/* ============================================================
   PMTT Design System v2 — app.css
   ─────────────────────────────────────────────────────────────
   Clean foundation. Zero vendor theme dependency.
   Built over Bootstrap 4 only.
   
   Font: Inter  ·  Palette: Zinc  ·  Accent: Violet
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ============================================================
   1. DESIGN TOKENS — DARK (default)
   ============================================================ */
:root {
  /* ── Backgrounds ── */
  --bg-base:      #09090B;
  --bg-surface:   #18181B;
  --bg-elevated:  #27272A;
  --bg-hover:     #3F3F46;
  --bg-active:    #52525B;
  --bg-overlay:   rgba(0, 0, 0, 0.6);

  /* ── Text ── */
  --text-primary:   #FAFAFA;
  --text-secondary: #D4D4DC;  /* bright enough on #18181B surfaces */
  --text-tertiary:  #A8A8B3;  /* labels, muted — still readable */
  --text-disabled:  #7C7C86;  /* icons, placeholders — visible */
  --text-inverse:   #09090B;

  /* ── Borders ── */
  --border-default: #27272A;
  --border-subtle:  #1F1F23;
  --border-strong:  #3F3F46;
  --border-focus:   #8B5CF6;
  --border:         #27272A;

  /* ── Accent (Violet) ── */
  --accent:        #8B5CF6;
  --accent-hover:  #7C3AED;
  --accent-soft:   rgba(139, 92, 246, 0.15);
  --accent-text:   #C4B5FD;

  /* ── Semantic ── */
  --success:       #22C55E;
  --success-soft:  rgba(34, 197, 94, 0.15);
  --success-text:  #86EFAC;
  --warning:       #F59E0B;
  --warning-soft:  rgba(245, 158, 11, 0.15);
  --warning-text:  #FCD34D;
  --danger:        #EF4444;
  --danger-soft:   rgba(239, 68, 68, 0.15);
  --danger-text:   #FCA5A5;
  --info:          #06B6D4;
  --info-soft:     rgba(6, 182, 212, 0.15);
  --info-text:     #67E8F9;

  /* ── Sidebar ── */
  --sidebar-bg:           linear-gradient(180deg, #4e73df 0%, #224abe 100%);
  --sidebar-bg-solid:     #3a5bc7;
  --sidebar-hover:        rgba(255, 255, 255, 0.12);
  --sidebar-active:       rgba(255, 255, 255, 0.18);
  --sidebar-text:         rgba(255, 255, 255, 0.8);
  --sidebar-text-active:  #FFFFFF;
  --sidebar-width:        260px;
  --sidebar-collapsed-width: 72px;

  /* ── Header ── */
  --header-bg:       linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --header-bg-solid:  #6366f1;
  --header-height:   56px;
  --header-border:   transparent;

  /* ── Typography ── */
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-heading: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', monospace;

  --text-xs:   0.875rem;   /* 14px — smallest allowed for accessibility */
  --text-sm:   0.9375rem;  /* 15px */
  --text-base: 1.0625rem;  /* 17px — body default for older users */
  --text-md:   1.125rem;   /* 18px */
  --text-lg:   1.25rem;    /* 20px */
  --text-xl:   1.4375rem;  /* 23px */
  --text-2xl:  1.75rem;    /* 28px */
  --text-3xl:  2.125rem;   /* 34px */

  /* ── Spacing (4px grid) ── */
  --space-0:  0;
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* ── Radius ── */
  --radius-xs:   4px;
  --radius-sm:   6px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-full: 9999px;

  /* ── Shadows (minimal in dark) ── */
  --shadow-sm:   0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md:   0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg:   0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-xl:   0 20px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(139, 92, 246, 0.15);

  /* ── Transitions ── */
  --transition-fast:   150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base:   200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow:   300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* ── Z-index ── */
  --z-sidebar:   100;
  --z-header:    200;
  --z-backdrop:  250;
  --z-dropdown:  300;
  --z-modal:     400;
  --z-toast:     500;
  --z-tooltip:   600;

  /* ── Scrollbar ── */
  --scrollbar-bg:    transparent;
  --scrollbar-thumb: #3F3F46;
  --scrollbar-hover: #52525B;
}

/* ============================================================
   2. DESIGN TOKENS — LIGHT
   ============================================================ */
[data-theme="light"] {
  --bg-base:      #F9F9FB;
  --bg-surface:   #FFFFFF;
  --bg-elevated:  #F4F4F5;
  --bg-hover:     #E4E4E7;
  --bg-active:    #D4D4D8;
  --bg-overlay:   rgba(0, 0, 0, 0.4);

  --text-primary:   #18181B;
  --text-secondary: #3F3F46;  /* was #52525B — darker for readability */
  --text-tertiary:  #52525B;  /* was #71717A — darker for readability */
  --text-disabled:  #71717A;  /* was #A1A1AA — darker */
  --text-inverse:   #FFFFFF;

  --border-default: #E4E4E7;
  --border-subtle:  #F4F4F5;
  --border-strong:  #D4D4D8;
  --border:         #E4E4E7;

  --accent:        #7C3AED;
  --accent-hover:  #6D28D9;
  --accent-soft:   rgba(124, 58, 237, 0.1);
  --accent-text:   #6D28D9;

  --success:       #16A34A;
  --success-soft:  rgba(22, 163, 74, 0.1);
  --success-text:  #15803D;
  --warning:       #D97706;
  --warning-soft:  rgba(217, 119, 6, 0.1);
  --warning-text:  #B45309;
  --danger:        #DC2626;
  --danger-soft:   rgba(220, 38, 38, 0.1);
  --danger-text:   #B91C1C;
  --info:          #0891B2;
  --info-soft:     rgba(8, 145, 178, 0.1);
  --info-text:     #0E7490;

  --sidebar-bg:           linear-gradient(180deg, #4e73df 0%, #224abe 100%);
  --sidebar-bg-solid:     #3a5bc7;
  --sidebar-hover:        rgba(255, 255, 255, 0.12);
  --sidebar-active:       rgba(255, 255, 255, 0.18);
  --sidebar-text:         rgba(255, 255, 255, 0.8);
  --sidebar-text-active:  #FFFFFF;

  --header-bg:     linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --header-bg-solid: #6366f1;
  --header-border: transparent;

  --shadow-sm:   0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md:   0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg:   0 8px 24px rgba(0, 0, 0, 0.1);
  --shadow-xl:   0 20px 40px rgba(0, 0, 0, 0.12);

  --scrollbar-thumb: #D4D4D8;
  --scrollbar-hover: #A1A1AA;
}

/* ============================================================
   3. RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

/* Smooth theme transition */
body,
.sidebar, .topbar, .card, .footer,
.btn, .form-control, .modal-content,
.dropdown-menu, .table {
  transition: background-color var(--transition-slow),
              border-color var(--transition-slow),
              color var(--transition-slow);
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: none; }

img { max-width: 100%; height: auto; }

/* Selection */
::selection {
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-bg); }
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-bg);
}

