/* ==========================================================================
   ENTERPRISE FINANCE & HR SUITE - MODERN DESIGN SYSTEM
   ========================================================================== */
/* Fonts loaded via <link> in HTML <head> for fast non-blocking rendering */
:root {
  /* Color Palette - Light Mode */
  --bg-app: #f4f6fb;
  --bg-surface: #ffffff;
  --bg-surface-soft: #f8fafc;
  --bg-surface-elevated: #ffffff;
  --bg-sidebar: #0f172a;
  --bg-sidebar-hover: #1e293b;
  --bg-sidebar-active: #3b82f6;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  --border-color: #e2e8f0;
  --border-light: #f1f5f9;

  /* Accent Brand Colors */
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-light: #eff6ff;
  --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);

  --emerald: #10b981;
  --emerald-light: #ecfdf5;
  --emerald-gradient: linear-gradient(135deg, #10b981 0%, #047857 100%);

  --amber: #f59e0b;
  --amber-light: #fffbeb;

  --rose: #ef4444;
  --rose-light: #fef2f2;

  --purple: #8b5cf6;
  --purple-light: #f5f3ff;

  --indigo: #6366f1;
  --indigo-light: #eef2ff;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.06);

  /* Radius & Transitions */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Variables */
[data-theme="dark"] {
  --bg-app: #0b0f19;
  --bg-surface: #111827;
  --bg-surface-soft: #1e293b;
  --bg-surface-elevated: #1f2937;
  --bg-sidebar: #070b14;
  --bg-sidebar-hover: #131b2e;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;

  --border-color: #1e293b;
  --border-light: #162032;

  --primary-light: rgba(59, 130, 246, 0.15);
  --emerald-light: rgba(16, 185, 129, 0.15);
  --amber-light: rgba(245, 158, 11, 0.15);
  --rose-light: rgba(239, 68, 68, 0.15);
  --purple-light: rgba(139, 92, 246, 0.15);
  --indigo-light: rgba(99, 102, 241, 0.15);

  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   LAYOUT STRUCTURE
   ========================================================================== */

.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR */
.app-sidebar {
  width: 270px;
  background: var(--bg-sidebar);
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: var(--transition);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-brand {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

.brand-text h2 {
  font-size: 17px;
  font-weight: 700;
  color: white;
  letter-spacing: -0.3px;
}

.brand-text span {
  font-size: 11px;
  color: var(--emerald);
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* SIDEBAR MODULE SWITCHER */
.module-badge-box {
  margin: 16px 16px 8px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.module-badge-box .badge-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #64748b;
  font-weight: 700;
}

.module-badge-box .badge-role {
  font-size: 12px;
  font-weight: 600;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 16px;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #64748b;
  font-weight: 700;
  padding: 14px 12px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: var(--transition);
  margin-bottom: 4px;
}

.nav-link:hover {
  color: #ffffff;
  background: var(--bg-sidebar-hover);
}

.nav-link.active {
  color: #ffffff;
  background: var(--primary);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.nav-link svg, .nav-link i {
  width: 18px;
  height: 18px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.security-badge {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 10px;
}

.security-badge .sec-icon {
  color: var(--emerald);
}

.security-badge .sec-text {
  font-size: 11.5px;
  color: #cbd5e1;
  line-height: 1.3;
}

.security-badge .sec-text strong {
  color: var(--emerald);
  display: block;
}

/* MAIN CONTENT */
.app-main {
  flex: 1;
  margin-left: 270px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* HEADER / TOPBAR */
.app-topbar {
  height: 70px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 1000;
  backdrop-filter: blur(12px);
  transition: var(--transition);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.page-title h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.page-title p {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* QUICK ROLE SWITCHER PILL */
.demo-switcher {
  background: var(--bg-surface-soft);
  border: 1px solid var(--border-color);
  padding: 4px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 4px;
}

.demo-switch-btn {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  color: var(--text-secondary);
  transition: var(--transition);
}

.demo-switch-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-sm);
}

.demo-switch-btn.active.hr {
  background: var(--purple);
}

/* THEME TOGGLE */
.theme-btn {
  background: var(--bg-surface-soft);
  border: 1px solid var(--border-color);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.theme-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

/* USER PROFILE PILL */
.user-profile-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-soft);
  border: 1px solid var(--border-color);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 13px;
}

.user-info {
  text-align: left;
}

.user-info .u-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.user-info .u-role {
  font-size: 11px;
  color: var(--text-muted);
}

/* APP BODY CONTENT */
.app-content {
  padding: 28px 32px 60px;
  flex: 1;
}

/* ==========================================================================
   CARDS, KPI STATS, & GRIDS
   ========================================================================== */

.grid-cols-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.grid-cols-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.grid-cols-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  margin-bottom: 24px;
}

.grid-cols-3-1 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

/* ==========================================================================
   MODAL COMPONENT SYSTEM (UNIVERSAL & MOBILE-FIRST)
   ========================================================================== */

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  box-sizing: border-box;
}

.modal-backdrop.show {
  display: flex !important;
  animation: modalFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-content,
.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.5);
  max-width: 740px;
  width: 100%;
  max-height: calc(92vh - 20px);
  display: flex;
  flex-direction: column;
  overflow: hidden !important;
  position: relative;
  box-sizing: border-box;
  animation: modalScaleUp 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-content > form,
.modal-dialog > form {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: calc(92vh - 20px);
  width: 100%;
  overflow: hidden;
  margin: 0;
}

.modal-content.modal-lg,
.modal-dialog.modal-lg {
  max-width: 860px;
}

.modal-content.modal-sm,
.modal-dialog.modal-sm {
  max-width: 480px;
}

.modal-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface-soft);
  flex-shrink: 0;
}

.modal-header h3,
.modal-header .modal-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: var(--transition);
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--border-color);
}

.modal-body {
  padding: 20px 22px;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  flex: 1;
  box-sizing: border-box;
  max-width: 100%;
}

.modal-body * {
  box-sizing: border-box;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-surface-soft);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-shrink: 0;
}

