/**
 * ==============================================================================
 * PTN Payroll System V4.0 - Modern Enterprise UI Stylesheet
 * ==============================================================================
 */
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #059669;
  --success-light: #ecfdf5;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --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.04);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f1f5f9;
  color: var(--slate-800);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* AUTH / LOGIN SCREEN */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #1e3a8a 0%, #0f172a 100%);
}
.login-card {
  background: #ffffff;
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-xl);
  text-align: center;
}
.login-logo {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 16px;
  box-shadow: 0 8px 20px rgba(37,99,235,0.35);
}
.login-title { font-size: 19px; font-weight: 700; color: var(--slate-900); margin-bottom: 4px; }
.login-sub { font-size: 12px; color: var(--slate-500); margin-bottom: 24px; }
.login-field { text-align: left; margin-bottom: 16px; }
.login-field label { display: block; font-size: 12px; font-weight: 600; color: var(--slate-700); margin-bottom: 6px; }
.login-field input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--slate-300);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: all 0.2s;
}
.login-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.login-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.login-btn:hover { background: linear-gradient(135deg, #1d4ed8, #1e40af); transform: translateY(-1px); }

/* MAIN APP SHELL */
.app-shell { display: none; flex-direction: column; min-height: 100vh; }
.app-shell.active { display: flex; }

/* HEADER */
.top-header {
  background: #ffffff;
  border-bottom: 1px solid var(--slate-200);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}
.brand-group { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.brand-info h1 { font-size: 15px; font-weight: 700; color: var(--slate-900); line-height: 1.2; }
.brand-info p { font-size: 11px; color: var(--slate-500); }

.header-actions { display: flex; align-items: center; gap: 10px; }
.status-badge {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid #a7f3d0;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.user-badge {
  background: var(--slate-100);
  color: var(--slate-700);
  border: 1px solid var(--slate-200);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* NAVIGATION TABS */
.nav-container {
  background: #ffffff;
  border-bottom: 1px solid var(--slate-200);
  padding: 4px 20px 0 20px;
  overflow-x: auto;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  scrollbar-width: thin;
  scrollbar-color: var(--slate-300) transparent;
  -webkit-overflow-scrolling: touch;
}
.nav-container::-webkit-scrollbar {
  height: 4px;
}
.nav-container::-webkit-scrollbar-thumb {
  background: var(--slate-300);
  border-radius: 4px;
}
.nav-tabs { 
  display: flex; 
  gap: 6px; 
  align-items: flex-end;
}
.nav-tab-btn {
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 8px 8px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-600);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.15s ease-in-out;
  flex-shrink: 0;
}
.nav-tab-btn:hover { 
  color: var(--primary); 
  background: var(--slate-100); 
}
.nav-tab-btn.active { 
  color: var(--primary); 
  border-bottom-color: var(--primary); 
  background: var(--primary-light); 
  font-weight: 700;
}
.nav-tab-btn i {
  font-size: 13.5px;
  transition: transform 0.15s ease;
}
.nav-tab-btn:hover i {
  transform: translateY(-1px);
}

/* MAIN CONTENT */
.main-container {
  flex: 1;
  padding: 20px 24px;
  max-width: 1480px;
  width: 100%;
  margin: 0 auto;
}

/* PERIOD CONTROL BAR */
.period-bar {
  background: #ffffff;
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 12px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}
.period-badge-group { display: flex; align-items: center; gap: 8px; }
.period-pill {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid #bfdbfe;
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
}
.period-select-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.period-select {
  padding: 6px 10px;
  border: 1.5px solid var(--slate-300);
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  outline: none;
}
.period-select:focus { border-color: var(--primary); }

.work-days-box {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--slate-50);
  border: 1.5px solid var(--slate-300);
  padding: 4px 8px;
  border-radius: var(--radius-md);
}

/* TAB SECTIONS */
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.2s ease-in-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* CARDS */
.card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: #ffffff;
}
.card-title { font-size: 15px; font-weight: 700; color: var(--slate-900); }
.card-sub { font-size: 11.5px; color: var(--slate-500); margin-top: 1px; }

/* STATS GRID */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}
.stat-card.blue { border-left: 4px solid var(--primary); }
.stat-card.green { border-left: 4px solid var(--success); }
.stat-card.red { border-left: 4px solid var(--danger); }
.stat-card.purple { border-left: 4px solid #8b5cf6; }
.stat-label { font-size: 11px; font-weight: 700; color: var(--slate-500); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 22px; font-weight: 700; font-family: monospace; color: var(--slate-900); margin-top: 4px; }
.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-icon.purple { background: #f5f3ff; color: #8b5cf6; }

/* TABLES (STICKY FROZEN HEADERS & RESPONSIVE SCROLL) */
.table-wrapper {
  max-height: calc(100vh - 250px);
  min-height: 300px;
  overflow: auto;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--slate-200);
  background: #ffffff;
  position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}
table.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  white-space: nowrap;
  font-size: 12px;
}
table.data-table thead {
  position: sticky;
  top: 0;
  z-index: 20;
}
th {
  color: #0f172a;
}
table.data-table thead th {
  position: sticky;
  top: 0;
  background: #f1f5f9;
  color: #0f172a;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 11px 12px;
  border-bottom: 2.5px solid #cbd5e1;
  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.07);
  z-index: 20;
}

