body {
  font-family: Tahoma, 'Segoe UI', system-ui, sans-serif;
  background: #f3f4f6;
  color: #111827;
}

body.sidebar-open {
  overflow: hidden;
}

body.app-loading {
  cursor: wait;
}

.nav-item {
  transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
  border-radius: 1rem;
}

.nav-item.active {
  background-color: #1e1b4b;
  color: white;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.card-scan-effect:focus {
  outline: none;
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.3);
}

.btn-press:active {
  transform: scale(0.97);
}

button.is-loading,
input[type='submit'].is-loading {
  opacity: 0.75;
  cursor: wait;
}

#sidebarOverlay {
  transition: opacity 0.3s ease;
}

#sidebarOverlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

#sidebar {
  transform: translate3d(100%, 0, 0);
  transition: transform 0.3s ease-in-out;
  will-change: transform;
}

#sidebar.is-open {
  transform: translate3d(0, 0, 0);
}

#mainContent {
  transition: margin-right 0.3s ease-in-out, background-color 0.2s ease, color 0.2s ease;
}

@media (min-width: 1024px) {
  #sidebarOverlay {
    display: none !important;
  }

  body.sidebar-open {
    overflow: auto;
  }

  #mainContent.is-sidebar-open {
    margin-right: 18rem;
  }
}

.responsive-table {
  min-width: 720px;
}

/* ── Global loading overlay (car theme) ── */

#appLoadingOverlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

#appLoadingOverlay.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.app-loading-card {
  width: min(100%, 18rem);
  background: #ffffff;
  border-radius: 1.5rem;
  padding: 1.75rem 1.5rem 1.5rem;
  text-align: center;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.25);
}

.app-loading-scene {
  position: relative;
  height: 4.5rem;
  overflow: hidden;
  margin-bottom: 1rem;
}

.app-loading-road {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.75rem;
  height: 0.35rem;
  background: linear-gradient(to left, #cbd5e1 50%, transparent 50%);
  background-size: 1.25rem 100%;
  animation: roadMove 0.55s linear infinite;
  border-radius: 999px;
}

.app-loading-car {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2rem;
  line-height: 1;
  animation: carBounce 0.7s ease-in-out infinite alternate;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.2));
}

.app-loading-text {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e293b;
}

@keyframes roadMove {
  from { background-position: 0 0; }
  to { background-position: -1.25rem 0; }
}

@keyframes carBounce {
  from { transform: translateX(-50%) translateY(0); }
  to { transform: translateX(-50%) translateY(-0.35rem); }
}

/* ── Dark mode ── */

html.dark body {
  background: #0f172a;
  color: #e5e7eb;
}

html.dark #mainContent > .sticky,
html.dark .bg-white,
html.dark .bg-white\/80 {
  background-color: #1f2937 !important;
}

html.dark .bg-gray-100 {
  background-color: #111827 !important;
}

html.dark .bg-gray-50,
html.dark .hover\:bg-gray-50:hover {
  background-color: #374151 !important;
}

html.dark .bg-gray-200,
html.dark a.bg-gray-200 {
  background-color: #374151 !important;
  color: #e5e7eb !important;
}

html.dark .border,
html.dark .border-b,
html.dark .border-t,
html.dark .border-r,
html.dark .border-gray-100,
html.dark .border-gray-200 {
  border-color: #374151 !important;
}

html.dark .text-gray-900,
html.dark .text-gray-800,
html.dark .text-gray-700,
html.dark .text-gray-600 {
  color: #f3f4f6 !important;
}

html.dark .text-gray-500,
html.dark .text-gray-400 {
  color: #9ca3af !important;
}

html.dark .shadow,
html.dark .shadow-md,
html.dark .shadow-sm,
html.dark .shadow-2xl {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35) !important;
}

html.dark #mainContent > .sticky {
  border-color: #374151 !important;
}

html.dark #sidebarToggle {
  background-color: #312e81 !important;
  color: #fde68a !important;
}

html.dark #sidebarToggle:hover {
  background-color: #3730a3 !important;
}

html.dark #themeToggle {
  background-color: #374151 !important;
  color: #fde68a !important;
}

html.dark #themeToggle:hover {
  background-color: #4b5563 !important;
}

html.dark input,
html.dark select,
html.dark textarea {
  background-color: #374151 !important;
  border-color: #4b5563 !important;
  color: #f3f4f6 !important;
}

html.dark input::placeholder,
html.dark textarea::placeholder {
  color: #9ca3af;
}

html.dark .bg-blue-50 {
  background-color: #1e3a5f !important;
  border-color: #2563eb !important;
}

html.dark .text-blue-900,
html.dark .text-blue-800,
html.dark .text-blue-700 {
  color: #bfdbfe !important;
}

html.dark .border-blue-200,
html.dark .border-blue-300 {
  border-color: #2563eb !important;
}

html.dark .bg-indigo-50 {
  background-color: #1e1b4b !important;
  border-color: #4338ca !important;
}

html.dark .border-indigo-200 {
  border-color: #4338ca !important;
}

html.dark .text-indigo-500 {
  color: #a5b4fc !important;
}

html.dark .text-indigo-900 {
  color: #e0e7ff !important;
}

html.dark .bg-yellow-50 {
  background-color: #422006 !important;
  border-color: #ca8a04 !important;
}

html.dark .text-yellow-800 {
  color: #fde68a !important;
}

html.dark .border-yellow-200 {
  border-color: #ca8a04 !important;
}

html.dark .bg-green-100 {
  background-color: #14532d !important;
}

html.dark .text-green-800 {
  color: #bbf7d0 !important;
}

html.dark .bg-red-100 {
  background-color: #450a0a !important;
}

html.dark .text-red-700,
html.dark .text-red-800 {
  color: #fecaca !important;
}

html.dark .bg-yellow-100 {
  background-color: #422006 !important;
}

html.dark .text-yellow-800 {
  color: #fde68a !important;
}

html.dark .bg-blue-100 {
  background-color: #1e3a5f !important;
}

html.dark .text-blue-800 {
  color: #bfdbfe !important;
}

html.dark .bg-red-100.text-red-700,
html.dark .bg-red-100 .text-red-700 {
  color: #fecaca !important;
}

html.dark .app-loading-card {
  background: #1f2937;
}

html.dark .app-loading-text {
  color: #e5e7eb;
}

html.dark .app-loading-road {
  background: linear-gradient(to left, #64748b 50%, transparent 50%);
  background-size: 1.25rem 100%;
}

html.dark .login-card {
  background-color: #1f2937 !important;
  color: #f3f4f6;
}

html.dark .login-card .text-gray-500 {
  color: #9ca3af !important;
}

html.dark body.login-page {
  background: #0f172a !important;
}