/* USER PROFILE AVATAR ENHANCEMENTS */
.avatar-img {
  object-fit: cover;
  border-radius: 50%;
}

.user-avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, #1d4ed8 100%);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.user-avatar-circle.hr {
  background: linear-gradient(135deg, var(--purple) 0%, #6d28d9 100%);
}

.user-avatar-circle.staff {
  background: linear-gradient(135deg, var(--emerald) 0%, #047857 100%);
}

.user-avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-upload-box {
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  background: var(--bg-surface-soft);
  transition: var(--transition);
  cursor: pointer;
}

.avatar-upload-box:hover {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.05);
}

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

@keyframes modalScaleUp {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.card:hover {
  box-shadow: var(--shadow-md);
}

/* RESPONSIVE GRID UTILITIES */
.grid-cols-4,
.metrics-grid-4,
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.grid-cols-3,
.metrics-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.grid-cols-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.grid-cols-1-2 {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 20px;
}

.grid-cols-2-1 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

.grid-cols-1-3 {
  display: grid;
  grid-template-columns: 1fr 3fr;
  gap: 20px;
}

.grid-cols-3-1 {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: 20px;
}

@media (max-width: 1200px) {
  .grid-cols-4,
  .metrics-grid-4,
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-cols-1-2,
  .grid-cols-2-1,
  .grid-cols-1-3,
  .grid-cols-3-1 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .grid-cols-4,
  .metrics-grid-4,
  .metrics-grid,
  .grid-cols-3,
  .metrics-grid-3,
  .grid-cols-2 {
    grid-template-columns: 1fr;
  }
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* STAT KPI CARD */
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary-gradient);
}