/* Custom sleek scrollbar for table container */
.table-wrapper::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.table-wrapper::-webkit-scrollbar-track {
  background: #f8fafc;
  border-radius: 4px;
}
.table-wrapper::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.table-wrapper::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
table.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--slate-100);
  color: var(--slate-800);
}
table.data-table tr:hover td { background: #f8fafc; }

/* INDIVIDUAL ATTENDANCE TIMESHEET STYLES */
#attSumSingleContainer {
  color: #0f172a;
}
#attSumSingleContainer table {
  color: #0f172a;
}
#attSumSingleContainer th {
  color: #0f172a !important;
  background-color: #f1f5f9 !important;
}
#attSumSingleContainer td {
  color: #0f172a;
}

/* TABLE CELL HELPERS */
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-mono { font-family: monospace; }
.font-bold { font-weight: 700; }
.text-blue { color: var(--primary); }
.text-green { color: var(--success); }
.text-red { color: var(--danger); }
.text-yellow { color: var(--warning); }
.text-muted { color: var(--slate-400); }
.bg-blue-light { background: var(--primary-light) !important; }
.bg-green-light { background: var(--success-light) !important; }
.bg-red-light { background: var(--danger-light) !important; }

/* BUTTONS */
.btn {
  padding: 7px 14px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
  font-family: inherit;
}
.btn-sm { padding: 4px 9px; font-size: 11px; }
.btn-primary { background: var(--primary); color: #ffffff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #ffffff; }
.btn-success:hover { background: #047857; }
.btn-danger { background: var(--danger); color: #ffffff; }
.btn-danger:hover { background: #b91c1c; }
.btn-yellow { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.btn-yellow:hover { background: #fde68a; }
.btn-slate { background: var(--slate-100); color: var(--slate-700); border: 1px solid var(--slate-300); }
.btn-slate:hover { background: var(--slate-200); }
.btn-icon {
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-icon.edit { background: var(--primary-light); color: var(--primary); }
.btn-icon.edit:hover { background: #dbeafe; }
.btn-icon.del { background: var(--danger-light); color: var(--danger); }
.btn-icon.del:hover { background: #fee2e2; }

/* TOOLBAR */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search-box {
  padding: 7px 12px;
  border: 1.5px solid var(--slate-300);
  border-radius: var(--radius-md);
  font-size: 12px;
  outline: none;
  min-width: 200px;
}
.search-box:focus { border-color: var(--primary); }

/* MODALS */
.modal-overlay, .modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.active, .modal.active { display: flex; }
.modal-card, .modal-content {
  background: #ffffff;
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 94vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  animation: modalPop 0.2s ease-out;
}
.modal-card.wide {
  max-width: 920px;
  width: 95%;
}

/* TOP-LEVEL PHOTO PREVIEW LIGHTBOX (ALWAYS ON TOP OF OTHER MODALS) */
#modalAttendancePhotoPreview {
  z-index: 1200 !important;
  background: rgba(15, 23, 42, 0.75) !important;
  backdrop-filter: blur(4px) !important;
}
#modalAttendancePhotoPreview .modal-card {
  z-index: 1201 !important;
  box-shadow: 0 25px 60px -10px rgba(0, 0, 0, 0.7) !important;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.modal-body {
  padding: 18px 24px;
  overflow-y: auto;
  flex: 1;
  max-height: calc(94vh - 130px);
}
.modal-body::-webkit-scrollbar {
  width: 6px;
}
.modal-body::-webkit-scrollbar-track {
  background: #f1f5f9;
}
.modal-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
@keyframes modalPop { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.modal-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
}
.modal-header h3 { font-size: 15px; font-weight: 700; color: var(--slate-900); }
.modal-close-btn {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--slate-400);
  cursor: pointer;
  padding: 4px;
}
.modal-close-btn:hover { color: var(--slate-700); }

.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--slate-200);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #f8fafc;
}

/* FORM FIELDS */
.form-grid { display: grid; gap: 14px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.form-row-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 8px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 11.5px; font-weight: 600; color: var(--slate-700); }
.form-group input, .form-group select {
  padding: 8px 12px;
  border: 1.5px solid var(--slate-300);
  border-radius: var(--radius-md);
  font-size: 12px;
  font-family: inherit;
  outline: none;
}
.form-group input:focus, .form-group select:focus { border-color: var(--primary); }
.form-group input[readonly] { background: var(--slate-100); color: var(--slate-600); }

/* TOAST NOTIFICATIONS */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: #0f172a;
  color: #ffffff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideToast 0.25s ease-out;
}
.toast.success { background: #065f46; border-left: 4px solid #10b981; }
.toast.error { background: #881337; border-left: 4px solid #f43f5e; }
@keyframes slideToast { from { transform: translateX(50px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* FOOTER */
footer {
  background: #ffffff;
  border-top: 1px solid var(--slate-200);
  padding: 14px 24px;
  text-align: center;
  font-size: 11.5px;
  color: var(--slate-500);
  margin-top: auto;
}

/* PRINT STYLES (PAYSLIP, EMPLOYEE HISTORY REPORT & YEARLY SUMMARY) */
@page {
  size: A4 portrait;
  margin: 10mm;
}

@page landscapePage {
  size: A4 landscape;
  margin: 8mm 10mm;
}

@media print {
  /* 1. Global Reset & Print Defaults */
  html, body {
    background: #ffffff !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* 2. Universal Website Chrome & Controls - ALWAYS HIDDEN WHEN PRINTING ANY DOCUMENT */
  header,
  nav,
  .top-header,
  .nav-container,
  .nav-tabs,
  .period-bar,
  footer,
  #toastContainer,
  #loginScreen,
  .modal-header,
  .modal-footer,
  .modal-close-btn,
  .cert-controls-bar,
  .card-header,
  .no-print,
  .ai-chat-btn,
  .ai-chat-drawer,
  #aiChatToggleBtn,
  #aiChatDrawer,
  .search-box,
  .btn,
  button,
  input[type="button"],
  input[type="submit"] {
    display: none !important;
  }

  .card {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #ffffff !important;
  }

  /* ========================================================================
     GROUP A: MODAL PRINT DOCUMENTS (Payslip, Salary Cert, 50 Twi, Sign-off)
     When printing any modal, the ENTIRE website / background is HIDDEN!
     ======================================================================== */
  body.printing-payslip #appShell,
  body.printing-salary-cert #appShell,
  body.printing-50twi #appShell,
  body.printing-payroll-summary #appShell,
  body.printing-attendance-summary #appShell,
  body.printing-attendance-individual #appShell,
  body.printing-payslip .main-container,
  body.printing-salary-cert .main-container,
  body.printing-50twi .main-container,
  body.printing-payroll-summary .main-container,
  body.printing-attendance-summary .main-container,
  body.printing-attendance-individual .main-container,
  body.printing-payslip .tab-content,
  body.printing-salary-cert .tab-content,
  body.printing-50twi .tab-content,
  body.printing-payroll-summary .tab-content,
  body.printing-attendance-summary .tab-content,
  body.printing-attendance-individual .tab-content {
    display: none !important;
  }

  /* ------------------------------------------------------------------------
     A1. PAYSLIP MODAL PRINT (A4 PORTRAIT)
     ------------------------------------------------------------------------ */
  body.printing-payslip > *:not(#payslipModal) {
    display: none !important;
  }
  body.printing-payslip .modal-overlay:not(#payslipModal) {
    display: none !important;
  }
  body.printing-payslip #payslipModal {
    display: block !important;
    position: static !important;
    width: 100% !important;
    background: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
  }
  body.printing-payslip #payslipModal .modal-card {
    display: block !important;
    position: static !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: #ffffff !important;
  }
  body.printing-payslip #payslipModal .modal-card > *:not(.modal-body) {
    display: none !important;
  }
  body.printing-payslip #payslipModal .modal-body {
    display: block !important;
    background: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    max-height: none !important;
  }
  body.printing-payslip #payslipContentArea {
    display: block !important;
    width: 100% !important;
    max-width: 760px !important;
    margin: 0 auto !important;
    padding: 0 !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
  body.printing-payslip #payslipContentArea * {
    visibility: visible !important;
  }

  /* ------------------------------------------------------------------------
     A2. SALARY & EMPLOYMENT CERTIFICATE MODAL PRINT (A4 PORTRAIT)
     ------------------------------------------------------------------------ */
  body.printing-salary-cert > *:not(#salaryCertModal) {
    display: none !important;
  }
  body.printing-salary-cert .modal-overlay:not(#salaryCertModal) {
    display: none !important;
  }
  body.printing-salary-cert #salaryCertModal {
    display: block !important;
    position: static !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    background: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    border: none !important;
    box-shadow: none !important;
  }
  body.printing-salary-cert #salaryCertModal .modal-card {
    display: block !important;
    position: static !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: #ffffff !important;
    border-radius: 0 !important;
  }
  body.printing-salary-cert #salaryCertModal .modal-header,
  body.printing-salary-cert #salaryCertModal .cert-controls-bar,
  body.printing-salary-cert #salaryCertModal .modal-footer,
  body.printing-salary-cert #salaryCertModal .no-print,
  body.printing-salary-cert #salaryCertModal .modal-card > *:not(.modal-body) {
    display: none !important;
  }
  body.printing-salary-cert #salaryCertModal .modal-body {
    display: block !important;
    background: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    max-height: none !important;
    border: none !important;
    box-shadow: none !important;
  }
  body.printing-salary-cert #salaryCertModal .modal-body > *:not(#salaryCertPaper) {
    display: none !important;
  }
  body.printing-salary-cert #salaryCertPaper {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: auto !important;
    margin: 0 !important;
    padding: 2mm 5mm !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    background: #ffffff !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    font-size: 14px !important;
    line-height: 1.9 !important;
  }
  body.printing-salary-cert #salaryCertPaper * {
    visibility: visible !important;
  }
  body.printing-salary-cert .salary-cert-paper [contenteditable="true"] {
    outline: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    border: none !important;
  }

  /* ------------------------------------------------------------------------
     A3. 50 TWI WITHHOLDING TAX CERTIFICATE MODAL PRINT (A4 PORTRAIT)
     ------------------------------------------------------------------------ */
  body.printing-50twi > *:not(#twi50Modal) {
    display: none !important;
  }
  body.printing-50twi .modal-overlay:not(#twi50Modal) {
    display: none !important;
  }
  body.printing-50twi #twi50Modal {
    display: block !important;
    position: static !important;
    width: 100% !important;
    background: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    border: none !important;
    box-shadow: none !important;
  }
  body.printing-50twi #twi50Modal .modal-card {
    display: block !important;
    position: static !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: #ffffff !important;
    border-radius: 0 !important;
  }
  body.printing-50twi #twi50Modal .modal-card > *:not(.modal-body) {
    display: none !important;
  }
  body.printing-50twi #twi50Modal .modal-body {
    display: block !important;
    background: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    max-height: none !important;
    border: none !important;
    box-shadow: none !important;
  }
  body.printing-50twi #twi50Modal .modal-body > *:not(#twi50PrintArea) {
    display: none !important;
  }
  body.printing-50twi #twi50PrintArea {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 10px 14px !important;
    border: 1.5px solid #0f172a !important;
    box-shadow: none !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
  body.printing-50twi #twi50PrintArea * {
    visibility: visible !important;
  }

  /* ------------------------------------------------------------------------
     A4. MONTHLY PAYROLL SUMMARY SIGN-OFF SHEET (A4 LANDSCAPE MULTI-PAGE)
     ------------------------------------------------------------------------ */
  body.printing-payroll-summary {
    page: landscapePage;
  }
  body.printing-payroll-summary > *:not(#payrollSummaryPrintContainer) {
    display: none !important;
  }
  body.printing-payroll-summary #payrollSummaryPrintContainer {
    display: block !important;
    position: static !important;
    width: 100% !important;
    background: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
  }
  body.printing-payroll-summary #payrollSummaryPrintContainer * {
    visibility: visible !important;
  }
  body.printing-payroll-summary .payroll-summary-print-wrapper {
    width: 100% !important;
    background: #ffffff !important;
    overflow: visible !important;
  }
  body.printing-payroll-summary .signoff-table-wrapper {
    overflow: visible !important;
    overflow-x: visible !important;
    overflow-y: visible !important;
    height: auto !important;
    max-height: none !important;
    margin-bottom: 14px !important;
  }
  body.printing-payroll-summary #signoffTable,
  body.printing-payroll-summary table {
    width: 100% !important;
    border-collapse: collapse !important;
    font-size: 10px !important;
    page-break-inside: auto !important;
    break-inside: auto !important;
  }
  body.printing-payroll-summary thead {
    display: table-header-group !important;
  }
  body.printing-payroll-summary thead tr {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
  body.printing-payroll-summary thead th {
    background: #f1f5f9 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    border-top: 1.5px solid #0f172a !important;
    border-bottom: 1.5px solid #0f172a !important;
    padding: 5px 3px !important;
  }
  body.printing-payroll-summary tbody tr {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
  body.printing-payroll-summary tbody td {
    padding: 4px 3px !important;
  }
  body.printing-payroll-summary tfoot {
    display: table-row-group !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
  body.printing-payroll-summary tfoot tr {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    background: #f1f5f9 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    border-top: 2px solid #0f172a !important;
    border-bottom: 2px solid #0f172a !important;
  }
  body.printing-payroll-summary tfoot td {
    padding: 6px 3px !important;
  }
  body.printing-payroll-summary #signoffSignatureSection,
  body.printing-payroll-summary .signoff-signatures {
    display: grid !important;
    grid-template-columns: 1fr 1fr 1fr !important;
    gap: 20px !important;
    text-align: center !important;
    margin-top: 24px !important;
    font-size: 11px !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
  body.printing-payroll-summary #signoffSignatureSection > div,
  body.printing-payroll-summary .signoff-signatures > div {
    background: #f8fafc !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    border: 1px solid #94a3b8 !important;
    border-radius: 6px !important;
    padding: 12px 10px !important;
  }


  /* ------------------------------------------------------------------------
     A5. ATTENDANCE PERIOD SUMMARY & INDIVIDUAL PRINT
     ------------------------------------------------------------------------ */
  body.printing-attendance-summary {
    page: landscapePage;
  }
  body.printing-attendance-summary > *:not(#attendancePrintContainer) {
    display: none !important;
  }
  body.printing-attendance-summary #attendancePrintContainer {
    display: block !important;
    position: static !important;
    width: 100% !important;
    background: #ffffff !important;
    padding: 6mm !important;
    margin: 0 !important;
  }
  body.printing-attendance-summary #attendancePrintContainer * {
    visibility: visible !important;
  }

  body.printing-attendance-individual > *:not(#attendancePrintContainer) {
    display: none !important;
  }
  body.printing-attendance-individual #attendancePrintContainer {
    display: block !important;
    position: static !important;
    width: 100% !important;
    max-width: 760px !important;
    margin: 0 auto !important;
    background: #ffffff !important;
    padding: 6mm !important;
  }
  body.printing-attendance-individual #attendancePrintContainer * {
    visibility: visible !important;
  }


  /* ========================================================================
     GROUP B: TAB PRINT DOCUMENTS (History Individual, Yearly Summary, Analytics)
     When printing tabs, all modal overlays are ALWAYS HIDDEN!
     ======================================================================== */
  body:not(.printing-payslip):not(.printing-salary-cert):not(.printing-50twi):not(.printing-payroll-summary):not(.printing-attendance-summary):not(.printing-attendance-individual) .modal-overlay {
    display: none !important;
  }

  /* ------------------------------------------------------------------------
     B1. INDIVIDUAL EMPLOYEE HISTORY REPORT (A4 LANDSCAPE)
     ------------------------------------------------------------------------ */
  body.printing-history {
    page: landscapePage;
  }
  body.printing-history #appShell,
  body.printing-history .main-container {
    display: block !important;
    position: static !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
  }
  body.printing-history .tab-content:not(#tab-history) {
    display: none !important;
  }
  body.printing-history #tab-history {
    display: block !important;
    overflow: visible !important;
  }
  body.printing-history #histYearlyViewArea,
  body.printing-history #histBatchPrintArea {
    display: none !important;
  }
  body.printing-history #histContentArea {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  body.printing-history #individualPrintHeaderBanner {
    display: block !important;
    text-align: center !important;
    margin-bottom: 6px !important;
  }
  body.printing-history #histEmpBioCard {
    display: block !important;
    margin-bottom: 8px !important;
    padding: 8px 12px !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 6px !important;
    background: #f8fafc !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
  body.printing-history .square-kpi-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 8px !important;
    margin-bottom: 8px !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
  body.printing-history .square-kpi-card {
    padding: 6px 10px !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 6px !important;
    background: #ffffff !important;
  }
  body.printing-history .table-wrapper {
    overflow: visible !important;
    border: none !important;
    box-shadow: none !important;
  }
  body.printing-history #historyTable {
    width: 100% !important;
    table-layout: fixed !important;
    font-size: 9.5px !important;
    border-collapse: collapse !important;
  }
  body.printing-history #historyTable th,
  body.printing-history #historyTable td {
    padding: 3px 2px !important;
    border: 0.5pt solid #cbd5e1 !important;
  }
  body.printing-history .no-print-col,
  body.printing-history #historyTable th.no-print-col,
  body.printing-history #historyTable td.no-print-col {
    display: none !important;
  }
  body.printing-history #individualPrintSignatures {
    display: grid !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    margin-top: 10px !important;
  }

  /* ------------------------------------------------------------------------
     B2. YEARLY SUMMARY MATRIX (A4 LANDSCAPE)
     ------------------------------------------------------------------------ */
  body.printing-yearly-summary {
    page: landscapePage;
  }
  body.printing-yearly-summary #appShell,
  body.printing-yearly-summary .main-container {
    display: block !important;
    position: static !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
  }
  body.printing-yearly-summary .tab-content:not(#tab-history) {
    display: none !important;
  }
  body.printing-yearly-summary #tab-history {
    display: block !important;
    overflow: visible !important;
  }
  body.printing-yearly-summary #histContentArea,
  body.printing-yearly-summary #histBatchPrintArea {
    display: none !important;
  }
  body.printing-yearly-summary #histYearlyViewArea {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  body.printing-yearly-summary #yearlyPrintHeaderBanner {
    display: block !important;
    text-align: center !important;
    margin-bottom: 6px !important;
  }
  body.printing-yearly-summary .square-kpi-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 8px !important;
    margin-bottom: 8px !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
  body.printing-yearly-summary .square-kpi-card {
    padding: 6px 10px !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 6px !important;
    background: #ffffff !important;
  }
  body.printing-yearly-summary .table-wrapper {
    overflow: visible !important;
    border: none !important;
    box-shadow: none !important;
  }
  body.printing-yearly-summary #yearlySummaryTable {
    width: 100% !important;
    table-layout: fixed !important;
    font-size: 9.5px !important;
    border-collapse: collapse !important;
  }
  body.printing-yearly-summary #yearlySummaryTable th,
  body.printing-yearly-summary #yearlySummaryTable td {
    padding: 3px 2px !important;
    border: 0.5pt solid #cbd5e1 !important;
  }
  body.printing-yearly-summary #yearlyPrintSignatures {
    display: grid !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    margin-top: 10px !important;
  }

  /* ------------------------------------------------------------------------
     B3. BATCH PRINT ALL EMPLOYEES (A4 LANDSCAPE)
     ------------------------------------------------------------------------ */
  body.printing-batch-history {
    page: landscapePage;
  }
  body.printing-batch-history #appShell,
  body.printing-batch-history .main-container {
    display: block !important;
    position: static !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
  }
  body.printing-batch-history .tab-content:not(#tab-history) {
    display: none !important;
  }
  body.printing-batch-history #tab-history {
    display: block !important;
    overflow: visible !important;
  }
  body.printing-batch-history #histYearlyViewArea,
  body.printing-batch-history #histContentArea {
    display: none !important;
  }
  body.printing-batch-history #histBatchPrintArea {
    display: block !important;
    padding: 0 !important;
  }
  body.printing-batch-history .batch-emp-page {
    page-break-after: always !important;
    break-after: page !important;
    padding: 5mm !important;
  }
  body.printing-batch-history .batch-emp-page:last-child {
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  /* ------------------------------------------------------------------------
     B4. EXECUTIVE ANALYTICS REPORT (A4 LANDSCAPE)
     ------------------------------------------------------------------------ */
  body.printing-analytics {
    page: landscapePage;
  }
  body.printing-analytics #appShell,
  body.printing-analytics .main-container {
    display: block !important;
    position: static !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
  }
  body.printing-analytics .tab-content:not(#tab-analytics) {
    display: none !important;
  }
  body.printing-analytics #tab-analytics {
    display: block !important;
    overflow: visible !important;
  }
  body.printing-analytics #analyticsPrintHeaderBanner {
    display: block !important;
    margin-bottom: 8px !important;
  }
  body.printing-analytics .analytics-header,
  body.printing-analytics .analytics-filter-bar,
  body.printing-analytics .analytics-filter-btn-group {
    display: none !important;
  }
  body.printing-analytics .analytics-kpi-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 8px !important;
    margin-bottom: 8px !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
  body.printing-analytics .analytics-kpi-card {
    padding: 8px 10px !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 6px !important;
    background: #ffffff !important;
  }
  body.printing-analytics .analytics-grid-2 {
    display: grid !important;
    grid-template-columns: 2fr 1fr !important;
    gap: 10px !important;
    margin-bottom: 10px !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
  body.printing-analytics .analytics-grid-3 {
    display: grid !important;
    grid-template-columns: 1fr 1fr 1.2fr !important;
    gap: 10px !important;
    margin-bottom: 10px !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
  body.printing-analytics .analytics-card {
    border: 1px solid #cbd5e1 !important;
    border-radius: 6px !important;
    padding: 10px !important;
  }
  body.printing-analytics .analytics-chart-box {
    height: 180px !important;
  }
  body.printing-analytics .analytics-matrix-pills {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 6px !important;
    margin-bottom: 8px !important;
  }
  body.printing-analytics .analytics-table th,
  body.printing-analytics .analytics-table td {
    padding: 4px 6px !important;
    border-bottom: 0.5pt solid #cbd5e1 !important;
    font-size: 10.5px !important;
  }
}

/* ==========================================================================
   AI PAYROLL ASSISTANT WIDGET
   ========================================================================== */
.ai-chat-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #ffffff;
  border: none;
  border-radius: 50px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 10px 25px -5px rgba(124, 58, 237, 0.5), 0 8px 10px -6px rgba(124, 58, 237, 0.4);
  cursor: grab;
  user-select: none;
  touch-action: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.ai-chat-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 15px 30px -5px rgba(124, 58, 237, 0.6), 0 10px 12px -6px rgba(124, 58, 237, 0.5);
}
.ai-chat-btn:active {
  cursor: grabbing;
}
.ai-chat-btn .sparkle-icon {
  font-size: 18px;
  animation: pulse-spin 3s infinite ease-in-out;
}
@keyframes pulse-spin {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.2) rotate(15deg); }
}