/* ============================================================
   4. TYPOGRAPHY
   ============================================================ */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: var(--space-3);
}

h1, .h1 { font-size: var(--text-3xl); font-weight: 700; }
h2, .h2 { font-size: var(--text-2xl); font-weight: 700; }
h3, .h3 { font-size: var(--text-xl); }
h4, .h4 { font-size: var(--text-lg); }
h5, .h5 { font-size: var(--text-md); }
h6, .h6 { font-size: var(--text-sm); }

p { margin-bottom: var(--space-3); color: var(--text-primary); font-weight: 500; line-height: 1.7; }

small, .small { font-size: var(--text-xs); }
.text-xs { font-size: var(--text-xs) !important; }
.text-lg { font-size: var(--text-lg) !important; }

.text-muted  { color: var(--text-tertiary) !important; }
.text-primary { color: var(--accent) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger  { color: var(--danger) !important; }
.text-info    { color: var(--info) !important; }

.font-weight-bold { font-weight: 700 !important; }
.text-gray-800 { color: var(--text-primary) !important; }
.text-gray-500 { color: var(--text-tertiary) !important; }
.text-gray-400 { color: var(--text-tertiary) !important; }
.text-gray-300 { color: var(--text-disabled) !important; }
.text-white    { color: var(--text-primary) !important; }

/* ============================================================
   5. LAYOUT SHELL
   ============================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.main-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
  margin-left: var(--sidebar-width);
  transition: margin-left var(--transition-slow);
}

.sidebar-collapsed .main-wrapper {
  margin-left: var(--sidebar-collapsed-width);
}

.main-content {
  flex: 1;
}

#container-wrapper {
  padding: var(--space-6);
  max-width: 100%;
  width: 100%;
}

/* ============================================================
   6. SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  height: 100dvh;
  background: var(--sidebar-bg);
  border-right: none;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.15);
  position: fixed;
  top: 0;
  left: 0;
  z-index: var(--z-sidebar);
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  transition: width var(--transition-slow);
}

/* Sidebar header (logo) */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-4);
  height: var(--header-height);
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.1);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none !important;
  overflow: hidden;
}

.sidebar-logo-icon {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  font-size: var(--text-lg);
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 700;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition-base), width var(--transition-base);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.sidebar-close {
  display: none; /* shown on mobile only */
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: var(--text-xl);
  cursor: pointer;
  padding: var(--space-1);
  line-height: 1;
}

/* Sidebar body (scrollable nav) */
.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) 0;
}

/* Sidebar section grouping */
.sidebar-group-title {
  padding: var(--space-4) var(--space-4) var(--space-2);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.5);
  white-space: nowrap;
  overflow: hidden;
}

/* Sidebar divider */
.sidebar-divider {
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  margin: var(--space-2) var(--space-4);
}

/* Sidebar nav items */
.sidebar-item {
  list-style: none;
  margin: 1px 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  padding: 12px var(--space-4);
  margin: 0 var(--space-2);
  color: var(--sidebar-text);
  font-size: var(--text-base);
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  text-decoration: none !important;
  white-space: nowrap;
  min-height: 52px;
  cursor: pointer;
}

.sidebar-link i:first-child {
  font-size: var(--text-base);
  width: 20px;
  text-align: center;
  margin-right: var(--space-3);
  color: rgba(255, 255, 255, 0.6);
  transition: color var(--transition-fast);
  flex-shrink: 0;
}

.sidebar-link span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
  text-decoration: none;
}
.sidebar-link:hover i:first-child { color: #FFFFFF; }

.sidebar-link.active {
  background: var(--sidebar-active);
  color: #FFFFFF;
  box-shadow: inset 4px 0 0 #FFFFFF;
  font-weight: 600;
}
.sidebar-link.active i:first-child { color: #FFFFFF; }

/* Sidebar collapse arrow */
.sidebar-arrow {
  font-size: 10px !important;
  width: auto !important;
  margin-right: 0 !important;
  margin-left: auto;
  color: rgba(255, 255, 255, 0.4) !important;
  transition: transform var(--transition-base) !important;
}

.sidebar-link[aria-expanded="true"] .sidebar-arrow {
  transform: rotate(90deg);
}

/* Sidebar submenu */
.sidebar-submenu {
  list-style: none;
  padding: var(--space-1) 0;
  margin: 0;
}

.sidebar-sublink {
  display: flex;
  align-items: center;
  padding: 10px var(--space-3) 10px var(--space-10);
  color: var(--sidebar-text);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  text-decoration: none !important;
  margin: 1px var(--space-2);
  min-height: 48px;
}

.sidebar-sublink i {
  font-size: 11px;
  width: 16px;
  margin-right: var(--space-2);
  color: rgba(255, 255, 255, 0.5);
  transition: color var(--transition-fast);
}

.sidebar-sublink:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
  text-decoration: none;
}
.sidebar-sublink:hover i { color: #FFFFFF; }

.sidebar-sublink.active {
  color: #FFFFFF;
  background: var(--sidebar-active);
  font-weight: 600;
  box-shadow: inset 3px 0 0 #FFFFFF;
}
.sidebar-sublink.active i { color: #FFFFFF; }

/* Sidebar footer */
.sidebar-footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}

.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: var(--space-2);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: var(--text-sm);
}

.sidebar-collapse-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #FFFFFF;
}

.sidebar-collapse-btn i {
  transition: transform var(--transition-base);
}

/* ── Collapsed sidebar (desktop) ── */
.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-width);
}

