:root {
  --primary: #FFCA00;
  --primary-hover: #e6b500;
  --primary-light: #fff3cc;
  --primary-dark: #cc9e00;
  --dark: #000000;
  --danger: #FF0000;
  --danger-hover: #cc0000;

  --bg-page: #f3f4f6;
  --bg-card: #ffffff;
  --bg-sidebar: #000000;
  --bg-input: #ffffff;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-inverse: #ffffff;
  --border: #e5e7eb;
  --border-input: #d1d5db;
}

[data-theme="dark"] {
  --bg-page: #0a0a0a;
  --bg-card: #1a1a1a;
  --bg-sidebar: #0f0f0f;
  --bg-input: #2d2d2d;
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-inverse: #000000;
  --border: #2d2d2d;
  --border-input: #404040;
}

* {
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

body {
  background: var(--bg-page);
  color: var(--text-primary);
}

input, select, textarea {
  background: var(--bg-input);
  border-color: var(--border-input);
  color: var(--text-primary);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 202, 0, 0.15);
}

button:not(:disabled) {
  cursor: pointer;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  height: 100vh;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 40;
  overflow-y: auto;
}

.sidebar-header {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-header h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.875rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  transition: all 0.15s;
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.08);
  color: var(--primary);
}

.sidebar-link.active {
  background: rgba(255,202,0,0.12);
  color: var(--primary);
}

.sidebar-link .icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-link:hover .icon,
.sidebar-link.active .icon {
  opacity: 1;
}

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-footer .user-info {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.875rem;
  border-radius: 8px;
  color: rgba(255,255,255,0.8);
  font-size: 0.8125rem;
  text-decoration: none;
  transition: background 0.15s;
}

.sidebar-footer .user-info:hover {
  background: rgba(255,255,255,0.08);
}

.avatar-initials {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--primary);
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.main-content {
  margin-left: 260px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-content-inner {
  flex: 1;
  padding: 1.5rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 1rem;
}

.card-body {
  padding: 1.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.15s;
  border: none;
  text-decoration: none;
  cursor: pointer;
}

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

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

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: var(--danger-hover);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}

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

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.btn .icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  cursor: pointer;
  user-select: none;
}

.toggle-switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.toggle-track {
  position: relative;
  width: 40px;
  height: 22px;
  background: #d1d5db;
  border-radius: 11px;
  transition: background 0.2s;
  flex-shrink: 0;
}

[data-theme="dark"] .toggle-track {
  background: #4b5563;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-track {
  background: var(--primary);
}

.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(18px);
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

.form-input {
  width: 100%;
  padding: 0.5625rem 0.75rem;
  border: 1px solid var(--border-input);
  border-radius: 8px;
  font-size: 0.875rem;
  background: var(--bg-input);
  color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 202, 0, 0.12);
}

.form-select {
  width: 100%;
  padding: 0.5625rem 0.75rem;
  border: 1px solid var(--border-input);
  border-radius: 8px;
  font-size: 0.875rem;
  background: var(--bg-input);
  color: var(--text-primary);
  appearance: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

table thead {
  background: var(--bg-page);
}

table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

table td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

table tr:hover {
  background: rgba(255,202,0,0.04);
}

.alert {
  padding: 0.875rem 1rem;
  border-radius: 10px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}

.alert-success {
  background: #d1fae5;
  border-color: #a7f3d0;
  color: #065f46;
}

.alert-error {
  background: #fee2e2;
  border-color: #fecaca;
  color: #991b1b;
}

.alert-warning {
  background: #fef3c7;
  border-color: #fde68a;
  color: #92400e;
}

.alert-info {
  background: #dbeafe;
  border-color: #bfdbfe;
  color: #1e40af;
}

[data-theme="dark"] .alert-success {
  background: #064e3b;
  border-color: #065f46;
  color: #a7f3d0;
}

[data-theme="dark"] .alert-error {
  background: #7f1d1d;
  border-color: #991b1b;
  color: #fecaca;
}

[data-theme="dark"] .alert-warning {
  background: #78350f;
  border-color: #92400e;
  color: #fde68a;
}

[data-theme="dark"] .alert-info {
  background: #1e3a5f;
  border-color: #1e40af;
  color: #bfdbfe;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1875rem 0.5625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-green {
  background: #d1fae5;
  color: #065f46;
}

.badge-red {
  background: #fee2e2;
  color: #991b1b;
}

.badge-blue {
  background: #dbeafe;
  color: #1e40af;
}

.badge-purple {
  background: #ede9fe;
  color: #5b21b6;
}

[data-theme="dark"] .badge-green {
  background: #064e3b;
  color: #a7f3d0;
}

[data-theme="dark"] .badge-red {
  background: #7f1d1d;
  color: #fecaca;
}

[data-theme="dark"] .badge-blue {
  background: #1e3a5f;
  color: #bfdbfe;
}

[data-theme="dark"] .badge-purple {
  background: #2e1065;
  color: #c4b5fd;
}

.text-primary-color {
  color: var(--primary);
}

.bg-primary-light {
  background: var(--primary-light);
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 1.125rem;
  cursor: pointer;
  transition: background 0.15s;
}

.theme-toggle:hover {
  background: rgba(255,255,255,0.08);
  color: var(--primary);
}

/* Mobile top bar */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  z-index: 41;
  padding: 0 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.mobile-topbar-home {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}

.mobile-topbar-home:hover {
  background: var(--border);
  color: var(--text-primary);
}

.mobile-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1.375rem;
  cursor: pointer;
  transition: background 0.15s;
}

.mobile-menu-btn:hover {
  background: var(--border);
}

.sidebar-overlay {
  display: none;
}

@media (max-width: 767px) {
  .mobile-topbar {
    display: flex;
  }

  .sidebar {
    padding-top: 52px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 39;
  }

  .sidebar-overlay.open {
    display: block;
  }

  .main-content {
    margin-left: 0;
    padding-top: 52px;
  }

  .main-content-inner {
    padding: 1rem;
  }
}

.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}

.stat-card h3 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin: 0 0 0.25rem;
}

.stat-card .value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 0.25rem;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin: 0 0 1.5rem;
}

[data-theme="dark"] .bg-white,
[data-theme="dark"] .bg-gray-50 {
  background: var(--bg-card) !important;
}

[data-theme="dark"] .text-gray-800,
[data-theme="dark"] .text-gray-900 {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .text-gray-500,
[data-theme="dark"] .text-gray-600,
[data-theme="dark"] .text-gray-700 {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .border,
[data-theme="dark"] .border-gray-200,
[data-theme="dark"] .border-gray-300,
[data-theme="dark"] .border-b,
[data-theme="dark"] .border-t,
[data-theme="dark"] .divide-gray-200,
[data-theme="dark"] .divide-gray-200 > * {
  border-color: var(--border) !important;
}

[data-theme="dark"] .hover\:bg-gray-50:hover {
  background: rgba(255,255,255,0.03) !important;
}

[data-theme="dark"] .shadow,
[data-theme="dark"] .shadow-sm,
[data-theme="dark"] .shadow-md,
[data-theme="dark"] .shadow-lg {
  box-shadow: 0 1px 3px rgba(0,0,0,0.3) !important;
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--bg-input);
  border-color: var(--border-input);
  color: var(--text-primary);
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}

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

button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

[data-theme="dark"] img[data-theme-show="light"] {
  display: none !important;
}

[data-theme="dark"] img[data-theme-show="dark"] {
  display: inline-block !important;
}

[data-theme="light"] img[data-theme-show="dark"] {
  display: none !important;
}

[data-theme="light"] img[data-theme-show="light"] {
  display: inline-block !important;
}