.ai-chat-drawer {
  position: fixed;
  bottom: 84px;
  right: 24px;
  width: 420px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 120px);
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 16px;
  box-shadow: 0 20px 40px -10px rgba(15, 23, 42, 0.25), 0 10px 15px -5px rgba(15, 23, 42, 0.1);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.ai-chat-drawer.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.ai-chat-header {
  background: linear-gradient(135deg, #1e3a8a, #4338ca);
  color: #ffffff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.ai-chat-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ai-avatar {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  backdrop-filter: blur(4px);
}
.ai-chat-name {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
}
.ai-chat-status {
  font-size: 11px;
  color: #86efac;
  display: flex;
  align-items: center;
  gap: 4px;
}
.ai-chat-status::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 8px #22c55e;
}
.ai-chat-actions {
  display: flex;
  gap: 6px;
}
.ai-header-btn {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all 0.15s;
}
.ai-header-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.ai-chat-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
}

.ai-quick-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
}
.ai-chip {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.ai-chip:hover {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.ai-msg {
  display: flex;
  gap: 8px;
  max-width: 88%;
}
.ai-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.ai-msg.bot {
  align-self: flex-start;
}
.ai-msg-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 12.5px;
  line-height: 1.5;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.ai-msg.user .ai-msg-bubble {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #ffffff;
  border-bottom-right-radius: 2px;
}
.ai-msg.bot .ai-msg-bubble {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 2px;
}
.ai-msg.bot .ai-msg-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 6px 0;
  font-size: 11px;
}
.ai-msg.bot .ai-msg-bubble th,
.ai-msg.bot .ai-msg-bubble td {
  border: 1px solid #cbd5e1;
  padding: 4px 6px;
}
.ai-msg.bot .ai-msg-bubble th {
  background: #f1f5f9;
  font-weight: 700;
}
.ai-msg.bot .ai-msg-bubble ul {
  margin: 4px 0 4px 16px;
  padding: 0;
}

.ai-typing {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  width: fit-content;
  align-self: flex-start;
}
.ai-typing-dot {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out both;
}
.ai-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.ai-typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

.ai-chat-footer {
  padding: 10px 14px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 8px;
  align-items: center;
}
.ai-chat-input {
  flex: 1;
  padding: 8px 12px;
  border: 1.5px solid #cbd5e1;
  border-radius: 20px;
  font-size: 12.5px;
  outline: none;
  font-family: inherit;
}
.ai-chat-input:focus {
  border-color: #2563eb;
}
.ai-send-btn {
  background: #2563eb;
  color: #ffffff;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: all 0.15s;
}
.ai-send-btn:hover {
  background: #1d4ed8;
  transform: scale(1.05);
}

/* =======================================================
   SQUARE KPI TILES (STYLE 1: MODERN CLEAN MINIMAL V6.2)
   ======================================================= */
.square-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}
.square-kpi-grid.five-cols {
  grid-template-columns: repeat(5, 1fr);
}
@media (max-width: 1200px) {
  .square-kpi-grid.five-cols {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 900px) {
  .square-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .square-kpi-grid.five-cols {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 520px) {
  .square-kpi-grid,
  .square-kpi-grid.five-cols {
    grid-template-columns: 1fr;
  }
}
.square-kpi-card {
  background: #ffffff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  position: relative;
  min-height: 124px;
}
.square-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}
.square-kpi-card.clickable {
  cursor: pointer;
  user-select: none;
}
.square-kpi-card.clickable:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 20px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}
.square-kpi-card.clickable:active {
  transform: translateY(-1px);
}
.square-kpi-card.blue { border-left: 4px solid var(--primary); }
.square-kpi-card.green { border-left: 4px solid var(--success); }
.square-kpi-card.orange { border-left: 4px solid var(--warning); }
.square-kpi-card.purple { border-left: 4px solid var(--accent); }
.square-kpi-card.red { border-left: 4px solid var(--danger); }