.sidebar-collapsed .sidebar-logo-text,
.sidebar-collapsed .sidebar-group-title,
.sidebar-collapsed .sidebar-link span,
.sidebar-collapsed .sidebar-arrow {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar-collapsed .sidebar-link {
  justify-content: center;
  padding: 10px;
  margin: 0 var(--space-2);
}

.sidebar-collapsed .sidebar-link i:first-child {
  margin-right: 0;
  font-size: var(--text-lg);
}

.sidebar-collapsed .sidebar .collapse,
.sidebar-collapsed .sidebar .collapsing {
  display: none !important;
}

.sidebar-collapsed .sidebar-footer {
  padding: var(--space-3) var(--space-2);
}

.sidebar-collapsed .sidebar-collapse-btn i {
  transform: rotate(180deg);
}

/* ── Flyout submenus: appear on hover when sidebar collapsed ── */
.sidebar-collapsed .sidebar-item {
  position: relative;
}

.sidebar-collapsed .sidebar-item:hover > .collapse,
.sidebar-collapsed .sidebar-item:hover > .collapsing {
  display: block !important;
  position: absolute;
  left: 100%;
  top: 0;
  width: 220px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2) 0;
  z-index: 1000;
  animation: flyoutIn 150ms ease;
}

@keyframes flyoutIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.sidebar-collapsed .sidebar-item:hover > .collapse .sidebar-sublink,
.sidebar-collapsed .sidebar-item:hover > .collapsing .sidebar-sublink {
  padding: 8px 16px;
  color: var(--text-secondary);
  margin: 0;
  min-height: 40px;
  font-size: var(--text-sm);
}

.sidebar-collapsed .sidebar-item:hover > .collapse .sidebar-sublink:hover,
.sidebar-collapsed .sidebar-item:hover > .collapsing .sidebar-sublink:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-collapsed .sidebar-item:hover > .collapse .sidebar-sublink i,
.sidebar-collapsed .sidebar-item:hover > .collapsing .sidebar-sublink i {
  color: var(--text-tertiary);
}

.sidebar-collapsed .sidebar-item:hover > .collapse .sidebar-sublink:hover i,
.sidebar-collapsed .sidebar-item:hover > .collapsing .sidebar-sublink:hover i {
  color: var(--accent);
}

/* Sidebar backdrop (mobile) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: var(--z-backdrop);
  opacity: 0;
  transition: opacity var(--transition-slow);
}

.sidebar-open .sidebar-backdrop {
  display: block;
  opacity: 1;
}

/* ============================================================
   7. TOPBAR / HEADER
   ============================================================ */
.topbar {
  height: var(--header-height);
  background: var(--header-bg);
  border-bottom: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  padding: 0 var(--space-4);
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.topbar.scrolled {
  box-shadow: 0 2px 12px rgba(0,0,0,.2);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-left: auto;
}

/* Sidebar toggle button in header */
.topbar-toggle {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  padding: 0;
  font-size: var(--text-base);
}

.topbar-toggle:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
}

/* Topbar nav items (search, bell, theme, user) */
.topbar-action {
  position: relative;
  display: flex;
  align-items: center;
}

.topbar-action-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  padding: 0;
  font-size: var(--text-base);
  text-decoration: none !important;
}

.topbar-action-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
}

/* Notification badge */
.topbar-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 9px;
  padding: 2px 5px;
  border-radius: var(--radius-full);
  background: var(--danger);
  color: #fff;
  font-weight: 600;
  line-height: 1;
}

/* Topbar divider */
.topbar-divider {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.2);
  margin: 0 var(--space-2);
}

/* User profile in topbar */
.topbar-user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
  text-decoration: none !important;
  color: #FFFFFF !important;
}

.topbar-user:hover {
  background: rgba(255, 255, 255, 0.15);
}

.topbar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.topbar-user-initials {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--text-sm);
  flex-shrink: 0;
}

.topbar-user-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: #FFFFFF;
  white-space: nowrap;
}

.topbar-user-role {
  font-size: var(--text-xs);
  color: rgba(255, 255, 255, 0.7);
}

/* ============================================================
   8. DROPDOWN MENUS
   ============================================================ */
.dropdown-menu {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-default) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-lg) !important;
  padding: var(--space-2) !important;
  min-width: 200px;
}

.dropdown-menu .dropdown-item {
  padding: var(--space-3) var(--space-4);
  color: var(--text-secondary);
  font-size: var(--text-base);
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  min-height: 52px;
  display: flex;
  align-items: center;
}

.dropdown-menu .dropdown-item:hover,
.dropdown-menu .dropdown-item:focus {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.dropdown-menu .dropdown-item:active {
  background: var(--accent-soft);
  color: var(--accent);
}

.dropdown-menu .dropdown-item i {
  width: 18px;
  text-align: center;
  color: var(--text-disabled);
  transition: color var(--transition-fast);
}
.dropdown-menu .dropdown-item:hover i { color: var(--accent); }

.dropdown-divider { border-color: var(--border-subtle); margin: var(--space-1) 0; }

.dropdown-menu .dropdown-item:active {
  background: var(--bg-active);
  color: var(--text-primary);
}

.dropdown-menu .dropdown-item i {
  color: var(--text-tertiary);
  transition: color var(--transition-fast);
}
.dropdown-menu .dropdown-item:hover i { color: var(--accent); }

.dropdown-divider {
  border-top: 1px solid var(--border-subtle) !important;
  margin: var(--space-1) 0;
}

.dropdown-header {
  background: var(--bg-elevated) !important;
  color: var(--text-primary) !important;
  font-weight: 600;
  font-size: var(--text-sm);
  padding: var(--space-3) !important;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  border: none !important;
}

/* Notification dropdown */
.dropdown-list {
  width: 320px !important;
  padding: 0 !important;
  overflow: hidden;
}

.dropdown-list .dropdown-item {
  border-radius: 0;
  border-bottom: 1px solid var(--border-subtle);
  border-left: none !important;
  border-right: none !important;
  padding: var(--space-3);
  white-space: normal;
}

.dropdown-list .dropdown-item:last-child { border-bottom: none; }

.icon-circle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-circle.bg-primary { background: var(--accent-soft) !important; }
.icon-circle.bg-primary i { color: var(--accent) !important; }

/* ============================================================
   9. CARDS
   ============================================================ */
.card {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-default) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: none !important;
  transition: box-shadow var(--transition-base), border-color var(--transition-base), transform var(--transition-base);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-sm) !important;
  border-color: var(--border-strong) !important;
}