.stat-card.emerald::before { background: var(--emerald-gradient); }
.stat-card.amber::before { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-card.purple::before { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.stat-card.rose::before { background: linear-gradient(135deg, #ef4444, #b91c1c); }

.stat-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.stat-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.emerald { background: var(--emerald-light); color: var(--emerald); }
.stat-icon.amber { background: var(--amber-light); color: var(--amber); }
.stat-icon.purple { background: var(--purple-light); color: var(--purple); }
.stat-icon.rose { background: var(--rose-light); color: var(--rose); }

/* ==========================================================================
   BUTTONS, BADGES, AND FORMS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

.btn-emerald {
  background: var(--emerald);
  color: white;
}
.btn-emerald:hover {
  background: #059669;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.btn-purple {
  background: var(--purple);
  color: white;
}
.btn-purple:hover {
  background: #7c3aed;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.35);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-primary);
}
.btn-outline:hover {
  background: var(--bg-surface-soft);
  border-color: var(--text-muted);
}

.btn-danger {
  background: var(--rose);
  color: white;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
}

.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-emerald { background: var(--emerald-light); color: var(--emerald); }
.badge-amber { background: var(--amber-light); color: var(--amber); }
.badge-rose { background: var(--rose-light); color: var(--rose); }
.badge-purple { background: var(--purple-light); color: var(--purple); }
.badge-slate { background: var(--bg-surface-soft); color: var(--text-secondary); border: 1px solid var(--border-color); }

/* TABLES */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.table th {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface-soft);
}

.table td {
  padding: 14px 16px;
  font-size: 13.5px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

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

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

/* FORM CONTROLS */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13.5px;
  font-family: inherit;
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* MODAL */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  padding: 20px;
}

.modal-backdrop.show {
  display: flex;
}

.modal-content {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalFadeIn 0.2s ease-out;
}

.modal-content.modal-lg {
  max-width: 800px;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background: var(--bg-surface-soft);
}

/* ALERT MESSAGES */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
}

.alert-success { background: var(--emerald-light); color: var(--emerald); border: 1px solid rgba(16, 185, 129, 0.3); }
.alert-warning { background: var(--amber-light); color: #b45309; border: 1px solid rgba(245, 158, 11, 0.3); }
.alert-danger { background: var(--rose-light); color: var(--rose); border: 1px solid rgba(239, 68, 68, 0.3); }
.alert-info { background: var(--primary-light); color: var(--primary); border: 1px solid rgba(59, 130, 246, 0.3); }

/* ==========================================================================
   ATS KANBAN PIPELINE STYLES
   ========================================================================== */

.ats-board {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.ats-column {
  background: var(--bg-surface-soft);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  min-height: 500px;
  display: flex;
  flex-direction: column;
}

.ats-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.ats-col-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.candidate-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.candidate-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

/* ==========================================================================
   PAGINATION & SVG CONTAINMENT
   ========================================================================== */

nav[role="navigation"] svg,
.pagination svg,
.w-5,
.h-5 {
  width: 16px !important;
  height: 16px !important;
  max-width: 16px !important;
  max-height: 16px !important;
  display: inline-block !important;
  vertical-align: middle !important;
}

nav[role="navigation"] {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  width: 100%;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.pagination .page-item .page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  text-decoration: none;
  min-width: 32px;
  height: 32px;
}

.pagination .page-item.active .page-link {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  font-weight: 700;
}

.pagination .page-item.disabled .page-link {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ==========================================================================
   HIGH-FIDELITY PRINT & PDF EXPORT STYLES
   ========================================================================== */

@page {
  size: A4 portrait;
  margin: 12mm 12mm 15mm 12mm;
}

@media print {
  /* Complete removal of navigation, buttons, forms, modals, header bars */
  .app-sidebar,
  .app-topbar,
  .btn,
  .no-print,
  .btn-no-print,
  .demo-switcher,
  .theme-btn,
  .user-profile-btn,
  .modal-backdrop,
  .alert,
  button,
  form,
  input,
  select {
    display: none !important;
  }

  /* Reset layout structure for print */
  html, body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 11pt !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .app-wrapper,
  .app-main {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }

  .app-content {
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Cards in Print */
  .card {
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
    border-radius: 6px !important;
    padding: 16px !important;
    margin-bottom: 16px !important;
    background: #ffffff !important;
    page-break-inside: avoid !important;
  }

  /* Table styling in Print */
  .table {
    width: 100% !important;
    border-collapse: collapse !important;
  }

  .table th {
    background: #f1f5f9 !important;
    color: #0f172a !important;
    border: 1px solid #cbd5e1 !important;
    font-size: 9.5pt !important;
    padding: 8px 10px !important;
  }

  .table td {
    border: 1px solid #e2e8f0 !important;
    font-size: 9.5pt !important;
    padding: 8px 10px !important;
    color: #1e293b !important;
  }

  /* Color accuracy */
  .badge {
    border: 1px solid #94a3b8 !important;
    background: #f8fafc !important;
    color: #0f172a !important;
  }

  /* Print Letterhead specific */
  .print-header,
  #printHeaderSection {
    display: block !important;
    margin-bottom: 20px !important;
  }

  /* Force page breaks cleanly */
  .page-break {
    page-break-after: always;
  }
}

/* ==========================================================================
   UNIVERSAL SEARCHABLE SELECT COMPONENT
   ========================================================================== */

.custom-select-wrapper {
  position: relative;
  width: 100%;
  user-select: none;
}

.custom-select-wrapper.is-disabled {
  opacity: 0.6;
  pointer-events: none;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 12px;
  background-color: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-md, 8px);
  color: var(--text-primary, #0f172a);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition, all 0.2s ease);
  min-height: 40px;
  box-sizing: border-box;
}

.custom-select-trigger:hover {
  border-color: var(--primary, #3b82f6);
}

.custom-select-trigger:focus,
.custom-select-wrapper.is-open .custom-select-trigger {
  border-color: var(--primary, #3b82f6);
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.custom-select-trigger-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 8px;
}

.custom-select-trigger-text.placeholder {
  color: var(--text-muted, #94a3b8);
  font-weight: 400;
}

.custom-select-trigger-icon {
  display: inline-flex;
  align-items: center;
  color: var(--text-secondary, #64748b);
  transition: transform 0.2s ease;
}

.custom-select-wrapper.is-open .custom-select-trigger-icon {
  transform: rotate(180deg);
  color: var(--primary, #3b82f6);
}

.custom-select-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background-color: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #cbd5e1);
  border-radius: var(--radius-md, 8px);
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.15);
  z-index: 3500;
  display: none;
  padding: 8px;
  min-width: 240px;
  animation: customSelectFadeIn 0.15s ease;
}

[data-theme="dark"] .custom-select-dropdown {
  background-color: #1e293b;
  border-color: #334155;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}

@keyframes customSelectFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.custom-select-wrapper.is-open {
  z-index: 3500;
  position: relative;
}

.custom-select-wrapper.is-open .custom-select-dropdown {
  display: block;
  z-index: 3500;
}

.custom-select-search-box {
  position: relative;
  margin-bottom: 6px;
}

.custom-select-search-box svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-muted, #94a3b8);
  pointer-events: none;
}

.custom-select-search-input {
  width: 100%;
  padding: 7px 10px 7px 32px;
  background: var(--bg-surface-soft, #f8fafc);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--text-primary, #0f172a);
  outline: none;
  box-sizing: border-box;
  font-family: inherit;
  transition: border-color 0.15s ease;
}

[data-theme="dark"] .custom-select-search-input {
  background: #0f172a;
  border-color: #334155;
  color: #f8fafc;
}

.custom-select-search-input:focus {
  border-color: var(--primary, #3b82f6);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.custom-select-options {
  max-height: 240px;
  overflow-y: auto;
  padding: 0;
  margin: 0;
  list-style: none;
}

.custom-select-options::-webkit-scrollbar {
  width: 6px;
}
.custom-select-options::-webkit-scrollbar-thumb {
  background: var(--border-color, #cbd5e1);
  border-radius: 3px;
}

.custom-select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-primary, #0f172a);
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.1s ease;
}

.custom-select-option:hover,
.custom-select-option.is-highlighted {
  background-color: var(--primary-light, #eff6ff);
  color: var(--primary, #3b82f6);
}

[data-theme="dark"] .custom-select-option:hover,
[data-theme="dark"] .custom-select-option.is-highlighted {
  background-color: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

.custom-select-option.is-selected {
  background-color: var(--primary, #3b82f6);
  color: #ffffff !important;
  font-weight: 600;
}

.custom-select-option.is-selected .match-highlight {
  color: #ffffff !important;
  text-decoration: underline;
}

.custom-select-empty {
  padding: 12px 10px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted, #94a3b8);
}

/* ==========================================================================
   MOBILE RESPONSIVENESS & TOUCH OPTIMIZATIONS (ARFADIA ENTERPRISE)
   ========================================================================== */

/* Mobile Hamburger Button */
.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-soft);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

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

/* Backdrop Overlay for Mobile Drawer */
.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.sidebar-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

/* Tablets & Small Desktops (<= 1024px) */
@media (max-width: 1024px) {
  .mobile-menu-btn {
    display: inline-flex;
  }

  .app-sidebar {
    transform: translateX(-100%);
    box-shadow: none;
    z-index: 1200;
  }

  .app-sidebar.show {
    transform: translateX(0);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
  }

  .app-main {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100vw;
  }

  .app-topbar {
    padding: 0 16px;
  }

  .app-content {
    padding: 20px 16px 60px;
  }

  .grid-cols-4,
  .metrics-grid-4,
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* SIDEBAR LOGOUT COMPONENT */
.sidebar-logout-box {
  padding: 12px 16px 0;
  margin-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logout-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.sidebar-logout-btn:hover {
  background: var(--rose);
  color: white;
  border-color: var(--rose);
}

/* Mobile Devices (<= 768px) */
@media (max-width: 768px) {
  /* CLEAN SINGLE-LINE TOPBAR ON MOBILE */
  .app-topbar {
    height: 56px !important;
    min-height: 56px !important;
    padding: 0 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 1000 !important;
    background: var(--bg-surface) !important;
  }

  .topbar-left {
    gap: 8px !important;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
  }

  .mobile-menu-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--bg-surface-soft);
    border: 1px solid var(--border-color);
  }

  .page-title {
    min-width: 0;
    flex: 1;
    overflow: hidden;
  }

  .page-title h1 {
    font-size: 14.5px !important;
    font-weight: 700 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.2;
    margin: 0;
    max-width: 100% !important;
  }

  .page-title p {
    display: none !important;
  }

  .topbar-right {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex-shrink: 0;
  }

  .d-none-mobile {
    display: none !important;
  }

  /* Compact Circular AI Copilot Button on Mobile */
  .copilot-topbar-btn {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    min-height: 34px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.35) !important;
  }

  .copilot-topbar-btn span {
    display: none !important;
  }

  /* Compact Theme Toggle Button on Mobile */
  .theme-btn {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    min-height: 34px !important;
    border-radius: 50% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Compact Profile Avatar on Mobile */
  .user-profile-btn {
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .user-profile-btn .user-avatar {
    width: 34px !important;
    height: 34px !important;
    border-width: 2px !important;
  }

  .user-info {
    display: none !important;
  }

  .topbar-logout-form {
    display: none !important;
  }

  /* App Content on Mobile */
  .app-content {
    padding: 12px 10px 80px !important;
  }

  /* Cards on Mobile */
  .card {
    padding: 14px !important;
    border-radius: 12px !important;
    margin-bottom: 14px !important;
  }

  .card-header {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    padding-bottom: 12px !important;
    margin-bottom: 14px !important;
  }

  .card-title {
    font-size: 14px !important;
    margin-bottom: 0 !important;
  }

  /* Stack all Multi-Column Layouts on Mobile */
  .staff-dashboard [style*="grid-template-columns: 1.5fr 1fr"],
  .staff-attendance-advanced [style*="grid-template-columns: 1.2fr 1fr"],
  .attendance-grid-layout,
  .dashboard-2col-grid,
  .hero-welcome-grid,
  .staff-profile-page [style*="grid-template-columns"],
  .staff-kpi-page [style*="grid-template-columns: 1fr 1fr"],
  .doc-grid-responsive,
  .doc-cards-grid,
  [style*="grid-template-columns: 1.5fr 1fr"],
  [style*="grid-template-columns: 1.2fr 1fr"],
  [style*="grid-template-columns: 2fr 1fr"],
  [style*="grid-template-columns: 1fr 1.5fr"],
  [style*="grid-template-columns: 1fr 1fr"],
  .grid-cols-4,
  .metrics-grid-4,
  .grid-cols-3,
  .metrics-grid-3,
  .grid-cols-3-1,
  .grid-cols-1-3,
  .grid-cols-2-1,
  .grid-cols-1-2,
  .grid-cols-2 {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  .attendance-col {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Stat cards on mobile */
  .metrics-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .stat-card {
    padding: 14px !important;
    border-radius: 10px !important;
  }

  .stat-value {
    font-size: 19px !important;
  }

  .stat-icon {
    width: 36px !important;
    height: 36px !important;
  }

  /* Attendance, Camera & Geofencing on Mobile */
  .attendance-hero-card {
    padding: 14px 12px !important;
    border-radius: 14px !important;
    margin-bottom: 16px !important;
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible !important;
    position: relative !important;
  }

  .camera-container {
    width: 100% !important;
    max-width: 100% !important;
    height: 220px !important;
    border-radius: 12px !important;
    margin: 0 0 12px 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    -webkit-mask-image: -webkit-radial-gradient(white, black) !important;
    isolation: isolate !important;
  }

  .camera-video,
  .camera-canvas {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    object-fit: cover !important;
    display: block !important;
  }

  .face-reticle {
    width: 130px !important;
    height: 165px !important;
  }

  #mapAttendance {
    height: 190px !important;
    border-radius: 10px !important;
    width: 100% !important;
    max-width: 100% !important;
    position: relative !important;
    z-index: 1 !important;
    isolation: isolate !important;
  }

  .scanner-tabs {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 6px !important;
    margin-bottom: 12px !important;
    padding: 4px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .scanner-tab-btn {
    font-size: 11.5px !important;
    padding: 8px 6px !important;
    width: 100% !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
  }

  .camera-toolbar {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 4px !important;
    flex-wrap: nowrap !important;
    margin-bottom: 8px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .camera-toolbar-btns {
    display: flex !important;
    gap: 4px !important;
    align-items: center !important;
    flex-shrink: 0 !important;
  }

  .camera-btn-compact {
    font-size: 11px !important;
    padding: 3px 7px !important;
    white-space: nowrap !important;
  }

  .camera-live-badge {
    font-size: 10.5px !important;
    padding: 3px 6px !important;
    white-space: nowrap !important;
  }

  .camera-action-group {
    display: flex !important;
    gap: 8px !important;
    margin-bottom: 12px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Leaflet Popups on Mobile */
  .leaflet-popup-content-wrapper {
    border-radius: 8px !important;
    padding: 0 !important;
    box-shadow: 0 4px 14px rgba(0,0,0,0.3) !important;
  }

  .leaflet-popup-content {
    margin: 6px 8px !important;
    font-size: 11px !important;
    line-height: 1.3 !important;
  }

  /* Horizontal Touch Scrolling for Data Tables */
  .table-responsive {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 12px;
  }

  .table th, .table td {
    padding: 9px 10px !important;
    font-size: 12px !important;
    white-space: nowrap;
  }

  /* Form Elements for Touch Devices */
  .form-control {
    font-size: 14px !important;
    min-height: 40px;
    padding: 8px 10px;
    border-radius: 8px;
  }

  .form-label {
    font-size: 12px !important;
    margin-bottom: 4px;
  }

  .btn {
    min-height: 40px;
    font-size: 13px !important;
    padding: 8px 14px;
    border-radius: 8px;
  }

  .btn-sm {
    min-height: 32px !important;
    font-size: 11.5px !important;
    padding: 4px 8px !important;
  }

  /* Modals on Mobile Viewport */
  .modal-backdrop {
    padding: 10px !important;
  }

  .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    margin: auto !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
    border-radius: 14px !important;
  }

  .modal-header {
    padding: 14px 16px !important;
  }

  .modal-body {
    padding: 14px 16px !important;
  }

  .modal-footer {
    padding: 12px 16px !important;
    flex-wrap: wrap;
    gap: 8px;
  }
}

/* Small SmartPhones (<= 480px) */
@media (max-width: 480px) {
  .page-title h1 {
    font-size: 13.5px !important;
    max-width: 100% !important;
  }

  .topbar-right {
    gap: 4px !important;
  }

  .copilot-topbar-btn,
  .theme-btn,
  .user-profile-btn .user-avatar {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
  }

  .mobile-menu-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
  }

  .attendance-hero-card {
    padding: 14px 10px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .camera-container {
    height: 240px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .face-reticle {
    width: 135px !important;
    height: 170px !important;
  }

  #mapAttendance {
    height: 190px !important;
    width: 100% !important;
    max-width: 100% !important;
    position: relative !important;
    z-index: 1 !important;
    isolation: isolate !important;
  }

  .stat-card {
    padding: 12px !important;
  }

  .stat-value {
    font-size: 17px !important;
  }

  .stat-icon {
    width: 32px !important;
    height: 32px !important;
  }

  /* PWA Smart Push Notification Mobile Polish */
  .pwa-notif-card {
    padding: 12px !important;
    border-radius: 12px !important;
    margin-bottom: 14px !important;
  }

  .pwa-notif-layout {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  .pwa-notif-info {
    min-width: 0 !important;
    gap: 10px !important;
  }

  .pwa-bell-icon {
    width: 38px !important;
    height: 38px !important;
    border-radius: 10px !important;
    flex-shrink: 0 !important;
  }

  .pwa-bell-icon i, .pwa-bell-icon svg {
    width: 18px !important;
    height: 18px !important;
  }

  .pwa-notif-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    width: 100% !important;
    gap: 8px !important;
  }

  .pwa-notif-actions .btn {
    width: 100% !important;
    padding: 8px 6px !important;
    font-size: 11.5px !important;
    justify-content: center !important;
  }

  .pwa-filter-badge {
    display: none !important;
  }
}

/* LEAVE PAGE DEDICATED RESPONSIVE RULES */
@media (max-width: 768px) {
  .leave-metrics-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px !important;
    margin-bottom: 14px !important;
  }

  .leave-metrics-grid .stat-card {
    padding: 10px 8px !important;
    min-height: 68px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    border-radius: 10px !important;
  }

  .leave-metrics-grid .stat-label {
    font-size: 10px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.3px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    margin-bottom: 2px !important;
  }

  .leave-metrics-grid .stat-value {
    font-size: 15px !important;
    font-weight: 800 !important;
    line-height: 1.1 !important;
  }

  .leave-metrics-grid .stat-sub {
    display: none !important;
  }

  .leave-metrics-grid .stat-icon {
    display: none !important;
  }

  /* PWA Card on Tablet/Mobile */
  .pwa-notif-actions {
    display: flex;
    gap: 8px;
    width: 100%;
  }

  .pwa-notif-actions .btn {
    flex: 1;
    justify-content: center;
  }
}

/* ==========================================================================
   AI COPILOT ARFADIA - EXECUTIVE MARKDOWN & TYPOGRAPHY SYSTEM
   ========================================================================== */
.copilot-modal-dialog {
  max-width: 820px !important;
  width: 95vw !important;
  max-height: 92vh !important;
  display: flex !important;
  flex-direction: column !important;
  border-radius: 14px !important;
  box-shadow: 0 20px 45px -10px rgba(15, 23, 42, 0.28), 0 0 0 1px rgba(99, 102, 241, 0.15) !important;
}

.copilot-chat-output {
  min-height: 180px;
  max-height: 440px;
  overflow-y: auto;
  background: var(--bg-surface-soft);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px 18px;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-primary);
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.3) transparent;
}

.copilot-chat-output::-webkit-scrollbar {
  width: 6px;
}
.copilot-chat-output::-webkit-scrollbar-track {
  background: transparent;
}
.copilot-chat-output::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.25);
  border-radius: 4px;
}
.copilot-chat-output::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.45);
}

/* Welcome Card */
.copilot-welcome-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.06) 0%, rgba(168, 85, 247, 0.06) 100%);
  border: 1px solid rgba(99, 102, 241, 0.18);
  border-radius: 10px;
  padding: 14px 16px;
}

.copilot-welcome-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(99, 102, 241, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.copilot-welcome-title {
  font-weight: 800;
  font-size: 14px;
  color: #312e81;
  margin-bottom: 4px;
}
[data-theme="dark"] .copilot-welcome-title {
  color: #c7d2fe;
}

.copilot-welcome-desc {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-secondary);
}

/* Loading State */
.copilot-loading-state {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 24px 16px;
  justify-content: center;
}

.copilot-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(99, 102, 241, 0.2);
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: copilot-spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

/* Response Header & Meta Toolbar */
.copilot-response-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
  gap: 8px;
  flex-wrap: wrap;
}

.copilot-header-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.copilot-badge-model {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(168, 85, 247, 0.1) 100%);
  color: #6366f1;
  padding: 3px 9px;
  border-radius: 12px;
  border: 1px solid rgba(99, 102, 241, 0.25);
}

.copilot-badge-attachment {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.08);
  color: #059669;
  padding: 3px 8px;
  border-radius: 12px;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.copilot-copy-response-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
}

.copilot-copy-response-btn:hover {
  background: var(--bg-surface-soft);
  color: var(--text-primary);
  border-color: #cbd5e1;
}

/* Markdown Document Body & Typography Hierarchy */
.copilot-markdown-body {
  color: var(--text-primary);
  font-size: 13.5px;
  line-height: 1.65;
}

.copilot-doc-title {
  font-size: 15px;
  font-weight: 800;
  color: #1e1b4b;
  text-align: center;
  letter-spacing: 0.4px;
  margin: 6px 0 4px 0;
  padding: 2px 0;
  text-transform: uppercase;
}
[data-theme="dark"] .copilot-doc-title {
  color: #e0e7ff;
}

.copilot-doc-meta {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.copilot-heading {
  margin: 16px 0 8px 0;
  line-height: 1.35;
  font-weight: 800;
}

.copilot-h1 {
  font-size: 16px;
  color: #312e81;
  padding-bottom: 6px;
  border-bottom: 1.5px solid rgba(99, 102, 241, 0.2);
}
[data-theme="dark"] .copilot-h1 {
  color: #c7d2fe;
  border-bottom-color: rgba(99, 102, 241, 0.35);
}

.copilot-h2 {
  font-size: 14.5px;
  color: #4338ca;
  margin-top: 14px;
}
[data-theme="dark"] .copilot-h2 {
  color: #a5b4fc;
}

.copilot-h3 {
  font-size: 13.5px;
  font-weight: 750;
  color: #1e293b;
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
[data-theme="dark"] .copilot-h3 {
  color: #f1f5f9;
}

.copilot-h3::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6366f1;
  flex-shrink: 0;
}

.copilot-h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
}

.copilot-bold {
  font-weight: 700;
  color: #0f172a;
}
[data-theme="dark"] .copilot-bold {
  color: #ffffff;
}

.copilot-italic {
  font-style: italic;
  color: var(--text-secondary);
}

.copilot-p {
  margin: 0 0 8px 0;
  line-height: 1.65;
}

.copilot-spacer {
  height: 8px;
}

.copilot-divider {
  border: 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.3) 0%, rgba(203, 213, 225, 0.8) 50%, transparent 100%);
  margin: 14px 0;
}
[data-theme="dark"] .copilot-divider {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.4) 0%, rgba(71, 85, 105, 0.8) 50%, transparent 100%);
}