.square-kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.square-kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.square-kpi-icon.blue { background: #eff6ff; color: #1d4ed8; }
.square-kpi-icon.green { background: #ecfdf5; color: #059669; }
.square-kpi-icon.orange { background: #fff7ed; color: #c2410c; }
.square-kpi-icon.purple { background: #f5f3ff; color: #7c3aed; }
.square-kpi-icon.red { background: #fef2f2; color: #dc2626; }

.square-kpi-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
}
.square-kpi-value {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
  margin-top: 2px;
}
.square-kpi-footer {
  font-size: 10.5px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-light);
  padding-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ==========================================================================
   ANALYTICS & EXECUTIVE DECISION HUB STYLES (V6.3)
   ========================================================================== */
.analytics-header {
  background: #ffffff;
  border-radius: var(--radius);
  padding: 16px 20px;
  border: 1px solid var(--border-light);
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}
.analytics-header-title h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.analytics-header-title p {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 3px;
  margin-bottom: 0;
}
.analytics-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.analytics-filter-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-light);
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  font-size: 12px;
  font-weight: 600;
}
.analytics-filter-item select {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 600;
  background: #fff;
  outline: none;
}

/* KPI 4-Card Grid */
.analytics-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.analytics-kpi-card {
  background: #ffffff;
  border-radius: var(--radius);
  padding: 16px 18px;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  border-left: 4px solid #94a3b8;
}
.analytics-kpi-card.blue { border-left-color: var(--primary); }
.analytics-kpi-card.green { border-left-color: var(--success); }
.analytics-kpi-card.purple { border-left-color: #8b5cf6; }
.analytics-kpi-card.orange { border-left-color: #f59e0b; }
.analytics-kpi-card.teal { border-left-color: #0d9488; }

.analytics-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1.5px solid var(--border-light);
}
.analytics-section-badge {
  background: #1e3a8a;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 6px;
  letter-spacing: 0.3px;
}
.analytics-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.analytics-kpi-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.analytics-kpi-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}
.analytics-kpi-badge {
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 700;
  background: #f1f5f9;
  color: #475569;
}
.analytics-kpi-val {
  font-size: 22px;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-dark);
}
.analytics-kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Analytics Chart Grids */
.analytics-grid-2 {
  display: grid;
  grid-template-columns: 2fr 1.1fr;
  gap: 16px;
  margin-bottom: 18px;
}
@media (max-width: 1024px) {
  .analytics-grid-2 { grid-template-columns: 1fr; }
}

.analytics-grid-3 {
  display: grid;
  grid-template-columns: 1.1fr 1.1fr 1.4fr;
  gap: 16px;
  margin-bottom: 18px;
}
@media (max-width: 1100px) {
  .analytics-grid-3 { grid-template-columns: 1fr; }
}

.analytics-card {
  background: #ffffff;
  border-radius: var(--radius);
  padding: 16px 18px;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}
.analytics-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 10px;
}
.analytics-card-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
}
.analytics-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: #f1f5f9;
  color: #475569;
}
.analytics-chart-box {
  position: relative;
  width: 100%;
  height: 250px;
}