.card-header {
  background: var(--bg-surface) !important;
  border-bottom: 1px solid var(--border-subtle) !important;
  padding: var(--space-4) var(--space-5);
  font-weight: 600;
  color: var(--text-primary);
}

/* Allow modern-card-header to override card-header */
.modern-card-header.card-header {
  background: var(--bg-elevated) !important;
  border-bottom: 1px solid var(--border-default) !important;
  padding: var(--space-4) var(--space-5) !important;
}

.card-body { padding: var(--space-5); }

.card-footer {
  background: var(--bg-surface) !important;
  border-top: 1px solid var(--border-subtle) !important;
  padding: var(--space-4) var(--space-5);
  color: var(--text-secondary);
}

/* Stats cards — refined with accent border glow */
.card.border-left-primary,
.border-left-primary { border-left: 4px solid var(--accent) !important; }
.card.border-left-success,
.border-left-success { border-left: 4px solid var(--success) !important; }
.card.border-left-info,
.border-left-info { border-left: 4px solid var(--info) !important; }
.card.border-left-warning,
.border-left-warning { border-left: 4px solid var(--warning) !important; }
.card.border-left-danger,
.border-left-danger { border-left: 4px solid var(--danger) !important; }
.card.border-left-pink,
.border-left-pink { border-left: 4px solid #EC4899 !important; }

.card.border-left-primary:hover { box-shadow: -2px 0 12px var(--accent-soft), var(--shadow-sm) !important; }
.card.border-left-success:hover { box-shadow: -2px 0 12px var(--success-soft), var(--shadow-sm) !important; }
.card.border-left-info:hover    { box-shadow: -2px 0 12px var(--info-soft), var(--shadow-sm) !important; }
.card.border-left-warning:hover { box-shadow: -2px 0 12px var(--warning-soft), var(--shadow-sm) !important; }
.card.border-left-danger:hover  { box-shadow: -2px 0 12px var(--danger-soft), var(--shadow-sm) !important; }

/* ============================================================
   10. TABLES & DATATABLES
   ============================================================ */
.table {
  color: var(--text-primary);
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}

.table thead th {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-default);
  border-top: none;
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
}

.thead-light th {
  background: var(--bg-elevated) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border-default) !important;
}

.table tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-primary);
  vertical-align: middle;
  transition: background var(--transition-fast);
  line-height: 1.6;
}

.table tbody tr:hover td {
  background: var(--bg-hover);
}

/* Active row indicator */
.table tbody tr:hover td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

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

.table-bordered { border: 1px solid var(--border-default); }
.table-bordered td,
.table-bordered th { border: 1px solid var(--border-default); }

.table-striped tbody tr:nth-of-type(odd) td {
  background: var(--bg-elevated);
}

/* DataTables */
.dataTables_wrapper { padding: 0; }

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
  padding: var(--space-3) var(--space-4);
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label {
  color: var(--text-secondary);
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: var(--text-xs);
  min-height: auto;
}

.dataTables_wrapper .dataTables_length select {
  appearance: auto;
  -webkit-appearance: menulist;
  background-image: none !important;
  min-width: 50px;
}

.dataTables_wrapper .dataTables_filter input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

/* DataTables pagination */
.dataTables_wrapper .dataTables_paginate .paginate_button {
  padding: 4px 10px;
  margin: 0 2px;
  border-radius: var(--radius-md) !important;
  border: 1px solid var(--border-default) !important;
  background: var(--bg-surface) !important;
  color: var(--text-secondary) !important;
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--bg-hover) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-strong) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

table.dataTable.no-footer { border-bottom: 1px solid var(--border-subtle); }

table.dataTable thead .sorting,
table.dataTable thead .sorting_asc,
table.dataTable thead .sorting_desc {
  background-image: none !important;
  cursor: pointer;
}

table.dataTable thead .sorting::after,
table.dataTable thead .sorting_asc::after,
table.dataTable thead .sorting_desc::after {
  font-family: 'Font Awesome 5 Free';
  font-weight: 900;
  font-size: 10px;
  margin-left: 6px;
  color: var(--text-disabled);
}

table.dataTable thead .sorting::after { content: '\f0dc'; }
table.dataTable thead .sorting_asc::after { content: '\f0de'; color: var(--accent); }
table.dataTable thead .sorting_desc::after { content: '\f0dd'; color: var(--accent); }

.table-responsive {
  border-radius: var(--radius-lg);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ============================================================
   11. BUTTONS
   ============================================================ */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--text-base);
  border-radius: var(--radius-md);
  padding: 12px 22px;
  min-height: 52px;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none !important;
  white-space: nowrap;
}

.btn:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft); }

.btn-primary {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}
.btn-primary:hover {
  background: var(--accent-hover) !important;
  border-color: var(--accent-hover) !important;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-primary:active { transform: translateY(0); box-shadow: none; }
.btn:active { transform: scale(0.97); }

.btn-outline-primary {
  background: transparent !important;
  color: var(--accent) !important;
  border-color: var(--accent) !important;
}
.btn-outline-primary:hover {
  background: var(--accent-soft) !important;
  color: var(--accent) !important;
}

.btn-success {
  background: var(--success) !important;
  color: #fff !important;
  border-color: var(--success) !important;
}
.btn-success:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-danger {
  background: var(--danger) !important;
  color: #fff !important;
  border-color: var(--danger) !important;
}
.btn-danger:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-warning {
  background: var(--warning) !important;
  color: #fff !important;
  border-color: var(--warning) !important;
}

.btn-info {
  background: var(--info) !important;
  color: #fff !important;
  border-color: var(--info) !important;
}

.btn-secondary,
.btn-outline-secondary {
  background: var(--bg-elevated) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border-default) !important;
}
.btn-secondary:hover,
.btn-outline-secondary:hover {
  background: var(--bg-hover) !important;
  color: var(--text-primary) !important;
}

.btn-light {
  background: var(--bg-elevated) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border-default) !important;
}
.btn-light:hover { background: var(--bg-hover) !important; }

