::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #334155; }

body { font-feature-settings: "tnum"; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- Header dropdown panels ---------- */
#searchResults a, #notifList a { display: block; }
#searchResults a:hover, #notifList .notif-item:hover { background: rgba(30, 41, 59, 0.6); }
html[data-theme="light"] #searchResults a:hover,
html[data-theme="light"] #notifList .notif-item:hover { background: #f1f5f9; }

/* ---------- Light theme (toggled via Dark/Light button, persisted in localStorage) ---------- */
html[data-theme="light"] body { background-color: #f1f5f9 !important; color: #1e293b !important; }

/* Layout chrome surfaces */
html[data-theme="light"] .bg-\[\#0A0F1E\] { background-color: #f1f5f9 !important; }
html[data-theme="light"] .bg-\[\#0B1220\] { background-color: #ffffff !important; }
html[data-theme="light"] .bg-\[\#0B1220\]\/60 { background-color: rgba(255, 255, 255, 0.88) !important; }
html[data-theme="light"] .bg-\[\#0F1830\] { background-color: #ffffff !important; }

/* Borders */
html[data-theme="light"] .border-slate-800\/80 { border-color: #e2e8f0 !important; }
html[data-theme="light"] .border-slate-800 { border-color: #e2e8f0 !important; }

/* Text */
html[data-theme="light"] .text-white { color: #0f172a !important; }
html[data-theme="light"] .text-slate-200 { color: #1e293b !important; }
html[data-theme="light"] .text-slate-300 { color: #334155 !important; }
html[data-theme="light"] .text-slate-400 { color: #64748b !important; }
html[data-theme="light"] .text-slate-500 { color: #64748b !important; }
html[data-theme="light"] .text-slate-600 { color: #94a3b8 !important; }
html[data-theme="light"] .placeholder-slate-600::placeholder { color: #94a3b8 !important; }

/* Sidebar nav */
html[data-theme="light"] aside nav a:not(.bg-cyan-500\/10):hover { background-color: #f1f5f9 !important; }

/* Card shadows in light mode */
html[data-theme="light"] .shadow-black\/50 { --tw-shadow-color: rgb(148 163 184 / 0.25); }

/* Progress track bars on dashboard */
html[data-theme="light"] .bg-slate-800 { background-color: #e2e8f0 !important; }

/* ---------- Collapsible sidebar ---------- */
#sidebar { transition: width 0.2s ease; }
#sidebar.collapsed { width: 64px !important; }
#sidebar.collapsed .nav-label,
#sidebar.collapsed .nav-num,
#sidebar.collapsed .submenu-toggle,
#sidebar.collapsed .nav-sub,
#sidebar.collapsed .brand-text,
#sidebar.collapsed .brand-sub { display: none !important; }
#sidebar.collapsed .nav-link { justify-content: center; padding-left: 0.5rem; padding-right: 0.5rem; }

/* ==========================================================================
   MOBILE RULES (duplicated from responsive.css for robustness: these must
   apply even if responsive.css fails to load on the server).
   ========================================================================== */
#sidebarOverlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 55;
  background: rgba(2, 6, 16, 0.65);
}
body.nav-open { overflow: hidden; }

@media (max-width: 1023.98px) {
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 60;
    height: 100%;
    height: 100dvh;
    width: 248px !important;
    transform: translateX(-110%);
    transition: transform 0.25s ease;
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.45);
  }
  #sidebar.open { transform: translateX(0); }
  #sidebar.collapsed { width: 248px !important; }
  #sidebar.collapsed .nav-label,
  #sidebar.collapsed .nav-num,
  #sidebar.collapsed .submenu-toggle,
  #sidebar.collapsed .brand-text,
  #sidebar.collapsed .brand-sub { display: initial !important; }
  /* Submenus keep their own open/closed state on mobile: only neutralize
     the desktop collapsed "display:none", never force them open. */
  #sidebar.collapsed .nav-sub:not(.hidden) { display: block !important; }
  #sidebar.collapsed .nav-link { justify-content: flex-start; }
  #sidebarCollapse { display: none; }
  #sidebar .nav-link { min-height: 44px; }
  #sidebar .nav-sub a { padding-top: 0.6rem; padding-bottom: 0.6rem; }
}

@media (min-width: 1024px) {
  #mobileMenuBtn { display: none !important; }
  #sidebarOverlay { display: none !important; }
}

@media (max-width: 767.98px) {
  main .grid-cols-2:not([class*="sm:"]):not([class*="md:"]):not([class*="lg:"]):not([class*="xl:"]),
  main .grid-cols-3:not([class*="sm:"]):not([class*="md:"]):not([class*="lg:"]):not([class*="xl:"]),
  main .grid-cols-4:not([class*="sm:"]):not([class*="md:"]):not([class*="lg:"]):not([class*="xl:"]),
  main .grid-cols-5:not([class*="sm:"]):not([class*="md:"]):not([class*="lg:"]):not([class*="xl:"]),
  main .grid-cols-6:not([class*="sm:"]):not([class*="md:"]):not([class*="lg:"]):not([class*="xl:"]),
  main .grid-cols-12:not([class*="sm:"]):not([class*="md:"]):not([class*="lg:"]):not([class*="xl:"]) {
    grid-template-columns: 1fr !important;
  }
  main [class*="col-span-"]:not([class*="sm:"]):not([class*="md:"]):not([class*="lg:"]):not([class*="xl:"]) {
    grid-column: 1 / -1 !important;
  }
  main table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  main table thead,
  main table tbody {
    display: table;
    width: 100%;
    min-width: 560px;
  }
  main table th,
  main table td { white-space: nowrap; }
  main { padding: 0.75rem !important; }
  main .p-6 { padding: 1rem !important; }
  main .p-5 { padding: 1rem !important; }
  main .gap-5 { gap: 0.75rem !important; }
  main pre { max-width: 100%; overflow-x: auto; }
  main .flex.justify-between { flex-wrap: wrap; row-gap: 0.5rem; }
  main input, main select, main textarea { font-size: 16px !important; }
  main button, main .btn { min-height: 40px; }
}

@media (max-width: 767.98px) {
  header { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }
  #globalSearch { font-size: 16px; }
}

@media (min-width: 768px) and (max-width: 1023.98px) {
  main .grid-cols-5:not([class*="md:"]):not([class*="lg:"]):not([class*="xl:"]) {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
  main .grid-cols-3:not([class*="md:"]):not([class*="lg:"]):not([class*="xl:"]) {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}