/* Tables in Analytics */
.analytics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.analytics-table th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 2px solid #e2e8f0;
  color: #475569;
  font-weight: 700;
  font-size: 11.5px;
}
.analytics-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.analytics-rank-badge {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  background: #e2e8f0;
  color: #475569;
}
.analytics-rank-badge.top1 { background: #fef08a; color: #854d0e; }
.analytics-rank-badge.top2 { background: #e2e8f0; color: #475569; }
.analytics-rank-badge.top3 { background: #fed7aa; color: #9a3412; }

/* Filter buttons for matrix */
.analytics-filter-btn-group {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.analytics-filter-btn {
  font-size: 11.5px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 20px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s;
}
.analytics-filter-btn:hover { background: #f8fafc; }
.analytics-filter-btn.active { background: #1e40af; color: #ffffff; border-color: #1e40af; }
.analytics-filter-btn.green.active { background: #059669; color: #ffffff; border-color: #059669; }
.analytics-filter-btn.blue.active { background: #2563eb; color: #ffffff; border-color: #2563eb; }
.analytics-filter-btn.orange.active { background: #d97706; color: #ffffff; border-color: #d97706; }
.analytics-filter-btn.red.active { background: #dc2626; color: #ffffff; border-color: #dc2626; }

/* Matrix Pills */
.analytics-matrix-pills {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.matrix-pill {
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.matrix-pill:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.matrix-pill.green { background: #f0fdf4; border: 1px solid #bbf7d0; }
.matrix-pill.blue { background: #eff6ff; border: 1px solid #bfdbfe; }
.matrix-pill.orange { background: #fffbeb; border: 1px solid #fde68a; }
.matrix-pill.red { background: #fef2f2; border: 1px solid #fecaca; }

.matrix-pill-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.matrix-pill.green .matrix-pill-icon { background: #dcfce7; color: #16a34a; }
.matrix-pill.blue .matrix-pill-icon { background: #dbeafe; color: #2563eb; }
.matrix-pill.orange .matrix-pill-icon { background: #fef3c7; color: #d97706; }
.matrix-pill.red .matrix-pill-icon { background: #fee2e2; color: #dc2626; }

.matrix-pill-title {
  font-size: 11px;
  font-weight: 700;
}
.matrix-pill.green .matrix-pill-title { color: #15803d; }
.matrix-pill.blue .matrix-pill-title { color: #1d4ed8; }
.matrix-pill.orange .matrix-pill-title { color: #92400e; }
.matrix-pill.red .matrix-pill-title { color: #b91c1c; }

.matrix-pill-val {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
}
.matrix-pill.green .matrix-pill-val { color: #14532d; }
.matrix-pill.blue .matrix-pill-val { color: #1e40af; }
.matrix-pill.orange .matrix-pill-val { color: #78350f; }
.matrix-pill.red .matrix-pill-val { color: #7f1d1d; }

.matrix-pill-sub {
  font-size: 10.5px;
  font-weight: 400;
  opacity: 0.85;
}

/* Insights list */
.analytics-insights-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  max-height: 320px;
  padding-right: 4px;
}
.insight-card-item {
  border-radius: 10px;
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-left-width: 4px;
}
.insight-card-item.orange { border-left-color: #f97316; background: #fffaf5; border-color: #fed7aa; }
.insight-card-item.pink { border-left-color: #db2777; background: #fdf2f8; border-color: #fbcfe8; }
.insight-card-item.green { border-left-color: #16a34a; background: #f0fdf4; border-color: #bbf7d0; }

.insight-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.insight-badge {
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 20px;
}
.insight-badge.orange { background: #ffedd5; color: #c2410c; }
.insight-badge.pink { background: #fce7f3; color: #9d174d; }
.insight-badge.green { background: #dcfce7; color: #15803d; }

.insight-impact {
  font-size: 10.5px;
  font-weight: 700;
}
.insight-impact.orange { color: #ea580c; }
.insight-impact.pink { color: #be185d; }
.insight-impact.green { color: #15803d; }

.insight-action-box {
  background: #ffffff;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11.5px;
  margin-top: 6px;
}
.insight-action-box.orange { border: 1px solid #ffedd5; }
.insight-action-box.pink { border: 1px solid #fce7f3; }
.insight-action-box.green { border: 1px solid #dcfce7; }

/* DOCUMENT & COMPLIANCE CENTER */
.doc-panel {
  animation: fadeIn 0.2s ease;
}
.salary-cert-paper {
  font-family: 'Sarabun', 'Prompt', sans-serif;
}
.salary-cert-paper [contenteditable="true"] {
  transition: all 0.15s ease;
  border-radius: 4px;
  padding: 2px 4px;
}
.salary-cert-paper [contenteditable="true"]:hover {
  outline: 1.5px dashed #3b82f6;
  background-color: #f8fafc;
  cursor: text;
}
.salary-cert-paper [contenteditable="true"]:focus {
  outline: 2px solid #2563eb;
  background-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