.btn-link {
  background: transparent !important;
  border: none !important;
  color: var(--text-secondary) !important;
  box-shadow: none !important;
  padding: var(--space-1);
}
.btn-link:hover {
  color: var(--text-primary) !important;
  text-decoration: none !important;
}

.btn-sm { font-size: var(--text-xs); padding: 6px 14px; min-height: 40px; }
.btn-lg { font-size: var(--text-md); padding: 14px 28px; min-height: 56px; }
.btn-block { width: 100%; }

/* Icon split button (used in many Index views) */
.btn-icon-split {
  padding: 0 !important;
  overflow: hidden;
}
.btn-icon-split .icon {
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.1);
  display: inline-flex;
  align-items: center;
}
.btn-icon-split .text {
  padding: 8px 14px;
}

/* Button group */
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.btn-group .btn:last-child { border-radius: 0 var(--radius-md) var(--radius-md) 0; }

/* ============================================================
   12. FORMS
   ============================================================ */
.form-control {
  background: var(--bg-elevated) !important;
  border: 1px solid var(--border-default) !important;
  color: var(--text-primary) !important;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: var(--text-base);
  font-family: var(--font-body);
  font-weight: 500;
  min-height: 52px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-soft) !important;
  outline: none;
}

.form-control::placeholder { color: var(--text-disabled); }

.form-control:disabled,
.form-control[readonly] {
  background: var(--bg-active) !important;
  opacity: 0.85;
  color: var(--text-primary) !important;
}