.copilot-ul,
.copilot-ol {
  margin: 6px 0 10px 18px;
  padding: 0;
}

.copilot-li {
  margin: 4px 0;
  line-height: 1.6;
}

.copilot-ul .copilot-li::marker {
  color: #6366f1;
}
.copilot-ol .copilot-li::marker {
  font-weight: 700;
  color: #4f46e5;
}

.copilot-quote {
  border-left: 3.5px solid #6366f1;
  background: rgba(99, 102, 241, 0.05);
  padding: 8px 14px;
  margin: 10px 0;
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  color: #3730a3;
  line-height: 1.6;
}
[data-theme="dark"] .copilot-quote {
  background: rgba(99, 102, 241, 0.12);
  color: #c7d2fe;
}

/* Masked PII Badges */
.copilot-masked-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  font-family: monospace;
}
[data-theme="dark"] .copilot-masked-badge {
  background: rgba(245, 158, 11, 0.2);
  color: #fde68a;
}

.copilot-masked-text {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-secondary);
  border-radius: 3px;
  padding: 0 4px;
  font-family: monospace;
  font-weight: 600;
}

/* Inline & Block Code */
.copilot-inline-code {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.2);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: #4f46e5;
}
[data-theme="dark"] .copilot-inline-code {
  color: #a5b4fc;
}

.copilot-code-wrapper {
  margin: 10px 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #1e293b;
  background: #0f172a;
}

.copilot-code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #1e293b;
  padding: 4px 10px;
  font-size: 11px;
  color: #94a3b8;
}

.copilot-code-copy {
  background: transparent;
  border: none;
  color: #cbd5e1;
  font-size: 10.5px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.copilot-code-copy:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.copilot-code {
  margin: 0;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  color: #e2e8f0;
  overflow-x: auto;
}

/* Tables */
.copilot-table-wrapper {
  overflow-x: auto;
  margin: 12px 0;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
}

.copilot-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  text-align: left;
}

.copilot-table th {
  background: var(--bg-surface-soft);
  color: var(--text-primary);
  font-weight: 700;
  padding: 8px 12px;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

.copilot-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

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

.copilot-table tbody tr:hover {
  background: rgba(99, 102, 241, 0.03);
}