label, .form-group label, .control-label {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.form-group {
  margin-bottom: var(--space-4);
  transition: all var(--transition-fast);
}

.form-group:focus-within label,
.form-group:focus-within .control-label {
  color: var(--accent);
}

select.form-control {
  appearance: auto;
  -webkit-appearance: menulist;
  background-image: none !important;
}

.input-group-text {
  background: var(--bg-active) !important;
  border: 1px solid var(--border-default) !important;
  color: var(--text-tertiary) !important;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  box-shadow: none !important;
}

.input-group-prepend .input-group-text,
.input-group-prepend span {
  border-right: none;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  background: var(--bg-active) !important;
  border-color: var(--border-default) !important;
  color: var(--text-tertiary) !important;
  box-shadow: none !important;
}

.input-group-append .input-group-text,
.input-group-append span,
.input-group-append .btn {
  border-left: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.input-group .form-control {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.input-group .form-control:first-child {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

/* Custom checkbox/radio */
.custom-control-input:checked ~ .custom-control-label::before {
  background-color: var(--accent);
  border-color: var(--accent);
}

.custom-control-input:focus ~ .custom-control-label::before {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.custom-control-label {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.custom-control-label::before {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
}

/* Validation */
.field-validation-error,
.text-danger,
span[data-valmsg-for] {
  color: var(--danger) !important;
  font-size: var(--text-base);
  font-weight: 600;
}

.input-validation-error { border-color: var(--danger) !important; }

.validation-summary-errors {
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  color: var(--danger-text);
  font-size: var(--text-sm);
}
.validation-summary-errors ul { margin-bottom: 0; padding-left: var(--space-4); }

/* Select2 */
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
  background: var(--bg-elevated) !important;
  border: 1px solid var(--border-default) !important;
  border-radius: var(--radius-md) !important;
  min-height: 52px;
  color: var(--text-primary);
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
  color: var(--text-primary) !important;
  line-height: 46px;
  padding-left: 14px;
  font-size: var(--text-base);
}

.select2-container--default .select2-selection--single .select2-selection__arrow { height: 46px; }

.select2-container--default .select2-results__option--highlighted[aria-selected] {
  background: var(--accent) !important;
}

.select2-dropdown {
  background: var(--bg-surface) !important;
  border-color: var(--border-default) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-lg);
}

.select2-search__field {
  background: var(--bg-elevated) !important;
  border-color: var(--border-default) !important;
  color: var(--text-primary) !important;
  border-radius: var(--radius-sm) !important;
}

.select2-results__option {
  color: var(--text-primary) !important;
  padding: 6px 12px;
}

/* ============================================================
   13. ALERTS
   ============================================================ */
.alert {
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  padding: var(--space-4) var(--space-5);
  font-size: var(--text-base);
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}

.alert-success { background: var(--success-soft) !important; border-color: var(--success) !important; color: var(--success-text) !important; }
.alert-danger  { background: var(--danger-soft) !important; border-color: var(--danger) !important; color: var(--danger-text) !important; }
.alert-warning { background: var(--warning-soft) !important; border-color: var(--warning) !important; color: var(--warning-text) !important; }
.alert-info    { background: var(--info-soft) !important; border-color: var(--info) !important; color: var(--info-text) !important; }

.alert .close { color: inherit; opacity: 0.7; text-shadow: none; margin-left: auto; }
.alert .close:hover { opacity: 1; }

/* ============================================================
   14. BADGES
   ============================================================ */
.badge {
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  letter-spacing: 0.02em;
}

.badge-primary   { background: var(--accent-soft) !important; color: var(--accent-text) !important; }
.badge-success   { background: var(--success-soft) !important; color: var(--success-text) !important; }
.badge-danger    { background: var(--danger-soft) !important; color: var(--danger-text) !important; }
.badge-warning   { background: var(--warning-soft) !important; color: var(--warning-text) !important; }
.badge-info      { background: var(--info-soft) !important; color: var(--info-text) !important; }
.badge-secondary { background: var(--bg-active) !important; color: var(--text-secondary) !important; }
.badge-counter   { background: var(--danger) !important; color: #fff !important; }
.badge-pill      { border-radius: var(--radius-full); padding: 4px 10px; }

/* ============================================================
   15. MODALS
   ============================================================ */
.modal-content {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-default) !important;
  border-radius: var(--radius-xl) !important;
  box-shadow: var(--shadow-xl) !important;
}

.modal-header {
  border-bottom: 1px solid var(--border-subtle);
  padding: var(--space-4) var(--space-5);
}

.modal-header .modal-title {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--text-primary);
}

.modal-header .close {
  color: var(--text-tertiary);
  text-shadow: none;
  opacity: 0.7;
}
.modal-header .close:hover { opacity: 1; color: var(--text-primary); }

.modal-body {
  padding: var(--space-5);
  color: var(--text-primary);
  font-size: var(--text-base);
  font-weight: 500;
}

.modal-footer {
  border-top: 1px solid var(--border-subtle);
  padding: var(--space-4) var(--space-5);
  gap: var(--space-2);
}

.modal-backdrop.show { opacity: 0.6; background: #000; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal-backdrop { z-index: 1040 !important; }
.modal { z-index: 1050 !important; }

/* Fix: Bootstrap 4 .form-check-input is position:absolute with negative
   margin-left, which gets clipped by modal-dialog-scrollable overflow. */
.modal-body .form-check {
  overflow: visible;
}
.modal-dialog-scrollable .modal-body {
  overflow-x: visible;
}

.modal.fade .modal-dialog {
  transform: translateY(20px) scale(0.97);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
}
.modal.show .modal-dialog {
  transform: translateY(0) scale(1);
}

/* ============================================================
   16. FOOTER
   ============================================================ */
.footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  padding: var(--space-3) var(--space-6);
  flex-shrink: 0;
}

.footer .copyright {
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  text-align: center;
}

/* Legacy footer class */
.sticky-footer {
  background: var(--bg-surface) !important;
  border-top: 1px solid var(--border-subtle);
  padding: var(--space-3) var(--space-4);
  box-shadow: none !important;
}

/* ============================================================
   17. SCROLL TO TOP
   ============================================================ */
.scroll-top {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  width: 40px;
  height: 40px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  z-index: var(--z-dropdown);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: all var(--transition-base);
}

.scroll-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scroll-top:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Legacy class compat */
.scroll-to-top {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: none;
  width: 40px;
  height: 40px;
  text-align: center;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  line-height: 40px;
  box-shadow: var(--shadow-md);
  z-index: var(--z-dropdown);
}
.scroll-to-top:hover {
  background: var(--accent);
  color: #fff;
}

/* ============================================================
   18. PAGE HEADERS & STATS
   ============================================================ */
.page-header {
  margin-bottom: var(--space-6);
}

.page-header h1, .page-header .h3 {
  font-family: var(--font-heading);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.stats-card .card-body {
  padding: var(--space-4);
}

.stats-card .text-xs {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stats-card .h5 {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stats-card .fa-2x {
  font-size: 1.5rem;
  color: var(--text-disabled) !important;
}

/* ============================================================
   19. FILTER PANEL
   ============================================================ */
#filterPanel {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
  overflow: visible;
  max-height: 400px;
  overflow-y: auto;
}

#filterPanel .form-control { background: var(--bg-base) !important; }

#filterIcon { transition: transform var(--transition-base); }

/* ============================================================
   20. DETAIL VIEWS (dl/dt/dd)
   ============================================================ */
/* Global dt/dd — ensure they never blend with background */
dt {
  font-weight: 600;
  color: var(--text-secondary);
}
dd {
  color: var(--text-primary);
  font-weight: 500;
}
dl.row dt {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: var(--text-base);
}
dl.row dd {
  color: var(--text-primary);
  font-weight: 500;
  font-size: var(--text-base);
}

.detail-card dl {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: var(--space-2) var(--space-4);
  margin: 0;
}

.detail-card dt {
  font-weight: 500;
  color: var(--text-tertiary);
  font-size: var(--text-sm);
}

.detail-card dd {
  font-weight: 500;
  color: var(--text-primary);
  font-size: var(--text-sm);
  margin: 0;
}

/* ============================================================
   21. THEME TOGGLE
   ============================================================ */
/* Old switch style (dropdown toggle) */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

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

.switch .slider {
  position: absolute;
  inset: 0;
  background: var(--bg-active);
  border-radius: var(--radius-full);
  transition: background var(--transition-base);
  cursor: pointer;
}

.switch .slider:before {
  content: '';
  width: 16px;
  height: 16px;
  background: var(--text-primary);
  border-radius: var(--radius-full);
  position: absolute;
  top: 3px;
  left: 3px;
  transition: transform var(--transition-base);
}

.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider:before { transform: translateX(18px); }

/* ============================================================
   22. TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  top: calc(var(--header-height) + var(--space-4));
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 320px;
  max-width: 480px;
  pointer-events: auto;
  animation: toastSlideIn var(--transition-slow) ease;
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-primary);
}

.toast-item.toast-success { border-left: 4px solid var(--success); }
.toast-item.toast-error   { border-left: 4px solid var(--danger); }
.toast-item.toast-warning { border-left: 4px solid var(--warning); }
.toast-item.toast-info    { border-left: 4px solid var(--info); }

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

/* ============================================================
   23. LOADING & SKELETON
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

.skeleton-text { height: 14px; margin-bottom: var(--space-2); width: 80%; }
.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 60%; }
.skeleton-avatar { width: 40px; height: 40px; border-radius: var(--radius-full); }
.skeleton-card { height: 120px; }

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
}
.loading-overlay .spinner-border { width: 3rem; height: 3rem; }

/* ============================================================
   24. EMPTY STATES
   ============================================================ */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--text-tertiary);
}

.empty-state i { font-size: 3rem; margin-bottom: var(--space-4); color: var(--text-disabled); }
.empty-state h5 { color: var(--text-secondary); margin-bottom: var(--space-2); }
.empty-state p { font-size: var(--text-sm); max-width: 360px; margin: 0 auto; }

/* ============================================================
   25. AVATARS
   ============================================================ */
.avatar-circle {
  width: 35px;
  height: 35px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: var(--text-sm);
  flex-shrink: 0;
}

.img-profile {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 2px solid var(--border-default);
}

.user-avatar-default {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--text-sm);
}

/* Soft badges */
.badge-soft-primary   { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); font-weight: 600; padding: .3rem .6rem; border-radius: var(--radius-sm); }
.badge-soft-success   { background: color-mix(in srgb, var(--success) 12%, transparent); color: var(--success); font-weight: 600; padding: .3rem .6rem; border-radius: var(--radius-sm); }
.badge-soft-danger    { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); font-weight: 600; padding: .3rem .6rem; border-radius: var(--radius-sm); }
.badge-soft-warning   { background: color-mix(in srgb, var(--warning) 12%, transparent); color: var(--warning); font-weight: 600; padding: .3rem .6rem; border-radius: var(--radius-sm); }
.badge-soft-info      { background: color-mix(in srgb, var(--info) 12%, transparent); color: var(--info); font-weight: 600; padding: .3rem .6rem; border-radius: var(--radius-sm); }
.badge-soft-secondary { background: color-mix(in srgb, var(--text-tertiary) 12%, transparent); color: var(--text-secondary); font-weight: 600; padding: .3rem .6rem; border-radius: var(--radius-sm); }

/* ============================================================
   26. ACTION BUTTONS (table rows)
   ============================================================ */
.action-buttons {
  display: flex;
  gap: var(--space-1);
  flex-wrap: nowrap;
}

.action-buttons .btn {
  padding: 4px 8px;
  font-size: var(--text-xs);
  min-height: 28px;
  border-radius: var(--radius-sm);
}

/* ============================================================
   27. CALENDAR CONTAINER
   ============================================================ */
.calendar-container {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.calendar-header-mobile {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
}

.calendar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

/* ============================================================
   28. LOGIN / AUTH PAGE STYLES
   ============================================================ */
.container-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}

.login-card {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-default) !important;
  border-radius: var(--radius-xl) !important;
  overflow: hidden;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-xl) !important;
  position: relative;
}

/* Accent gradient bar at top */
.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #A78BFA, #C084FC);
  z-index: 1;
}

.login-form { padding: var(--space-8); }

.login-icon {
  width: 64px;
  height: 64px;
  background: var(--accent-soft);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}
.login-icon i { font-size: var(--text-2xl); color: var(--accent); }

.login-title {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.login-btn { min-height: 44px; font-weight: 600; }

.dark-mode-toggle {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: var(--z-dropdown);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.dark-mode-toggle:hover { background: var(--bg-hover); }
.dark-mode-toggle i { color: var(--text-secondary); font-size: var(--text-base); }

.toggle-switch {
  width: 36px;
  height: 20px;
  background: var(--bg-active);
  border-radius: var(--radius-full);
  position: relative;
  transition: background var(--transition-base);
}
.toggle-switch::after {
  content: '';
  width: 14px;
  height: 14px;
  background: var(--text-primary);
  border-radius: var(--radius-full);
  position: absolute;
  top: 3px;
  left: 3px;
  transition: transform var(--transition-base);
}
[data-theme="light"] .toggle-switch::after { transform: translateX(16px); }
[data-theme="light"] .toggle-switch { background: var(--accent); }

/* ============================================================
   29. MODERN TABLE ENHANCEMENTS (lib compat)
   ============================================================ */
.modern-table thead th {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: .75rem;
  letter-spacing: .5px;
  padding: .75rem;
  border: none;
  border-bottom: 1px solid var(--border);
}
.modern-table tbody td {
  padding: .75rem;
  vertical-align: middle;
  border-color: var(--border);
  color: var(--text-primary);
}
.modern-table tbody tr { transition: background .15s ease, box-shadow .15s ease; }
.modern-table tbody tr:hover {
  background: var(--bg-elevated);
  box-shadow: inset 3px 0 0 var(--accent);
}

.report-table thead th {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: .75rem;
  letter-spacing: .5px;
  padding: .75rem;
  border: none;
  border-bottom: 1px solid var(--border);
}
.report-table tbody td {
  padding: .75rem;
  vertical-align: middle;
  border-color: var(--border);
}

/* modern-detail-card/modern-card-header: main styles in pmtt-form-modern.css */
/* These are fallback overrides to ensure they beat Bootstrap .card */
.modern-detail-card.card {
  border: 1px solid var(--border-default) !important;
  border-radius: var(--radius-lg) !important;
  background: var(--bg-surface) !important;
  overflow: visible !important;
  position: relative;
}

/* Accent top bar on modern detail cards */
.modern-detail-card.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #A78BFA, #C084FC);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  z-index: 1;
}
.modern-card-header {
  background: var(--bg-elevated) !important;
  border-bottom: 1px solid var(--border-default) !important;
  padding: var(--space-4) var(--space-5) !important;
}
.modern-card-header .section-title {
  font-weight: 600;
  font-size: .875rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.star-toggle { transition: transform .2s ease; display: inline-block; }
.star-toggle:hover { transform: scale(1.2); }

.font-weight-500 { font-weight: 500; }

/* Employee avatar (NhanVien Index) */
.employee-avatar { width: 35px; height: 35px; border-radius: 50%; overflow: hidden; }
.employee-avatar img { width: 100%; height: 100%; object-fit: cover; border: 2px solid var(--border); }

/* ============================================================
   30. BOOTSTRAP UTILITY OVERRIDES
   ============================================================ */
.bg-white     { background: var(--bg-surface) !important; }
.bg-light     { background: var(--bg-elevated) !important; }
.bg-gradient-primary { background: linear-gradient(135deg, var(--accent), var(--accent-hover)) !important; }
.bg-gradient-login   { background: var(--bg-base) !important; }
.bg-primary   { background: var(--accent) !important; }
.bg-success   { background: var(--success) !important; }
.bg-danger    { background: var(--danger) !important; }
.bg-warning   { background: var(--warning) !important; }
.bg-info      { background: var(--info) !important; }

.border-primary { border-color: var(--accent) !important; }
.border-bottom  { border-color: var(--border-subtle) !important; }
.border         { border-color: var(--border-default) !important; }
.border-left-0  { border-left: 0 !important; }

.shadow, .shadow-sm, .shadow-lg { box-shadow: none !important; }

.text-uppercase { text-transform: uppercase; letter-spacing: 0.06em; }
.rounded        { border-radius: var(--radius-md) !important; }
.rounded-circle { border-radius: var(--radius-full) !important; }

hr { border-color: var(--border-subtle); }

.list-group-item {
  background: var(--bg-surface);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}
.list-group-item:hover { background: var(--bg-hover); }

/* Nav tabs/pills */
.nav-tabs { border-bottom: 1px solid var(--border-subtle); }

.nav-tabs .nav-link {
  color: var(--text-tertiary);
  border: none;
  padding: var(--space-3) var(--space-5);
  font-weight: 600;
  font-size: var(--text-sm);
  min-height: 48px;
  display: flex;
  align-items: center;
  transition: all var(--transition-fast);
}
.nav-tabs .nav-link:hover {
  color: var(--text-primary);
  border-color: transparent;
}
.nav-tabs .nav-link.active {
  color: var(--accent);
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--accent);
}

/* Breadcrumb */
.breadcrumb {
  background: transparent;
  font-size: var(--text-base);
  font-weight: 600;
  padding: 0;
  margin: 0;
}

.breadcrumb-item a { color: var(--text-secondary); }
.breadcrumb-item a:hover { color: var(--accent); }
.breadcrumb-item.active { color: var(--text-primary); }
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-tertiary); }

/* Pagination */
.page-item .page-link {
  background: var(--bg-surface);
  border-color: var(--border-default);
  color: var(--text-secondary);
  font-size: var(--text-sm);
}
.page-item .page-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.page-item.active .page-link {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Tooltip */
.tooltip-inner {
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
}

/* Popover */
.popover {
  background: var(--bg-surface);
  border-color: var(--border-default);
}
.popover-body { color: var(--text-secondary); }

/* ============================================================
   31. MOBILE BOTTOM NAV
   ============================================================ */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-default);
  z-index: var(--z-header);
  padding: var(--space-1) 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
  justify-content: space-around;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px var(--space-2);
  font-size: 10px;
  color: var(--text-tertiary);
  text-decoration: none !important;
  min-width: 56px;
  transition: color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav-item i { font-size: 18px; }

.mobile-nav-item.active,
.mobile-nav-item:hover { color: var(--accent); }

/* ============================================================
   32. RESPONSIVE / MOBILE
   ============================================================ */
@media (max-width: 768px) {
  /* Sidebar: off-screen by default, slides in when .sidebar-open */
  .sidebar {
    width: var(--sidebar-width) !important;
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
    z-index: calc(var(--z-backdrop) + 10);
  }

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

  .sidebar-close { display: block; }

  .main-wrapper {
    margin-left: 0 !important;
  }

  .sidebar-collapsed .main-wrapper {
    margin-left: 0 !important;
  }

  #container-wrapper {
    padding: var(--space-3);
  }

  .topbar-user-name,
  .topbar-user-role {
    display: none;
  }

  .mobile-nav { display: flex; }

  .footer { padding-bottom: calc(var(--space-3) + 56px); }

  .stats-card { margin-bottom: var(--space-3) !important; }

  .card-header { padding: var(--space-3) var(--space-4); }
  .card-body { padding: var(--space-3); }

  .scroll-top,
  .scroll-to-top { display: none !important; }

  .detail-card dl {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }

  .detail-card dt {
    padding-top: var(--space-2);
    font-size: var(--text-xs);
  }

  /* ── Mobile pagination fix ── */
  .dataTables_wrapper .dataTables_paginate {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 3px;
    padding: var(--space-2) !important;
    overflow: visible;
  }

  .dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 4px 8px !important;
    margin: 0 !important;
    min-width: 28px;
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px !important;
    line-height: 1;
    box-sizing: border-box;
  }

  .dataTables_wrapper .dataTables_paginate .paginate_button.previous,
  .dataTables_wrapper .dataTables_paginate .paginate_button.next {
    font-size: 10px !important;
    padding: 4px 6px !important;
  }

  .dataTables_wrapper .dataTables_info {
    text-align: center;
    padding: var(--space-2) !important;
    font-size: var(--text-xs) !important;
  }

  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter {
    text-align: center;
    float: none !important;
    padding: var(--space-2) var(--space-3) !important;
  }

  /* ── Mobile filter panel ── */
  #filterPanel {
    padding: var(--space-3);
  }

  /* ── Mobile form fields ── */
  .modern-field-group .row > [class*="col-md-"] {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* ── Mobile breadcrumb ── */
  .breadcrumb {
    flex-wrap: nowrap;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--space-1);
  }

  /* ── Mobile page title ── */
  .d-sm-flex.align-items-center.justify-content-between {
    flex-direction: column;
    align-items: flex-start !important;
    gap: var(--space-2);
  }

  /* ── Mobile table responsive ── */
  .table-responsive {
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
  }
}

@media (max-width: 640px) {
  .form-group .col-md-6,
  .form-group .col-lg-4 {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

@media (min-width: 769px) {
  .mobile-nav { display: none !important; }
  .sidebar-close { display: none !important; }
}

/* ============================================================
   33. ANIMATIONS
   ============================================================ */
.animated--grow-in {
  animation: growIn 120ms ease-out !important;
}

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

/* Page entrance — REMOVED from #container-wrapper.
   ANY CSS animation (even opacity-only) creates a stacking context,
   which traps position:fixed modals & popovers below the <body>-level
   .modal-backdrop.  The 0.3s fade-in is not worth breaking every modal
   on every page. The keyframes are kept for other utility classes. */
@keyframes pageEnter {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.fade-in { animation: fadeIn var(--transition-base) ease; }

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

.slide-up { animation: slideUp var(--transition-base) ease; }

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

/* ============================================================
   34. PRINT
   ============================================================ */
@media print {
  .sidebar { display: none !important; }
  .topbar { display: none !important; }
  .footer, .sticky-footer { display: none !important; }
  .scroll-top, .scroll-to-top { display: none !important; }
  .mobile-nav { display: none !important; }
  .sidebar-backdrop { display: none !important; }
  .main-wrapper { margin-left: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
  body { background: #fff !important; color: #000 !important; }
}

/* ============================================================
   35. ACCESSIBILITY
   ============================================================ */
@media (pointer: coarse) {
  .btn, .sidebar-link, .sidebar-sublink, .dropdown-item, .mobile-nav-item,
  .nav-tabs .nav-link, .page-item .page-link, .breadcrumb-item a {
    min-height: 52px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (forced-colors: active) {
  .btn { border: 1px solid ButtonText; }
  .card { border: 1px solid CanvasText; }
}

/* Focus visible rings */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
  outline: none;
}

/* ============================================================
   36. BACKWARD COMPAT — body.dark-mode
   ============================================================ */
body.dark-mode {
  background: var(--bg-base) !important;
  color: var(--text-primary) !important;
}

/* Ruang-admin compat: text-pink (used in Nhom/Members.cshtml) */
.text-pink { color: #EC4899 !important; }
