/* ============================================================
   ISU Ilagan — IPCR Management System
   Theme: Forest Green & Gold | Premium Clean UI
   ============================================================ */

:root {
  /* ISU Brand Colors — exact match to ISU Ilagan seal logo */
  --primary:        #1a5c2a;   /* ISU dark forest green */
  --primary-dark:   #0e3d1a;   /* Deep dark green */
  --primary-light:  #207832;   /* Medium green */
  --primary-xlight: #eaf4ec;   /* Light green tint */
  --primary-hover:  #1a6b2e;   /* Hover */
  --accent:         #c8a415;   /* ISU Gold */
  --accent-light:   #f0c940;   /* Light gold */
  --accent-bg:      #fdf9e8;   /* Gold tint bg */

  --success:  #16a34a;
  --warning:  #d97706;
  --danger:   #dc2626;
  --info:     #0369a1;

  --white:    #ffffff;
  --gray-50:  #f6faf7;
  --gray-100: #eef4f0;
  --gray-200: #dbe6de;
  --gray-300: #c2d4c7;
  --gray-400: #96b59e;
  --gray-500: #6a8f72;
  --gray-600: #4b6b52;
  --gray-700: #334a38;
  --gray-800: #1e2d22;

  --sidebar-w:   272px;
  --navbar-h:    62px;
  --border-r:    10px;
  --border-r-sm: 6px;
  --border-r-lg: 14px;

  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow-sm: 0 1px 4px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.09), 0 2px 6px rgba(0,0,0,.05);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.13), 0 4px 12px rgba(0,0,0,.07);

  --transition: all .18s ease;
}

/* ── BASE ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--gray-800);
  background: var(--gray-100);
  min-height: 100vh;
  margin: 0;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

/* ── LOGIN ────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  /* Background image with CEAT building - lighter overlay for glassmorphism effect */
  background:
    linear-gradient(rgba(8, 40, 21, 0.4), rgba(13, 61, 30, 0.5)),
    url('../images/ceat.jpg') center center/cover no-repeat;
  background-attachment: fixed;
  position: relative;
  overflow: hidden;
}

/* If image not found, fallback to gradient */
@supports not (background: url('../images/gemini_generated.jpg')) {
  .login-page {
    background:
      radial-gradient(ellipse at 20% 20%, rgba(46,125,79,.35) 0%, transparent 60%),
      radial-gradient(ellipse at 80% 80%, rgba(200,164,21,.18) 0%, transparent 60%),
      linear-gradient(150deg, #082815 0%, #0d3d1e 40%, #1b5e35 100%);
  }
}

/* Subtle pattern overlay */
.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255,255,255,.04) 1px, transparent 0);
  background-size: 32px 32px;
  z-index: 1;
  pointer-events: none;
}

/* Decorative accent - subtle */
.login-page::after {
  content: '';
  position: absolute;
  bottom: -100px; right: -100px;
  width: 500px; height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(200,164,21,.08) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.login-card {
  /* Glassmorphism / Frosted Glass Effect */
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: 44px 44px 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: 
    0 8px 32px 0 rgba(0, 0, 0, 0.37),
    0 0 40px rgba(46, 125, 79, 0.4),
    0 0 80px rgba(46, 125, 79, 0.2),
    inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  position: relative;
  z-index: 10;
  margin-bottom: 20px;
}

/* Make text more readable on transparent background */
.login-card .login-title {
  color: #ffffff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.login-card .login-subtitle {
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.login-card .form-label {
  color: #ffffff;
  font-weight: 600;
}

.login-card .alert {
  background: rgba(220, 53, 69, 0.2);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(220, 53, 69, 0.4);
  color: #ffffff;
}

.login-card .login-demo-box {
  background: rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 16px;
  color: rgba(255, 255, 255, 0.95);
}

.login-card .login-demo-box .border-bottom {
  border-bottom-color: rgba(255, 255, 255, 0.15) !important;
}

.login-card a {
  color: #c8a415 !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.login-card .input-group-text {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  color: #ffffff;
}

.login-card .form-control {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  color: #ffffff;
}

.login-card .form-control::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.login-card .form-control:focus {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
  color: #ffffff;
  box-shadow: 0 0 0 0.25rem rgba(255, 255, 255, 0.15);
}

.login-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  margin: 24px 0;
}
  position: relative;
  z-index: 1;
  border-top: 4px solid var(--accent);
}

@media (max-width: 480px) {
  .login-card { padding: 32px 24px 28px; border-radius: 14px; }
  .login-isu-logo { width: 72px; height: 72px; }
  .login-title { font-size: .98rem; }
}

.login-logo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 28px;
  gap: 10px;
}

.login-isu-logo {
  width: 96px;
  height: 96px;
  object-fit: contain;
  filter: drop-shadow(0 3px 10px rgba(0,0,0,.18));
}

.login-title {
  color: var(--primary);
  font-size: 1.1rem;
  font-weight: 800;
  text-align: center;
  line-height: 1.35;
}

.login-subtitle {
  color: var(--gray-500);
  font-size: .8rem;
  text-align: center;
  line-height: 1.6;
}

.login-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gray-200), transparent);
  margin: 20px 0;
}

.login-demo-box {
  background: var(--primary-xlight);
  border: 1px solid #b8d9c4;
  border-radius: var(--border-r);
  padding: 14px 16px;
  font-size: .78rem;
  color: var(--gray-600);
}

.login-demo-box .fw-bold { color: var(--primary); font-size: .8rem; }

/* ── APP SHELL ────────────────────────────────────────────── */
#app-shell { display: flex; min-height: 100vh; }

/* ── SIDEBAR ──────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--primary-dark);
  color: #fff;
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 999; /* Below modals (1055) and topbar (900), but above content */
  transition: width .22s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

#sidebar::-webkit-scrollbar { width: 3px; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 3px; }

/* Gold top accent line on sidebar */
#sidebar::before {
  content: '';
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-light), var(--accent));
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 18px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
}

.sidebar-logo-img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
  padding: 3px;
  flex-shrink: 0;
  object-fit: contain;
  box-shadow: 0 0 0 2px rgba(200,164,21,.5);
}

.sidebar-logo-fallback {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: .82rem; font-weight: 800; color: #fff;
  flex-shrink: 0;
}

.sidebar-brand-name {
  font-size: .8rem;
  font-weight: 700;
  line-height: 1.3;
  color: #fff;
}

.sidebar-brand-sub {
  font-size: .67rem;
  color: var(--accent-light);
  margin-top: 2px;
  font-weight: 500;
  opacity: .85;
}

.sidebar-nav { flex: 1; padding: 8px 0 16px; }

.sidebar-section-label {
  font-size: .63rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
  padding: 18px 20px 5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,.08);
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px 9px 16px;
  margin: 1px 10px;
  color: rgba(255,255,255,.68);
  font-size: .855rem;
  transition: var(--transition);
  border-radius: 8px;
  text-decoration: none;
  position: relative;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.95);
}

.sidebar-nav a.active {
  background: rgba(255,255,255,.13);
  color: #fff;
  font-weight: 600;
}

.sidebar-nav a.active::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent-light);
  border-radius: 0 3px 3px 0;
}

.sidebar-nav a i {
  font-size: .95rem;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
  opacity: .85;
}

.sidebar-nav a.active i { opacity: 1; }

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.07);
  font-size: .72rem;
  color: rgba(255,255,255,.3);
}

/* ── MAIN WRAPPER ─────────────────────────────────────────── */
#main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left .22s ease;
}

/* ── TOPBAR ───────────────────────────────────────────────── */
#topbar {
  height: var(--navbar-h);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: 0 1px 0 rgba(0,0,0,.04), 0 2px 12px rgba(0,0,0,.05);
}

.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; }

.topbar-title {
  font-size: .92rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -.01em;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 14px 5px 6px;
  border-radius: 32px;
  background: var(--primary-xlight);
  border: 1.5px solid #c0ddc9;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  color: inherit;
}

.topbar-user:hover {
  background: #d8eede;
  border-color: var(--primary-light);
  color: inherit;
}

.topbar-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,.8);
}

.topbar-user-name { font-size: .83rem; font-weight: 600; color: var(--gray-800); }

.topbar-user-role {
  font-size: .68rem;
  font-weight: 700;
  color: var(--primary);
  background: rgba(27,94,53,.1);
  padding: 2px 10px;
  border-radius: 12px;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.btn-sidebar-toggle {
  background: none;
  border: none;
  color: var(--gray-500);
  font-size: 1.2rem;
  padding: 7px 9px;
  cursor: pointer;
  border-radius: 8px;
  transition: var(--transition);
  line-height: 1;
  display: flex; align-items: center;
}

.btn-sidebar-toggle:hover { background: var(--gray-100); color: var(--primary); }

/* ── PAGE CONTENT ─────────────────────────────────────────── */
#page-content { flex: 1; padding: 28px 32px; }

/* ── PAGE HEADER ──────────────────────────────────────────── */
.page-header {
  margin-bottom: 26px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--gray-200);
  position: relative;
  z-index: 1; /* Ensure page header is below modals */
}

.page-header-left {}

.page-header h1 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  margin: 0 0 5px;
  letter-spacing: -.03em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-header h1 i {
  font-size: 1.2rem;
  opacity: .75;
}

.breadcrumb-bar {
  font-size: .76rem;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb-bar a { color: var(--primary-light); font-weight: 500; }
.breadcrumb-bar a:hover { color: var(--primary); }
.breadcrumb-bar::before { content: ''; }

/* ── CARDS ────────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--border-r);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 14px 22px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--gray-50);
  position: relative; /* Required for absolute positioning of settings button */
}

.card-header h5, .card-header h6 {
  margin: 0;
  font-weight: 700;
  color: var(--primary);
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: 7px;
}

.card-body { padding: 22px; }

.card-footer {
  padding: 12px 22px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
}

/* ── METRIC CARDS ─────────────────────────────────────────── */
.metric-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--border-r);
  padding: 24px 20px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  /* Make cards square and equal height */
  aspect-ratio: 1 !important;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 160px;
}

.metric-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gray-200);
  transition: var(--transition);
}

.metric-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.metric-card:hover::after {
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
}

.metric-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  margin-bottom: 12px;
}

.metric-value {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--primary);
  letter-spacing: -.04em;
  margin-bottom: 6px;
}

.metric-label { 
  font-size: .82rem; 
  color: var(--gray-600); 
  font-weight: 600;
  margin-bottom: 4px;
}

.metric-sub { 
  font-size: .7rem; 
  color: var(--gray-400);
  line-height: 1.3;
}

.metric-icon-primary { background: rgba(27,94,53,.1);  color: var(--primary); }
.metric-icon-success { background: rgba(22,163,74,.1); color: var(--success); }
.metric-icon-warning { background: rgba(217,119,6,.1); color: var(--warning); }
.metric-icon-danger  { background: rgba(220,38,38,.1); color: var(--danger); }
.metric-icon-info    { background: rgba(3,105,161,.1); color: var(--info); }
.metric-icon-accent  { background: rgba(200,164,21,.12); color: var(--accent); }

/* ── SUBMISSION STAT CARDS ────────────────────────────────── */
.submission-stat-card {
  background: #fff;
  border-radius: var(--border-r);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  max-height: 160px;
  height: 100%;
  aspect-ratio: 1 / 1; /* Force square shape */
}

/* Ensure parent columns maintain square aspect */
.submission-tracking-row > [class*='col-'] {
  display: flex;
  max-width: 180px; /* Limit maximum card width */
}

.submission-tracking-row a {
  width: 100%;
  display: flex;
  aspect-ratio: 1 / 1;
}

a:has(.submission-stat-card):hover .submission-stat-card,
.submission-stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  border-color: currentColor !important;
}

.submission-stat-icon {
  font-size: 2rem;
  margin-bottom: 10px;
  transition: var(--transition);
}

a:has(.submission-stat-card):hover .submission-stat-icon {
  transform: scale(1.1);
}

.submission-stat-value {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.04em;
}

.submission-stat-label {
  font-size: .85rem;
  color: var(--gray-600);
  margin-top: 8px;
  font-weight: 500;
}

/* ── TABLES ───────────────────────────────────────────────── */
.table-container {
  border-radius: var(--border-r);
  overflow: hidden;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}

.ipcr-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.ipcr-table thead tr {
  background: var(--primary);
}

.ipcr-table th {
  color: #ffffff !important;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 12px 16px;
  border: none;
  white-space: nowrap;
}

.ipcr-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
  font-size: .865rem;
  color: var(--gray-800);
}

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

.ipcr-table tbody tr {
  transition: background .12s ease;
  position: relative;
  pointer-events: auto;
}

.ipcr-table tbody tr:hover {
  background: var(--primary-xlight);
}

/* Ensure action buttons stay interactive above hover background */
.ipcr-table tbody tr:hover td.dept-actions,
.ipcr-table tbody tr:hover td.user-actions {
  position: relative;
  z-index: 20;
}

.ipcr-table tbody tr:hover td.dept-actions *,
.ipcr-table tbody tr:hover td.user-actions * {
  pointer-events: auto !important;
}

/* Ensure action buttons are always clickable */
.ipcr-table td.dept-actions,
.ipcr-table td.user-actions {
  pointer-events: auto !important;
}

.ipcr-table td.dept-actions *,
.ipcr-table td.user-actions * {
  pointer-events: auto !important;
}

/* Hide evaluator row on desktop - it shows inline with name */
.ipcr-table td.evaluator-row {
  display: none;
}

/* ── FILTER BAR ───────────────────────────────────────────── */
.filter-bar {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--border-r);
  padding: 12px 16px;
  margin-bottom: 20px;
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  box-shadow: var(--shadow-xs);
}

/* Search input max-width on desktop */
.filter-bar .filter-search-input {
  width: 180px;
  max-width: 180px;
  flex-shrink: 1;
  flex-grow: 0;
}

/* Compact select dropdowns */
.filter-bar .form-select {
  width: 135px;
  max-width: 135px;
  flex-shrink: 1;
  flex-grow: 0;
}

/* Date input styling */
.filter-bar .filter-date-input {
  width: 145px;
  max-width: 145px;
  flex-shrink: 1;
  flex-grow: 0;
}

/* Compact buttons */
.filter-bar .btn {
  padding: 8px 14px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Medium screens - allow wrapping if needed */
@media (max-width: 1199px) {
  .filter-bar {
    flex-wrap: wrap;
  }
  
  .filter-bar .filter-search-input {
    min-width: 180px;
  }
}

/* ── BUTTONS ──────────────────────────────────────────────── */
.btn-primary {
  background-color: var(--primary) !important;
  border-color: var(--primary) !important;
  font-weight: 600 !important;
  letter-spacing: .01em;
}

.btn-primary:hover, .btn-primary:focus {
  background-color: var(--primary-light) !important;
  border-color: var(--primary-light) !important;
  box-shadow: 0 4px 12px rgba(27,94,53,.25) !important;
}

.btn-outline-primary {
  color: var(--primary) !important;
  border-color: var(--primary) !important;
  font-weight: 600 !important;
}

.btn-outline-primary:hover {
  background-color: var(--primary) !important;
  color: #fff !important;
  box-shadow: 0 4px 12px rgba(27,94,53,.2) !important;
}

/* ── BADGES ───────────────────────────────────────────────── */
.badge.bg-primary { background: var(--primary) !important; }

.late-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: .7rem;
  font-weight: 600;
  color: #fff;
  background: var(--warning);
  border-radius: 4px;
  margin-left: 6px;
  text-transform: uppercase;
  letter-spacing: .3px;
}

/* ── MODAL ────────────────────────────────────────────────── */
.modal-header {
  background: linear-gradient(90deg, var(--primary-dark), var(--primary));
  color: #fff;
  border-radius: 10px 10px 0 0;
  border-bottom: 3px solid var(--accent);
  padding: 16px 22px;
}

.modal-header .btn-close { filter: invert(1) brightness(1.5); }
.modal-title { font-weight: 700; font-size: .95rem; }
.modal-content { border-radius: var(--border-r); overflow: hidden; border: none; box-shadow: var(--shadow-lg); }
.modal-footer { border-top: 1px solid var(--gray-200); background: var(--gray-50); }

/* ── FORMS ────────────────────────────────────────────────── */
.form-label { font-size: .83rem; font-weight: 600; color: var(--gray-700); margin-bottom: 5px; }

.form-control, .form-select {
  border-color: var(--gray-300);
  font-size: .87rem;
  border-radius: var(--border-r-sm);
  transition: var(--transition);
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(27,94,53,.1);
  outline: none;
}

/* ── CHECKBOX & RADIO STYLING ──────────────────────────────── */
.form-check-input {
  width: 18px;
  height: 18px;
  margin-top: 0.15em;
  vertical-align: top;
  background-color: #fff;
  border: 2px solid var(--gray-400);
  border-radius: 4px;
  transition: all 0.15s ease-in-out;
  cursor: pointer;
}

.form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

.form-check-input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(27,94,53,.15);
  outline: none;
}

.form-check-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  cursor: pointer;
  padding-left: 6px;
}

.form-check {
  display: flex;
  align-items: center;
  min-height: 1.2rem;
  padding-left: 0;
  margin-bottom: 0.5rem;
}

/* Smaller checkboxes in template forms */
.mfo-body .form-check-input,
.p-3.bg-light .form-check-input {
  width: 16px;
  height: 16px;
}

.mfo-body .form-check-label,
.p-3.bg-light .form-check-label {
  font-size: 0.8rem;
}

/* ── TOGGLE SWITCH (form-switch) ──────────────────────────────── */
/* Override checkbox styles for toggle switches */
.form-switch .form-check-input {
  width: 48px !important;
  height: 24px !important;
  min-width: 48px;
  min-height: 24px;
  background-color: var(--gray-300);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e") !important;
  background-position: left center;
  background-size: contain;
  background-repeat: no-repeat;
  border-radius: 24px !important;
  border: 2px solid var(--gray-300);
  margin-top: 0;
  transition: all 0.25s ease-in-out;
  flex-shrink: 0;
}

.form-switch .form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
  background-position: right center;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e") !important;
}

.form-switch .form-check-input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 4px rgba(27, 94, 53, 0.15);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e") !important;
}

.form-switch .form-check-input:hover {
  opacity: 0.9;
  cursor: pointer;
}

/* Ensure form-switch doesn't inherit checkbox square styling */
.form-check.form-switch {
  padding-left: 0;
}

.form-check.form-switch .form-check-input {
  margin-left: 0;
  margin-right: 10px;
}

/* Workflow Option Card styling */
.workflow-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.workflow-option {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-r);
  padding: 18px 20px;
  transition: var(--transition);
}

.workflow-option:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-sm);
}

.workflow-option .form-check-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 6px;
}

.workflow-description {
  font-size: 0.82rem;
  color: var(--gray-600);
  margin: 8px 0 0 0;
  line-height: 1.5;
}

/* ── IPCR FORM HEADER ─────────────────────────────────────── */
.ipcr-form-header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
  color: #fff;
  padding: 26px 30px;
  border-radius: var(--border-r);
  margin-bottom: 24px;
  border-left: 5px solid var(--accent);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.ipcr-form-header::after {
  content: 'IPCR';
  position: absolute;
  right: 16px; bottom: -18px;
  font-size: 6.5rem;
  font-weight: 900;
  color: rgba(255,255,255,.05);
  letter-spacing: -.05em;
  pointer-events: none;
  line-height: 1;
}

.ipcr-form-header h2 { font-size: 1.1rem; font-weight: 800; margin: 0 0 8px; }

.ipcr-form-header .meta {
  font-size: .8rem;
  opacity: .88;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.ipcr-form-header .meta span {
  display: flex; align-items: center; gap: 5px;
  background: rgba(255,255,255,.1);
  padding: 3px 10px;
  border-radius: 20px;
}

/* ── MFO ACCORDION ────────────────────────────────────────── */
.mfo-accordion { margin-bottom: 16px; border-radius: var(--border-r); overflow: hidden; box-shadow: var(--shadow-sm); }

.mfo-header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #fff;
  padding: 13px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
  border-left: 4px solid var(--accent);
}

.mfo-header:hover { filter: brightness(1.1); }
.mfo-header h6 { margin: 0; font-size: .88rem; font-weight: 700; letter-spacing: -.01em; }

.mfo-body {
  border: 1px solid var(--gray-200);
  border-top: none;
  background: #fff;
}

.kra-block { border-bottom: 1px solid var(--gray-200); }
.kra-block:last-child { border-bottom: none; }

.kra-header {
  background: linear-gradient(90deg, #f0f9f4 0%, #fff 100%);
  padding: 9px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--gray-200);
  border-left: 3px solid var(--primary-light);
}

.kra-header h6 { margin: 0; font-size: .82rem; font-weight: 700; color: var(--primary); }

/* ── SI CARDS ─────────────────────────────────────────────── */
.si-code {
  font-size: .68rem;
  font-weight: 700;
  color: var(--primary-light);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.si-targets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }

.si-target-pill {
  background: var(--primary-xlight);
  border: 1px solid #b8d9c4;
  border-radius: 20px;
  padding: 3px 11px;
  font-size: .7rem;
  color: var(--primary);
  font-weight: 500;
}

/* ── EVIDENCE ─────────────────────────────────────────────── */
.evidence-item {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--border-r-sm);
  padding: 10px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: var(--transition);
}

.evidence-item:last-child { margin-bottom: 0; }
.evidence-item:hover { border-color: #b8d9c4; box-shadow: 0 2px 8px rgba(27,94,53,.06); }

.ev-file-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}

.ev-file-pdf   { background: #fee2e2; color: #dc2626; }
.ev-file-doc   { background: #dbeafe; color: #2563eb; }
.ev-file-xls   { background: #dcfce7; color: #16a34a; }
.ev-file-img   { background: #fef9c3; color: #ca8a04; }
.ev-file-other { background: var(--primary-xlight); color: var(--primary); }

.ev-file-info { flex: 1; min-width: 0; }
.ev-filename  { font-weight: 600; font-size: .84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-meta      { font-size: .73rem; color: var(--gray-500); margin-top: 2px; }
.ev-desc      { font-size: .78rem; color: var(--gray-500); margin-top: 4px; font-style: italic; }

/* ── LIVE SCORE PANEL ─────────────────────────────────────── */
.live-score-panel {
  background: linear-gradient(160deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #fff;
  border-radius: var(--border-r);
  padding: 22px;
  position: sticky;
  top: calc(var(--navbar-h) + 14px);
  border-top: 4px solid var(--accent);
  box-shadow: var(--shadow-md);
}

.live-score-panel h6 { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; opacity: .6; margin-bottom: 10px; }
.lsp-composite { font-size: 2.8rem; font-weight: 900; line-height: 1; letter-spacing: -.05em; }
.lsp-adjectival { font-size: .95rem; font-weight: 700; margin-top: 4px; margin-bottom: 14px; color: var(--accent-light); }
.lsp-table { width: 100%; font-size: .77rem; }
.lsp-table td { padding: 4px 0; vertical-align: middle; }
.lsp-table td:last-child { text-align: right; font-weight: 700; }
.lsp-bar { height: 4px; border-radius: 2px; background: rgba(255,255,255,.15); overflow: hidden; margin-top: 3px; }
.lsp-bar-fill { height: 100%; border-radius: 2px; background: var(--accent-light); transition: width .4s ease; }

/* ── EV REVIEW CARDS ──────────────────────────────────────── */
.ev-review-card {
  border: 1.5px solid var(--gray-200);
  border-radius: var(--border-r);
  overflow: hidden;
  margin-bottom: 14px;
  transition: box-shadow .15s ease;
}

.ev-review-card:hover { box-shadow: 0 3px 14px rgba(27,94,53,.09); }
.ev-review-card.ev-verified-card      { border-left: 4px solid var(--success); }
.ev-review-card.ev-needs_revision-card{ border-left: 4px solid var(--warning); }
.ev-review-card.ev-insufficient-card,
.ev-review-card.ev-rejected-card      { border-left: 4px solid var(--danger); }
.ev-review-card.ev-pending-card       { border-left: 4px solid var(--gray-300); }

.ev-review-header {
  background: var(--gray-50);
  padding: 11px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--gray-200);
}

.ev-review-body { padding: 18px; }

/* ── ALERT VARIANTS ───────────────────────────────────────── */
.alert-return {
  background: #fff8ec;
  border: 1px solid #ffe08a;
  border-left: 4px solid var(--accent);
  border-radius: var(--border-r);
  padding: 14px 18px;
}

.alert-deadline {
  background: var(--primary-xlight);
  border: 1px solid #b8d9c4;
  border-left: 4px solid var(--primary);
  border-radius: var(--border-r);
  padding: 11px 16px;
  color: var(--primary);
  font-size: .85rem;
}

/* ── STICKY ACTIONS ───────────────────────────────────────── */
.sticky-actions {
  position: sticky;
  bottom: 0;
  background: #fff;
  border-top: 1.5px solid var(--gray-200);
  padding: 13px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: 0 -4px 18px rgba(0,0,0,.07);
  z-index: 100;
  margin: 0 -32px -28px;
}

/* ── RATING INPUT ─────────────────────────────────────────── */
.rating-input {
  width: 64px;
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
  border: 2px solid var(--gray-300);
  border-radius: 8px;
  padding: 5px 4px;
  transition: var(--transition);
}

.rating-input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(27,94,53,.1);
}

.rating-avg-display {
  padding: 4px 14px;
  border-radius: 20px;
  font-size: .85rem;
  font-weight: 700;
  background: var(--primary-xlight);
  color: var(--primary);
  border: 1px solid #b8d9c4;
}

/* ── TOAST ────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: calc(var(--navbar-h) + 14px);
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
  pointer-events: none;
}

.toast-item {
  background: #fff;
  border-radius: var(--border-r);
  box-shadow: var(--shadow-md);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: slideIn .25s ease;
  pointer-events: auto;
  border-left: 4px solid var(--primary);
  min-width: 280px;
}

.toast-success { border-left-color: var(--success); }
.toast-error   { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-info    { border-left-color: var(--info); }

.toast-icon { font-size: 1.05rem; flex-shrink: 0; margin-top: 2px; }
.toast-success .toast-icon { color: var(--success); }
.toast-error   .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info    .toast-icon { color: var(--info); }

.toast-body { flex: 1; }
.toast-title { font-weight: 700; font-size: .84rem; margin-bottom: 2px; }
.toast-msg   { font-size: .78rem; color: var(--gray-500); }
.toast-close { background: none; border: none; color: var(--gray-400); cursor: pointer; font-size: .9rem; padding: 0; line-height: 1; }

@keyframes slideIn { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to   { opacity: 0; transform: translateX(110%); } }
.toast-hiding { animation: fadeOut .25s ease forwards; }

/* ── MISC ─────────────────────────────────────────────────── */
.required-star { color: var(--danger); }
.text-muted-sm { font-size: .77rem; color: var(--gray-500); }

.late-badge {
  background: #fef3c7;
  color: #92400e;
  font-size: .66rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 6px;
  border: 1px solid #fde68a;
  vertical-align: middle;
}

.overdue-row td { background: #fff5f5 !important; }

.autosave-indicator {
  font-size: .77rem;
  color: rgba(255,255,255,.6);
  display: flex; align-items: center; gap: 6px;
}

.autosave-indicator i { color: var(--accent-light); }

/* ── AUDIT ────────────────────────────────────────────────── */
.audit-timeline { position: relative; padding-left: 28px; }
.audit-timeline::before { content: ''; position: absolute; left: 10px; top: 0; bottom: 0; width: 2px; background: var(--gray-200); }
.audit-item { position: relative; margin-bottom: 14px; }
.audit-dot { width: 20px; height: 20px; border-radius: 50%; background: var(--primary); border: 3px solid #fff; box-shadow: 0 0 0 2px var(--primary); position: absolute; left: -24px; top: 2px; }
.audit-content { background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: var(--border-r); padding: 10px 14px; }
.audit-action { font-weight: 600; font-size: .84rem; }
.audit-meta { font-size: .74rem; color: var(--gray-500); margin-top: 2px; }

/* ── RATING SUMMARY TABLE ─────────────────────────────────── */
.rating-summary-table { width: 100%; }
.rating-summary-table th,
.rating-summary-table td { padding: 9px 14px; border: 1px solid var(--gray-200); font-size: .85rem; }
.rating-summary-table th { background: var(--primary); color: #fff; font-size: .73rem; text-transform: uppercase; letter-spacing: .05em; }
.composite-row { background: var(--primary-dark) !important; }
.composite-row td { color: #fff !important; border-color: #0a2d14 !important; font-weight: 700; }

/* ── PROGRESS ─────────────────────────────────────────────── */
.progress { background: var(--gray-200) !important; border-radius: 8px !important; }
.progress-bar.bg-success { background: var(--primary) !important; }

/* ── LIST GROUP ───────────────────────────────────────────── */
.list-group-item-action.active {
  background-color: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}

/* ── FORM SECTION TITLE ───────────────────────────────────── */
.form-section-title {
  font-size: .73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--gray-500);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--gray-200);
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — All screen sizes
   ══════════════════════════════════════════════════════════ */

/* ── Large Desktop (1400px+) ── */
@media (min-width: 1400px) {
  :root { --sidebar-w: 280px; }
  #page-content { padding: 30px 36px; }
}

/* ── Desktop (1200px–1399px) — default, no changes needed ── */

/* ── Small Desktop / Large Tablet (992px–1199px) ── */
@media (max-width: 1199px) {
  :root { --sidebar-w: 250px; }
  #page-content { padding: 22px 24px; }
  .sticky-actions  { margin: 0 -24px -22px; padding: 12px 24px; }
  .form-bottom-bar { margin: 0 -24px -22px; padding: 12px 24px; }
  .metric-value    { font-size: 1.7rem; }
  
  /* Submission stat cards - mobile optimization */
  .submission-stat-card {
    padding: 12px 10px !important;
    min-height: 100px !important;
    max-height: 130px !important;
    aspect-ratio: 1 / 1 !important; /* Keep square on mobile */
  }
  
  .submission-tracking-row > [class*='col-'] {
    max-width: 150px !important;
  }
  
  .submission-tracking-row a {
    aspect-ratio: 1 / 1 !important;
  }
  
  .submission-stat-icon {
    font-size: 24px !important;
    margin-bottom: 6px !important;
  }
  
  .submission-stat-value {
    font-size: 24px !important;
    margin-bottom: 4px !important;
  }
  
  .submission-stat-label {
    font-size: 10px !important;
    line-height: 1.2 !important;
  }
}

/* ── Tablet (768px–991px) ── */
@media (max-width: 991px) {
  :root { --sidebar-w: 230px; }
  #page-content    { padding: 18px 20px; }
  .sticky-actions  { margin: 0 -20px -18px; padding: 12px 20px; }
  .form-bottom-bar { margin: 0 -20px -18px; padding: 12px 20px; }

  /* Topbar adjustments */
  .topbar-user-name { display: none; }
  #topbar { padding: 0 18px; }

  /* Page header stack */
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-header .d-flex { flex-wrap: wrap; }

  /* Tables — horizontal scroll */
  .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .ipcr-table { min-width: 600px; }

  /* Cards */
  .card-body { padding: 16px; }
  .card-header { padding: 12px 16px; }

  /* Metric cards */
  .metric-card { 
    padding: 18px 14px;
    min-height: 140px;
  }
  .metric-value { font-size: 1.8rem; }
  .metric-icon  { width: 44px; height: 44px; font-size: 1.2rem; }

  /* PA grid in ipcr-form */
  .pa-grid { grid-template-columns: 1fr; }
  .pa-half:first-child { border-right: none; border-bottom: 1px solid var(--gray-200); }
  .input-grid-3 { grid-template-columns: 1fr 1fr; }

  /* MFO headers */
  .mfo-section-header h5,
  .view-mfo-header h5 { font-size: .85rem; }

  /* Modal full-width on tablet */
  .modal-dialog { max-width: 92vw; margin: 10px auto; }
}

/* ── Mobile (max 767px) ── */
@media (max-width: 767px) {
  :root {
    --navbar-h: 56px;
    --border-r: 8px;
  }
  
  /* Prevent horizontal scroll globally */
  body {
    overflow-x: hidden;
    max-width: 100vw;
  }

  /* Sidebar — hidden by default, slide in */
  #sidebar {
    transform: translateX(-100%);
    width: 280px !important;
    box-shadow: none;
    transition: transform .22s ease, box-shadow .22s ease;
    max-width: 85vw;
  }

  body.sidebar-open #sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.25);
  }

  body.sidebar-open::after {
    content: '';
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 999;
    cursor: pointer;
  }

  #main-wrapper { margin-left: 0 !important; width: 100%; }

  /* Page content */
  #page-content { 
    padding: 12px;
    overflow-x: hidden;
    max-width: 100vw;
    width: 100%;
    box-sizing: border-box;
  }
  
  /* Ensure all direct children respect the container width */
  #page-content > * {
    max-width: 100%;
    box-sizing: border-box;
  }
  .sticky-actions  { margin: 0 -12px -12px; padding: 10px 12px; }
  .form-bottom-bar { margin: 0 -12px -12px; padding: 10px 12px; }

  /* Topbar */
  #topbar { padding: 0 12px; height: var(--navbar-h); }
  .topbar-user-name { display: none; }
  .topbar-user-role { display: none; }
  .topbar-title    { font-size: .82rem; }
  .topbar-user     { padding: 5px 8px; }
  .topbar-avatar { width: 36px; height: 36px; font-size: .8rem; }
  .btn-sidebar-toggle { font-size: 1.3rem; }

  /* Page header */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding-bottom: 14px;
    margin-bottom: 18px;
    max-width: 100%;
    box-sizing: border-box;
  }
  .page-header h1  { font-size: 1.15rem; }
  .page-header-left { width: 100%; max-width: 100%; }
  .page-header-right { width: 100%; max-width: 100%; }
  .page-header .d-flex { flex-wrap: wrap; gap: 6px !important; }
  .page-header .btn { font-size: .78rem; padding: 6px 12px; width: 100%; }

  /* Cards */
  .card-body   { padding: 16px; }
  .card-header { 
    padding: 12px 16px;
    padding-right: 50px !important; /* Ensure enough space for dropdown button */
    position: relative; /* Ensure dropdown positioning context */
    min-height: 46px; /* Ensure enough height for button */
  }
  .card-header h5,
  .card-header h6 { font-size: .85rem; }
  .card-footer { padding: 12px 16px; }
  
  /* Fix: Faculty dashboard Current IPCR Status card - prevent action button overlap */
  /* Ensure card-settings-btn dropdown button is properly positioned */
  .card-header .card-settings-btn,
  .card-header .btn-settings,
  .card-header .settings-button {
    position: absolute !important;
    top: 50% !important;
    right: 12px !important;
    transform: translateY(-50%) !important;
    z-index: 20 !important; /* Above card content */
    width: 36px;
    height: 26px;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .card-header .dropdown-menu {
    position: absolute !important;
    right: 12px !important;
    left: auto !important;
    top: calc(100% + 2px) !important;
    margin: 0 !important;
    min-width: 180px;
    z-index: 1050 !important; /* Bootstrap dropdown z-index */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
  }

  /* Metric cards — stack full width on mobile */
  .metric-card  { 
    padding: 16px 14px;
    min-height: 120px;
    aspect-ratio: auto; /* Remove square constraint on very small screens */
  }
  .metric-value { font-size: 1.6rem; }
  .metric-icon  { width: 40px; height: 40px; font-size: 1.1rem; margin-bottom: 10px; }
  .metric-label { font-size: .78rem; }

  /* Tables - Card layout for better mobile UX */
  .table-container { 
    overflow: visible;
    border-radius: 0;
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  
  /* Convert table to card layout on mobile */
  .ipcr-table {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: unset;
    overflow: visible;
    table-layout: auto;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  
  .ipcr-table thead,
  .ipcr-table tbody,
  .ipcr-table tr,
  .ipcr-table th,
  .ipcr-table td {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  
  .ipcr-table thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }
  
  .ipcr-table tbody {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
  }
  
  .ipcr-table tr {
    margin: 0 0 10px 0;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    padding: 8px;
    background: #fff;
    box-shadow: var(--shadow-xs);
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    transition: all .2s ease;
  }
  
  .ipcr-table tr:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--primary-light);
  }
  
  .ipcr-table td {
    border: none;
    padding: 8px 0;
    text-align: left;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
    min-height: auto;
    width: 100%;
    max-width: 100%;
    font-size: .85rem;
    overflow: hidden;
    box-sizing: border-box;
  }
  
  .ipcr-table td:before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--primary);
    font-size: .7rem;
    min-width: 100px;
    max-width: 100px;
    width: 100px;
    flex-shrink: 0;
    padding-top: 2px;
    line-height: 1.4;
    text-transform: uppercase;
    letter-spacing: 0.02em;
  }
  
  /* Hide labels for periods table - cleaner mobile view */
  .periods-table-no-labels td:before {
    display: none;
  }
  
  /* When labels are hidden, td should not have flex gap */
  .periods-table-no-labels td {
    gap: 0;
    padding-left: 0;
  }
  
  .ipcr-table td > * {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
  }
  
  /* Special handling for badge containers */
  .ipcr-table td > span.badge {
    flex: 0 0 auto;
    min-width: auto;
  }
  
  /* Div wrappers should not stretch badges */
  .ipcr-table td > div {
    flex: 0 0 auto;
    max-width: 100%;
  }
  
  .ipcr-table td > div > .badge {
    flex: none;
  }
  
  /* Make sure text content wraps properly */
  .ipcr-table td strong,
  .ipcr-table td span:not(.badge),
  .ipcr-table td div {
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    white-space: normal;
    max-width: 100%;
  }
  
  /* Badges - smaller and inline */
  .ipcr-table td .badge {
    width: auto !important;
    max-width: fit-content !important;
    display: inline-block !important;
    font-size: .6rem !important;
    padding: 2px 6px !important;
    line-height: 1.3 !important;
    white-space: nowrap;
    flex-shrink: 0;
  }
  
  /* Badge container div */
  .ipcr-table td div {
    display: inline-block;
    max-width: 100%;
  }
  
  /* Code elements (Employee ID) */
  .ipcr-table td code {
    font-size: .75rem;
    padding: 2px 6px;
    white-space: nowrap;
  }
  
  /* Text muted for evaluator and last login */
  .ipcr-table td .text-muted-sm {
    font-size: .72rem;
    line-height: 1.4;
    margin-top: 3px;
    word-wrap: break-word;
  }
  
  /* Hide inline evaluator on mobile - shown as separate row instead */
  .ipcr-table td .evaluator-inline {
    display: none !important;
  }
  
  /* Evaluator row - separate on mobile, show as block */
  .ipcr-table td.evaluator-row {
    display: flex !important; /* Override desktop display: none */
    padding: 6px 0;
    border-bottom: 1px dashed var(--gray-200);
    margin-bottom: 4px;
  }
  
  .ipcr-table td.evaluator-row .text-muted-sm {
    font-size: .75rem;
    color: var(--gray-600);
  }
  
  /* Actions row - two layouts: top-right (dashboard/history) or inline */
  
  /* DEFAULT: Top-right corner positioning (for dashboard & history pages) */
  .ipcr-table tbody tr {
    position: relative;
    padding: 12px;
    padding-right: 100px; /* Make room for buttons on the right */
  }
  
  .ipcr-table td.actions {
    position: absolute;
    top: 12px;
    right: 12px;
    width: auto !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    margin: 0;
  }
  
  .ipcr-table td.actions:before {
    display: none !important;
  }
  
  .ipcr-table td.actions .d-flex {
    flex-direction: row;
    gap: 4px;
    width: auto;
  }
  
  .ipcr-table td.actions .action-btn {
    width: auto;
    font-size: .72rem;
    padding: 7px 10px;
    white-space: nowrap;
    box-sizing: border-box;
    justify-content: center;
    align-items: center;
    border-width: 1px;
    margin: 0;
    line-height: 1;
    display: inline-flex;
    gap: 3px;
  }
  
  .ipcr-table td.actions .action-btn i {
    font-size: .7rem;
    margin: 0;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  
  .ipcr-table td.actions .action-btn span {
    font-size: .7rem;
    line-height: 1;
  }
  
  /* Dropdown menu positioning */
  .ipcr-table td.actions .dropdown {
    display: inline-block;
  }
  
  .ipcr-table td.actions .dropdown-toggle {
    width: auto;
    padding: 7px 10px;
    font-size: .72rem;
  }
  
  /* Ensure Period and other data don't overlap with buttons */
  .ipcr-table td[data-label="Period"],
  .ipcr-table td[data-label="Status"],
  .ipcr-table td[data-label="Rating"],
  .ipcr-table td[data-label="Adjectival"],
  .ipcr-table td[data-label="Academic Year"],
  .ipcr-table td[data-label="Submitted"],
  .ipcr-table td[data-label="Composite Rating"],
  .ipcr-table td[data-label="Adjectival Rating"],
  .ipcr-table td[data-label="Finalized"] {
    padding-right: 8px !important;
    max-width: calc(100% - 100px); /* Prevent text from going under buttons */
  }
  
  .ipcr-table td[data-label="Period"] strong {
    display: block;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
  
  /* View Only badge for secretary role */
  .ipcr-table td.actions .badge {
    width: auto !important;
    padding: 6px 14px !important;
    font-size: .75rem !important;
  }

  /* Filter bar */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    margin-left: 0;
    margin-right: 0;
  }
  .filter-bar > * { width: 100% !important; min-width: unset !important; max-width: 100% !important; box-sizing: border-box; }
  
  /* Search input full width on mobile */
  .filter-search-input,
  .filter-date-input {
    max-width: 100% !important;
    width: 100% !important;
  }
  
  .filter-bar .btn { width: 100%; max-width: 100%; box-sizing: border-box; }
  .filter-bar .form-control,
  .filter-bar .form-select { font-size: .85rem; max-width: 100%; box-sizing: border-box; }

  /* IPCR form header */
  .ipcr-form-header { padding: 16px 18px; }
  .ipcr-form-header h2 { font-size: 1rem; }
  .ipcr-form-header .meta { font-size: .75rem; gap: 8px; }
  .ipcr-form-header .meta span { padding: 4px 10px; font-size: .73rem; }

  /* IPCR page header */
  .ipcr-page-header  { padding: 14px 16px; flex-direction: column; }
  .ipcr-page-header h2 { font-size: .95rem; }
  .ipcr-meta { gap: 6px; flex-wrap: wrap; }
  .ipcr-meta-item { font-size: .72rem; padding: 3px 8px; }
  .progress-ring { width: 60px; height: 60px; }
  .progress-ring .num { font-size: 1.2rem; }

  /* View hero */
  .view-hero { padding: 16px; flex-direction: column; gap: 12px; }
  .view-hero h2 { font-size: 1rem; }
  .hero-chip { font-size: .7rem; padding: 3px 9px; }

  /* PA grid — stack vertical */
  .pa-grid { grid-template-columns: 1fr; }
  .pa-half:first-child { border-right: none; border-bottom: 1px solid var(--gray-200); }
  .pa-fields { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .input-grid-3 { grid-template-columns: 1fr; gap: 8px; }
  .input-grid-2 { grid-template-columns: 1fr; gap: 8px; }

  /* SI cards */
  .view-si-body  { padding: 14px; }
  .si-card-body  { padding: 14px; }
  .view-si-header { padding: 10px 14px; }
  .si-card-header { padding: 10px 14px; }
  .si-code { font-size: .7rem; }
  .si-target-pill { font-size: .68rem; padding: 3px 9px; }

  /* MFO/KRA headers */
  .mfo-section-header { padding: 12px 14px; }
  .mfo-section-header h5 { font-size: .85rem; }
  .mfo-header { padding: 12px 18px; }
  .mfo-header h6 { font-size: .85rem; }
  .view-mfo-header { padding: 10px 14px; }
  .view-mfo-header h5 { font-size: .82rem; }
  .kra-section-header { padding: 8px 14px; }
  .kra-header { padding: 8px 18px; }
  .kra-header h6 { font-size: .8rem; }
  .view-kra-header { padding: 7px 14px; }

  /* Evidence items */
  .evidence-item { padding: 12px; flex-direction: column; gap: 10px; }
  .ev-file-icon { width: 40px; height: 40px; font-size: 1.15rem; }
  .ev-filename { font-size: .82rem; }
  .ev-meta { font-size: .72rem; }
  .evidence-item .d-flex { flex-wrap: wrap; gap: 6px; }
  .evidence-item .btn { font-size: .73rem; padding: 5px 10px; }

  /* Rating summary */
  .composite-banner { flex-direction: column; gap: 8px; padding: 14px 16px; }
  .composite-num { font-size: 1.9rem; }
  .composite-label { font-size: .8rem; }
  .mfo-rating-row { padding: 10px 14px; flex-wrap: wrap; }
  .mfo-rating-row .rating-input { width: 56px; font-size: .9rem; }

  /* Bottom bar */
  .form-bottom-bar { 
    flex-direction: column; 
    align-items: stretch; 
    gap: 10px; 
    position: static;
    margin-top: 20px;
  }
  .form-bottom-bar .d-flex { justify-content: stretch; flex-wrap: wrap; }
  .form-bottom-bar .btn { flex: 1; text-align: center; min-width: 100%; }
  .progress-bar-wrap { max-width: 100%; }

  /* Sticky actions */
  .sticky-actions {
    flex-direction: column;
    gap: 8px;
    position: static;
    margin-top: 20px;
  }
  .sticky-actions .btn { width: 100%; }
  .sticky-actions .d-flex { width: 100%; }

  /* Modal */
  .modal-dialog { margin: 10px; max-width: calc(100vw - 20px); }
  .modal-content { border-radius: var(--border-r); }
  .modal-header { padding: 14px 16px; }
  .modal-title { font-size: .9rem; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
  .modal-footer .btn { flex: 1; min-width: 120px; }
  
  /* Password modal - keep buttons in one row */
  #passwordModal .modal-footer { flex-wrap: nowrap; }
  #passwordModal .modal-footer .btn { min-width: auto; }

  /* Forms */
  .form-label { font-size: .8rem; }
  .form-control, .form-select { font-size: .85rem; padding: 8px 12px; }
  .input-group-text { font-size: .85rem; }

  /* Deadline banner */
  .deadline-banner { flex-direction: column; gap: 6px; font-size: .8rem; padding: 12px; }
  .alert-deadline { padding: 12px 14px; font-size: .82rem; }

  /* Return alert */
  .return-alert { padding: 12px 14px; font-size: .82rem; }
  .alert-return { padding: 12px 14px; }

  /* Live score panel */
  .live-score-panel { 
    position: static; 
    margin-bottom: 16px; 
    padding: 18px; 
  }
  .lsp-composite { font-size: 2.2rem; }
  .lsp-adjectival { font-size: .88rem; }
  .lsp-table { font-size: .75rem; }

  /* Evidence section */
  .evidence-section { padding: 12px; }
  .btn-attach { padding: 6px 12px; font-size: .75rem; white-space: nowrap; }

  /* Toast notifications */
  #toast-container {
    top: calc(var(--navbar-h) + 10px);
    right: 10px;
    left: 10px;
    max-width: unset;
  }
  .toast-item {
    min-width: unset;
    width: 100%;
    padding: 12px 14px;
  }
  .toast-title { font-size: .82rem; }
  .toast-msg { font-size: .75rem; }

  /* Buttons in general */
  .btn { font-size: .82rem; padding: 8px 14px; }
  .btn-sm { font-size: .75rem; padding: 6px 10px; }
  .btn-lg { font-size: .9rem; padding: 10px 18px; }

  /* Bootstrap grid overrides - balanced spacing */
  .row { 
    margin-left: 0 !important; 
    margin-right: 0 !important; 
  }
  .row > * { 
    padding-left: 0;
    padding-right: 0;
  }
  
  /* Re-apply Bootstrap gap utilities with balanced padding */
  .row.g-1 > * { padding: 4px; }
  .row.g-2 > * { padding: 6px; }
  .row.g-3 > * { padding: 8px; }
  .row.g-4 > * { padding: 10px; }
  .row.g-5 > * { padding: 12px; }

  /* Hide some non-critical table columns on mobile */
  .hide-mobile { display: none !important; }

  /* Better touch targets */
  a, button, .btn, input[type="checkbox"], input[type="radio"] {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Adjust badge sizes */
  .badge { font-size: .7rem; padding: 3px 8px; }
  .late-badge { font-size: .65rem; padding: 2px 7px; }

  /* Evidence review cards */
  .ev-review-card { margin-bottom: 12px; }
  .ev-review-header { padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
  .ev-review-body { padding: 14px; }

  /* Status badges in tables */
  .ipcr-table .badge { white-space: nowrap; }
  
  /* Empty state message */
  .ipcr-table tr td[colspan] {
    padding: 40px 20px !important;
    text-align: center !important;
    font-size: .9rem;
  }
  
  .ipcr-table tr td[colspan]:before {
    display: none !important;
  }

  /* Pagination */
  .pagination { flex-wrap: wrap; gap: 4px; }
  .pagination .page-link { padding: 6px 10px; font-size: .75rem; }
  
  .pagination .page-item {
    margin: 0;
  }
  
  .pagination .page-link {
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* ── Small Mobile (max 480px) ── */
@media (max-width: 480px) {
  /* Further reduce spacing */
  #page-content { padding: 10px 10px 14px; }
  
  /* Ensure all direct children respect the tighter container width */
  #page-content > * {
    max-width: 100%;
    box-sizing: border-box;
  }
  
  .card-body { padding: 12px; }
  .card-header { padding: 10px 12px; }
  
  /* Typography */
  .ipcr-page-header h2 { font-size: .88rem; }
  .view-hero h2 { font-size: .9rem; }
  .page-header h1 { font-size: 1rem; }
  
  /* Metrics */
  .metric-value { font-size: 1.4rem; }
  .metric-icon { width: 36px; height: 36px; font-size: 1rem; }
  .metric-label { font-size: .72rem; }
  
  /* Tables - remove min-width for card layout */
  .ipcr-table { min-width: unset !important; font-size: .75rem; width: 100%; max-width: 100%; }
  .ipcr-table th { padding: 8px 8px; font-size: .65rem; }
  .ipcr-table td { padding: 8px 8px; }
  
  /* Filter bar - even tighter on very small screens */
  .filter-bar {
    padding: 10px;
    gap: 8px;
  }
  
  /* Table container - ensure no overflow */
  .table-container {
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100%;
  }
  
  .ipcr-table tr {
    padding: 10px;
    margin-bottom: 8px;
  }
  
  /* PA fields - 2 columns instead of 3 */
  .pa-fields { grid-template-columns: 1fr 1fr; gap: 6px; }
  
  /* Rating */
  .composite-num { font-size: 1.7rem; }
  .rating-input { width: 52px; font-size: .85rem; padding: 4px 2px; }
  
  /* Hide MFO badges on very small screens */
  .mfo-badge, .mfo-wt-badge { display: none; }
  
  /* Buttons */
  .btn { font-size: .78rem; padding: 7px 12px; }
  .btn-sm { font-size: .72rem; padding: 5px 9px; }
  
  /* Forms */
  .form-control, .form-select { font-size: .82rem; padding: 7px 10px; }
  .form-label { font-size: .78rem; }
  
  /* Toast */
  .toast-item { padding: 10px 12px; }
  .toast-title { font-size: .8rem; }
  .toast-msg { font-size: .73rem; }
  
  /* Evidence */
  .ev-file-icon { width: 36px; height: 36px; font-size: 1rem; }
  .ev-filename { font-size: .8rem; }
  .evidence-item { padding: 10px; }
  
  /* Modal */
  .modal-dialog { margin: 8px; }
  .modal-body { padding: 14px; }
  .modal-header { padding: 12px 14px; }
  .modal-footer { padding: 10px 14px; }
  
  /* IPCR form header */
  .ipcr-form-header { padding: 14px 16px; }
  .ipcr-form-header h2 { font-size: .92rem; }
  .ipcr-form-header .meta span { font-size: .7rem; padding: 3px 8px; }
  
  /* Live score panel */
  .lsp-composite { font-size: 1.9rem; }
  .lsp-adjectival { font-size: .82rem; }
  
  /* Sidebar - reduce width on very small screens */
  body.sidebar-open #sidebar { width: 260px !important; max-width: 80vw; }
}

/* ── SIDEBAR COLLAPSED (Desktop only) ── */
@media (min-width: 768px) {
  body.sidebar-collapsed #sidebar { width: 64px; }
  body.sidebar-collapsed #main-wrapper { margin-left: 64px; }
  body.sidebar-collapsed .sidebar-brand-text,
  body.sidebar-collapsed .sidebar-nav a span,
  body.sidebar-collapsed .sidebar-section-label,
  body.sidebar-collapsed .sidebar-footer { display: none; }
  body.sidebar-collapsed .sidebar-brand { padding: 14px 10px; justify-content: center; }
  body.sidebar-collapsed .sidebar-nav a { padding: 11px; justify-content: center; margin: 2px 6px; }
  body.sidebar-collapsed .sidebar-nav a.active::before { display: none; }
  body.sidebar-collapsed .sidebar-logo-img,
  body.sidebar-collapsed .sidebar-logo-fallback { width: 34px; height: 34px; }
  body.sidebar-collapsed #sidebar::before { height: 3px; }
}

/* ── PRINT ────────────────────────────────────────────────── */
@media print {
  #sidebar, #topbar, #toast-container, .sticky-actions,
  .form-bottom-bar, .filter-bar, .no-print,
  .btn, .btn-group, .nav { display: none !important; }
  #main-wrapper { margin-left: 0 !important; }
  #page-content { padding: 0 !important; }
  body { background: #fff !important; font-size: 10pt; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
  .table-container { overflow: visible !important; }
  .ipcr-table { min-width: unset !important; }
  table { border-collapse: collapse !important; width: 100%; }
  table th, table td { border: 1px solid #999 !important; padding: 4px 6px !important; font-size: 8pt; }
  .sig-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 32px; margin-top: 40px; }
  .sig-line { border-top: 1px solid #000; padding-top: 6px; text-align: center; font-size: 9pt; }
  .sig-name { font-weight: 700; }
  .page-break { page-break-before: always; }
  @page { size: A4 portrait; margin: 15mm; }
}


/* ── QUICK ACTION TILES ───────────────────────────────────── */
.quick-action-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 8px;
  border-radius: 10px;
  border: 1.5px solid var(--gray-200);
  background: #fff;
  text-decoration: none;
  transition: all .15s ease;
  cursor: pointer;
}

.quick-action-tile:hover {
  border-color: var(--primary);
  background: var(--primary-xlight);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(26,92,42,.1);
}

.qat-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.qat-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--gray-700);
  text-align: center;
  line-height: 1.2;
}

.quick-action-tile:hover .qat-label { color: var(--primary); }

/* ── STATUS COUNT CARDS ───────────────────────────────────── */
.status-count-card {
  background: #fff;
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  padding: 20px 12px;
  text-align: center;
  transition: all .15s ease;
  cursor: default;
  /* Make cards square and equal */
  aspect-ratio: 1 !important;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 140px;
}

.status-count-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,.1);
}

.status-count-icon {
  font-size: 1.8rem;
  margin-bottom: 10px;
  line-height: 1;
}

.status-count-num {
  font-size: 2.2rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.04em;
  margin-bottom: 8px;
}

.status-count-label {
  font-size: .74rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .05em;
  line-height: 1.2;
}

@media (max-width: 767px) {
  .status-count-card { 
    padding: 16px 10px;
    min-height: 120px;
  }
  .status-count-num  { font-size: 1.6rem; }
  .status-count-icon { font-size: 1.3rem; }
  .status-count-label{ font-size: .68rem; }
  
  /* Center the entire status cards section on mobile */
  .row.g-3.mb-4 {
    justify-content: center;
    text-align: center;
  }
  
  /* Compact Recent Activity table on mobile */
  .table-responsive .ipcr-table tr {
    padding: 8px;
    margin-bottom: 8px;
  }
  
  .table-responsive .ipcr-table td {
    padding: 3px 0;
    font-size: .75rem;
    gap: 6px;
  }
  
  .table-responsive .ipcr-table td:before {
    min-width: 60px;
    max-width: 60px;
    width: 60px;
    font-size: .6rem;
  }
  
  .table-responsive .ipcr-table td code {
    font-size: .7rem;
    padding: 1px 4px;
  }
  
  .table-responsive .ipcr-table td strong {
    font-size: .75rem;
  }
  
  .table-responsive .ipcr-table .text-muted-sm {
    font-size: .7rem;
  }
}

/* ── MODAL Z-INDEX FIX ────────────────────────────────────── */
.modal         { z-index: 1055 !important; }
.modal-backdrop{ z-index: 1054 !important; }

/* Bottom bar must be below modal */
.form-bottom-bar,
.sticky-actions { z-index: 100 !important; }

/* Modal dialog proper positioning */
.modal-dialog {
  margin-top: 80px;
}

.modal-header {
  padding: 14px 20px;
  align-items: center;
}

.modal-header .btn-close {
  margin-left: auto;
  flex-shrink: 0;
}

/* ── FILE PREVIEW MODAL ───────────────────────────────────── */
.preview-modal-body {
  padding: 0;
  height: 80vh;
  display: flex;
  flex-direction: column;
}

.preview-iframe {
  flex: 1;
  width: 100%;
  border: none;
  background: #f0f0f0;
}

.preview-img {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  padding: 16px;
}

.preview-unsupported {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  gap: 12px;
  color: var(--gray-500);
}

.preview-unsupported i { font-size: 3rem; }

/* ── TABLE ACTIONS COLUMN ─────────────────────────────────── */
.ipcr-table td.actions {
  white-space: nowrap;
  vertical-align: middle;
}

.ipcr-table td.actions .d-flex {
  flex-wrap: nowrap;
  align-items: center;
}

/* Keep action buttons consistent size */
.ipcr-table td.actions .btn-sm {
  font-size: .75rem;
  padding: 4px 10px;
  white-space: nowrap;
}

/* ── PAGINATION ──────────────────────────────────────────── */
.pagination-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: 1.5rem;
  padding: 1rem 0;
  border-top: 1px solid var(--gray-200);
  gap: 12px;
}

.pagination-info {
  font-size: .85rem;
  color: var(--gray-600);
  font-weight: 500;
  text-align: center;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pagination-pages {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0 0.5rem;
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: .85rem;
  font-weight: 600;
  color: var(--primary);
  background: #fff;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.2s;
}

.pagination-btn:hover:not(.disabled) {
  background: var(--primary-xlight);
  border-color: var(--primary);
  color: var(--primary);
}

.pagination-btn.disabled {
  color: var(--gray-400);
  cursor: not-allowed;
  opacity: 0.5;
}

.pagination-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 0.5rem;
  font-size: .85rem;
  font-weight: 500;
  color: var(--gray-700);
  background: #fff;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.2s;
}

.pagination-page:hover:not(.active) {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.pagination-page.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 700;
  cursor: default;
}

.pagination-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  color: var(--gray-400);
  font-weight: 700;
}

.pagination-compact {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1rem;
  padding: 0.75rem 0;
}

/* ── PAGINATION MOBILE RESPONSIVE ──────────────────────────── */
@media (max-width: 767px) {
  .pagination-wrapper {
    padding: 12px 0;
    gap: 8px;
  }
  
  .pagination-info {
    font-size: 0.75rem;
  }
  
  .pagination-controls {
    gap: 0.25rem;
    width: 100%;
    justify-content: space-between;
  }
  
  .pagination-pages {
    gap: 0.15rem;
    margin: 0 0.25rem;
    flex: 1;
    justify-content: center;
  }
  
  /* Smaller buttons on mobile */
  .pagination-btn {
    padding: 0.4rem 0.7rem !important;
    font-size: 0.75rem !important;
    min-width: auto !important;
    white-space: nowrap;
    gap: 0.3rem !important;
  }
  
  .pagination-btn i {
    font-size: 0.7rem !important;
  }
  
  /* Smaller page numbers on mobile */
  .pagination-page {
    min-width: 28px !important;
    height: 28px !important;
    padding: 0 0.3rem !important;
    font-size: 0.75rem !important;
  }
  
  /* Smaller ellipsis */
  .pagination-ellipsis {
    min-width: 24px !important;
    height: 28px !important;
    font-size: 0.75rem !important;
  }
}

/* Extra small phones - even more compact */
@media (max-width: 480px) {
  .pagination-btn {
    padding: 0.35rem 0.5rem !important;
    font-size: 0.7rem !important;
    border-radius: 4px;
  }
  
  .pagination-btn i {
    font-size: 0.65rem !important;
  }
  
  .pagination-page {
    min-width: 26px !important;
    height: 26px !important;
    font-size: 0.7rem !important;
    border-radius: 4px;
  }
  
  .pagination-ellipsis {
    min-width: 20px !important;
    height: 26px !important;
  }
  
  .pagination-info {
    font-size: 0.7rem !important;
  }
}

/* Legacy pagination styles (keep for backward compatibility) */
.pagination {
  display: flex;
  list-style: none;
  padding: 0;
  margin: 0;
  gap: 5px;
}

.page-item {
  list-style: none;
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: var(--primary);
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s ease;
  min-width: 40px;
  min-height: 40px;
}

.page-link:hover {
  background: var(--primary-xlight);
  border-color: var(--primary);
  color: var(--primary-dark);
}

.page-item.active .page-link {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  cursor: default;
}

.page-item.disabled .page-link {
  color: #9ca3af;
  pointer-events: none;
  background: #f9fafb;
  border-color: #e5e7eb;
}



/* ============================================================
   SYSTEM FOOTER - Developer Credits
   ============================================================ */

.system-footer {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: white;
  padding: 24px 32px;
  margin-top: auto;
  border-top: 3px solid var(--accent);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
}

.footer-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.footer-left p {
  margin: 0;
  line-height: 1.6;
}

.footer-left strong {
  font-size: 1rem;
  font-weight: 700;
  color: white;
}

.footer-right {
  text-align: right;
}

.footer-right p {
  margin: 0;
  line-height: 1.8;
}

.footer-right .text-muted {
  color: rgba(255, 255, 255, 0.8) !important;
}

.footer-right strong {
  color: var(--accent-light);
  font-weight: 600;
}

.footer-right i {
  color: var(--accent);
}

/* Make footer stick to bottom */
.main-wrapper {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--navbar-h));
}

.page-content {
  flex: 1;
  padding-bottom: 0;
}

/* Responsive */
@media (max-width: 768px) {
  .system-footer {
    padding: 20px 16px;
  }
  
  .footer-content {
    flex-direction: column;
    text-align: center;
    gap: 16px;
  }
  
  .footer-right {
    text-align: center;
  }
}

/* Print: Hide footer */
@media print {
  .system-footer {
    display: none;
  }
}


/* ── MOBILE-SPECIFIC IMPROVEMENTS ─────────────────────────── */

/* Better touch targets */
.touch-device a,
.touch-device button,
.touch-device .btn,
.touch-device input[type="checkbox"],
.touch-device input[type="radio"] {
  min-height: 44px;
  min-width: 44px;
}

/* Smooth horizontal scroll for tables */
.table-container.grabbing {
  cursor: grabbing;
  user-select: none;
}

/* Better form inputs on mobile */
@media (max-width: 767px) {
  input, textarea, select {
    font-size: 16px !important; /* Prevents zoom on iOS */
  }
  
  /* IPCR Templates Mobile Optimization */
  /* Fix container overflow */
  .mfo-body,
  .kra-block,
  .kra-block .p-3 {
    overflow: visible !important;
    width: 100% !important;
  }
  
  /* Ensure cards don't get cut off */
  .col-lg-9,
  .card-body {
    overflow: visible !important;
    padding-left: 8px !important;
    padding-right: 8px !important;
  }
  
  /* Increase page padding for templates page */
  body.templates-page #page-content {
    padding: 14px 8px 20px !important;
  }
  
  /* Table container needs more space */
  .ipcr-table,
  .table-container {
    margin-left: 0;
    margin-right: 0;
    max-width: 100%;
  }
  
  /* Make all template inputs full width on mobile */
  .mfo-body .row.g-1 .col-2,
  .mfo-body .row.g-1 .col-3,
  .mfo-body .row.g-1 .col-4,
  .mfo-body .row.g-1 .col-5,
  .mfo-body .row.g-1 .col-6,
  .mfo-body .row.g-2 .col-md-2,
  .mfo-body .row.g-2 .col-md-3,
  .mfo-body .row.g-2 .col-md-5,
  .p-3.bg-light.border-top .row.g-2 .col-2,
  .p-3.bg-light.border-top .row.g-2 .col-3,
  .p-3.bg-light.border-top .row.g-2 .col-5,
  form.mb-4.p-3 .row.g-2 .col-md-2,
  form.mb-4.p-3 .row.g-2 .col-md-3,
  form.mb-4.p-3 .row.g-2 .col-md-5 {
    width: 100%;
    max-width: 100%;
    flex: 0 0 100%;
  }
  
  /* Stack form controls vertically */
  .mfo-body .row.g-1,
  .mfo-body .row.g-2,
  .p-3.bg-light.border-top .row.g-2,
  form.mb-4.p-3 .row.g-2 {
    row-gap: 8px;
  }
  
  /* Make buttons full width */
  .mfo-body button.btn,
  .p-3.bg-light.border-top button.btn,
  form.mb-4.p-3 button.btn {
    width: 100%;
  }
  
  /* Improve input visibility */
  .mfo-body input.form-control,
  .mfo-body input.form-control-sm,
  .p-3.bg-light.border-top input.form-control,
  .p-3.bg-light.border-top input.form-control-sm,
  form.mb-4.p-3 input.form-control,
  form.mb-4.p-3 input.form-control-sm {
    min-height: 44px;
    padding: 8px 12px;
    font-size: 16px !important;
  }
  
  /* Adjust input groups on mobile */
  .mfo-body .input-group,
  .p-3.bg-light.border-top .input-group,
  form.mb-4.p-3 .input-group {
    width: 100%;
  }
  
  /* Better checkbox spacing */
  .mfo-body .form-check {
    margin-top: 8px;
    margin-bottom: 8px;
  }
  
  /* Keep checkbox size reasonable on mobile */
  .form-check-input {
    width: 18px !important;
    height: 18px !important;
    min-height: auto !important;
  }
  
  .mfo-body .form-check-input,
  .p-3.bg-light .form-check-input {
    width: 16px !important;
    height: 16px !important;
  }
  
  .form-check-label {
    font-size: 0.875rem !important;
    line-height: 1.4;
  }
  
  /* Improve table on mobile for templates */
  .ipcr-table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow: visible !important;
    -webkit-overflow-scrolling: touch;
    margin: 0;
  }
  
  .ipcr-table thead,
  .ipcr-table tbody,
  .ipcr-table tr,
  .ipcr-table th,
  .ipcr-table td {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  
  .ipcr-table thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }
  
  .ipcr-table tbody {
    width: 100%;
    max-width: 100%;
  }
  
  .ipcr-table tr {
    margin: 0 0 16px 0;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    background: #fff;
    width: 100%;
    max-width: 100%;
    display: block;
    overflow: visible;
    box-sizing: border-box;
  }
  
  .ipcr-table td {
    border: none;
    padding: 8px 0;
    text-align: left;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 12px;
    min-height: 32px;
    width: 100%;
    max-width: 100%;
    overflow: visible;
    box-sizing: border-box;
  }
  
  .ipcr-table td:before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.72rem;
    min-width: 75px;
    max-width: 75px;
    flex-shrink: 0;
    padding-top: 2px;
    line-height: 1.3;
  }
  
  .ipcr-table td > span {
    flex: 1;
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: normal;
    max-width: 100%;
    width: 100%;
    font-size: 0.85rem;
    line-height: 1.4;
    box-sizing: border-box;
  }
  
  /* Special handling for last td (Actions) */
  .ipcr-table td:last-child {
    border-top: 1px solid #e5e7eb;
    margin-top: 8px;
    padding-top: 12px;
    justify-content: center;
  }
  
  .ipcr-table td:last-child:before {
    display: none;
  }
  
  .ipcr-table td:last-child > form,
  .ipcr-table td:last-child > button {
    width: auto;
    flex: 0;
  }
  
  /* Ensure badges display properly */
  .ipcr-table .badge {
    display: inline-block;
    white-space: nowrap;
    font-size: 0.7rem;
  }
  
  /* KRA and MFO containers */
  .kra-block,
  .mfo-accordion {
    width: 100%;
    max-width: 100%;
    overflow: visible;
    box-sizing: border-box;
  }
  
  /* Stack buttons vertically by default */
  .btn-group-mobile {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  
  .btn-group-mobile .btn {
    width: 100%;
  }
  
  /* Better spacing for mobile forms */
  .form-group-mobile {
    margin-bottom: 16px;
  }
  
  /* Improve modal on mobile */
  .modal-fullscreen-mobile {
    max-width: 100%;
    margin: 0;
    height: 100vh;
  }
  
  .modal-fullscreen-mobile .modal-content {
    height: 100%;
    border-radius: 0;
  }
  
  /* Better card spacing */
  .card + .card {
    margin-top: 16px;
  }
  
  /* Dashboard cards - ensure equal margins */
  .card {
    margin-left: 0;
    margin-right: 0;
    width: 100%;
    box-sizing: border-box;
  }
  
  /* Dashboard row g-4 - remove extra padding on mobile for full-width cards */
  .row.g-4 > .col-lg-4,
  .row.g-4 > .col-lg-8 {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  
  /* Ensure card spacing between stacked cards */
  .row.g-4 > .col-lg-4 .card,
  .row.g-4 > .col-lg-8 .card {
    margin-bottom: 16px;
  }
  
  /* Improve table scrolling indicators */
  .table-container {
    position: relative;
  }
  
  .table-container::after {
    content: '→';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.9));
    padding: 8px 12px;
    font-size: 1.2rem;
    color: var(--primary);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
  }
  
  .table-container.has-scroll::after {
    opacity: 1;
  }
  
  /* Better overflow menu for mobile */
  .overflow-menu-mobile {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid var(--gray-200);
    padding: 12px;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
    z-index: 1050;
  }
  
  /* Improve file upload button */
  .btn-attach-mobile {
    width: 100%;
    padding: 12px;
    font-size: 0.9rem;
  }
  
  /* Better evidence list on mobile */
  .evidence-item {
    border-radius: var(--border-r-sm);
  }
  
  .evidence-item .btn-group {
    flex-wrap: wrap;
    gap: 4px;
  }
  
  .evidence-item .btn-sm {
    flex: 1;
    min-width: 80px;
  }
}

/* Landscape mobile improvements */
@media (max-width: 767px) and (orientation: landscape) {
  #page-content {
    padding: 10px;
  }
  
  .page-header {
    margin-bottom: 12px;
    padding-bottom: 10px;
  }
  
  .page-header h1 {
    font-size: 1rem;
  }
  
  .card-body {
    padding: 12px;
  }
  
  .metric-card {
    padding: 12px;
    min-height: 110px;
  }
  
  .metric-icon {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
    margin-bottom: 6px;
  }
  
  .metric-value {
    font-size: 1.3rem;
  }
}

/* iOS-specific fixes */
@supports (-webkit-touch-callout: none) {
  /* Fix iOS input zoom */
  input, textarea, select {
    font-size: 16px !important;
  }
  
  /* Fix iOS sticky header */
  #topbar {
    -webkit-transform: translateZ(0);
  }
  
  /* Fix iOS Safari bottom bar overlap */
  @media (max-width: 767px) {
    body {
      padding-bottom: env(safe-area-inset-bottom);
    }
    
    .sticky-actions,
    .form-bottom-bar {
      padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }
  }
}

/* Dark mode improvements for mobile (optional) */
@media (prefers-color-scheme: dark) and (max-width: 767px) {
  /* Future enhancement: Add dark mode support */
}


/* ── Additional Mobile Optimization for Submission Cards ── */
@media (max-width: 480px) {
  .submission-stat-card {
    padding: 8px 6px !important;
    min-height: 85px !important;
    max-height: 100px !important;
    aspect-ratio: 1 / 1 !important;
  }
  
  .submission-tracking-row > [class*='col-'] {
    max-width: 120px !important;
  }
  
  .submission-tracking-row a {
    aspect-ratio: 1 / 1 !important;
  }
  
  .submission-stat-icon {
    font-size: 18px !important;
    margin-bottom: 4px !important;
  }
  
  .submission-stat-value {
    font-size: 20px !important;
    margin-bottom: 2px !important;
  }
  
  .submission-stat-label {
    font-size: 8.5px !important;
    line-height: 1.1 !important;
  }
  
  .metric-value { font-size: 1.3rem; }
  .metric-icon { width: 32px; height: 32px; font-size: .95rem; }
  .metric-label { font-size: .68rem; }
}

@media (max-width: 576px) {
  .submission-stat-card {
    padding: 10px 8px !important;
    min-height: 90px !important;
    aspect-ratio: 1 / 1 !important;
  }
  
  .submission-tracking-row a {
    aspect-ratio: 1 / 1 !important;
  }
  
  .submission-stat-icon {
    font-size: 20px !important;
    margin-bottom: 5px !important;
  }
  
  .submission-stat-value {
    font-size: 22px !important;
    margin-bottom: 3px !important;
  }
  
  .submission-stat-label {
    font-size: 9px !important;
    line-height: 1.15 !important;
  }
}

@media (max-width: 640px) {
  .submission-stat-card {
    padding: 12px 10px !important;
    min-height: 100px !important;
    aspect-ratio: 1 / 1 !important;
  }
  
  .submission-tracking-row a {
    aspect-ratio: 1 / 1 !important;
  }
  
  .submission-stat-icon {
    font-size: 24px !important;
    margin-bottom: 6px !important;
  }
  
  .submission-stat-value {
    font-size: 24px !important;
    margin-bottom: 4px !important;
  }
  
  .submission-stat-label {
    font-size: 10px !important;
    line-height: 1.2 !important;
  }
}


/* Force equal heights for submission cards */
.submission-stat-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Ensure parent columns are same height */
.submission-tracking-row {
  display: flex;
  flex-wrap: wrap;
}

.submission-tracking-row > [class*='col-'] {
  display: flex;
}

.submission-tracking-row a {
  width: 100%;
  display: flex;
}


/* ── DEPARTMENTS PAGE - MOBILE COMPACT LAYOUT ──────────────── */

/* ══════════════════════════════════════════════════════════
   DEPARTMENT ACTIONS - RESPONSIVE BUTTON LAYOUT
   ══════════════════════════════════════════════════════════ */

/* Desktop: Show normal action buttons, hide settings icon */
.dept-action-mobile {
  display: none;
}

.dept-action-desktop {
  display: inline-block !important;
  position: relative;
  z-index: 10;
  cursor: pointer;
}

.dept-action-desktop form {
  display: inline-block;
  margin: 0;
  position: relative;
  z-index: 10;
  pointer-events: auto !important;
}

/* Ensure form doesn't block hover */
.ipcr-table tbody tr:hover .dept-action-desktop form {
  z-index: 20;
}

.dept-action-desktop .btn,
.dept-action-desktop form .btn {
  cursor: pointer;
  pointer-events: auto !important;
  position: relative;
  z-index: 10;
}

/* Ensure delete button hover works properly */
.dept-action-desktop form .btn-outline-danger {
  transition: all 0.15s ease;
}

.ipcr-table .dept-action-desktop form .btn-outline-danger:hover:not(:disabled),
.dept-action-desktop form .btn-outline-danger:hover:not(:disabled) {
  background-color: #dc3545 !important;
  border-color: #dc3545 !important;
  color: white !important;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(220, 53, 69, 0.3);
}

.ipcr-table .dept-action-desktop .btn-outline-primary:hover:not(:disabled),
.dept-action-desktop .btn-outline-primary:hover:not(:disabled) {
  background-color: #0d6efd !important;
  border-color: #0d6efd !important;
  color: white !important;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(13, 110, 253, 0.3);
}

/* Ultra specific selector for stubborn Bootstrap overrides */
.ipcr-table tbody tr td.dept-actions .dept-action-desktop form button.btn-outline-danger:hover {
  background-color: #dc3545 !important;
  border-color: #dc3545 !important;
  color: #fff !important;
}

.ipcr-table tbody tr td.dept-actions .dept-action-desktop button.btn-outline-primary:hover {
  background-color: #0d6efd !important;
  border-color: #0d6efd !important;
  color: #fff !important;
}

.ipcr-table td.dept-actions {
  white-space: nowrap;
  vertical-align: middle;
  position: relative;
  z-index: 5;
}

.ipcr-table td.dept-actions > div {
  position: relative;
  z-index: 10;
  pointer-events: auto;
}

/* Mobile view optimizations */
@media (max-width: 768px) {
  /* Hide desktop action buttons, show mobile settings button */
  .dept-action-desktop {
    display: none !important;
  }
  
  .dept-action-mobile {
    display: inline-block !important;
    position: relative;
    z-index: 100;
  }
  
  /* Compact department cards with relative positioning for settings button */
  .ipcr-table tr {
    padding: 12px 12px 12px 12px !important;
    margin-bottom: 12px !important;
    position: relative;
    overflow: visible !important; /* CRITICAL: Allow button to be visible immediately */
  }
  
  .ipcr-table td {
    padding: 4px 0 !important;
    font-size: 0.85rem;
  }
  
  .ipcr-table td:before {
    min-width: 85px;
    max-width: 85px;
    font-size: 0.75rem;
  }
  
  /* Actions row - position in top right corner */
  .ipcr-table td.dept-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    border: none;
    margin: 0;
    padding: 0 !important;
    width: auto;
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
    z-index: 101; /* Above the tr */
    pointer-events: none; /* Allow clicks to pass through the container */
  }
  
  /* Override hover state on mobile - keep absolute positioning */
  .ipcr-table tbody tr:hover td.dept-actions {
    position: absolute !important; /* Don't change to relative on mobile */
    top: 8px;
    right: 8px;
  }
  
  .ipcr-table td.dept-actions:before {
    display: none;
  }
  
  .dept-action-mobile {
    width: 32px; /* Fixed width for square */
    height: 32px; /* Fixed height for square */
    padding: 0; /* Remove padding for perfect square */
    font-size: 0.8rem;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex !important; /* Use flexbox for centering */
    align-items: center;
    justify-content: center;
    transition: none !important; /* Remove any transition delays */
    pointer-events: auto; /* Re-enable clicks on the button itself */
    position: relative; /* Ensure it's in its own stacking context */
    touch-action: manipulation; /* Improve touch response */
  }
  
  .dept-action-mobile:hover {
    background: var(--gray-50);
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
  }
  
  .dept-action-mobile i {
    font-size: 0.95rem;
    margin: 0;
  }
  
  /* Add padding-right to first row to avoid overlap with settings button */
  .ipcr-table td[data-label="#"] {
    padding-right: 45px !important;
  }
  
  /* Department name styling */
  .ipcr-table td[data-label="Department"] strong {
    font-size: 0.95rem;
    color: var(--primary);
  }
  
  /* Badge sizing */
  .ipcr-table td .badge {
    font-size: 0.75rem;
    padding: 4px 8px;
  }
  
  /* Code tag (abbreviation) */
  .ipcr-table td code {
    font-size: 0.75rem;
    padding: 2px 6px;
  }
}

/* Very small screens - even more compact */
@media (max-width: 480px) {
  .ipcr-table tr {
    padding: 10px 10px 10px 10px !important;
    margin-bottom: 10px !important;
  }
  
  .ipcr-table td {
    padding: 3px 0 !important;
    font-size: 0.8rem;
  }
  
  .ipcr-table td:before {
    min-width: 75px;
    max-width: 75px;
    font-size: 0.7rem;
  }
  
  .ipcr-table td[data-label="Department"] strong {
    font-size: 0.9rem;
  }
  
  /* Settings button slightly smaller on very small screens */
  .dept-action-mobile {
    width: 30px; /* Slightly smaller square for small screens */
    height: 30px;
    padding: 0;
    font-size: 0.75rem;
  }
  
  .dept-action-mobile i {
    font-size: 0.85rem;
  }
  
  /* Adjust padding for number column */
  .ipcr-table td[data-label="#"] {
    padding-right: 40px !important;
  }
  
  /* Position settings button */
  .ipcr-table td.dept-actions {
    top: 6px;
    right: 6px;
  }
}


/* ══════════════════════════════════════════════════════════
   USER ACTIONS - RESPONSIVE BUTTON LAYOUT
   ══════════════════════════════════════════════════════════ */

/* Desktop: Show normal action buttons, hide settings icon */
.user-action-mobile {
  display: none;
}

.user-action-desktop {
  display: inline-block !important;
  position: relative;
  z-index: 10;
  cursor: pointer;
}

.ipcr-table td.user-actions {
  white-space: nowrap;
  vertical-align: middle;
  position: relative;
  z-index: 5;
}

.ipcr-table td.user-actions .action-form {
  display: inline-block;
  margin: 0;
  position: relative;
  z-index: 10;
}

.ipcr-table td.user-actions .action-btn {
  position: relative;
  z-index: 10;
  pointer-events: auto !important;
  cursor: pointer;
}

/* Mobile view optimizations */
@media (max-width: 768px) {
  /* Hide desktop action buttons, show mobile settings button */
  .user-action-desktop {
    display: none !important;
  }
  
  .user-action-mobile {
    display: inline-block !important;
  }
  
  /* Compact user cards with relative positioning for settings button */
  .ipcr-table tr {
    padding: 12px 12px 12px 12px !important;
    margin-bottom: 12px !important;
    position: relative;
  }
  
  .ipcr-table td {
    padding: 4px 0 !important;
    font-size: 0.85rem;
  }
  
  .ipcr-table td:before {
    min-width: 85px;
    max-width: 85px;
    font-size: 0.75rem;
  }
  
  /* Actions row - position in top right corner */
  .ipcr-table td.user-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    border: none;
    margin: 0;
    padding: 0 !important;
    width: auto;
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
    pointer-events: none; /* Allow clicks to pass through the container */
  }
  
  /* Override hover state on mobile - keep absolute positioning */
  .ipcr-table tbody tr:hover td.user-actions {
    position: absolute !important; /* Don't change to relative on mobile */
    top: 8px;
    right: 8px;
  }
  
  .ipcr-table td.user-actions:before {
    display: none;
  }
  
  .user-action-mobile {
    width: auto;
    padding: 6px 10px;
    font-size: 0.8rem;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    pointer-events: auto; /* Re-enable clicks on the button itself */
    position: relative; /* Ensure it's in its own stacking context */
    touch-action: manipulation; /* Improve touch response */
    transition: none !important; /* Remove any transition delays */
  }
  
  .user-action-mobile:hover {
    background: var(--gray-50);
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
  }
  
  .user-action-mobile i {
    font-size: 0.9rem;
    margin: 0;
  }
  
  /* Add padding-right to first row to avoid overlap with settings button */
  .ipcr-table td[data-label="Employee ID"] {
    padding-right: 45px !important;
  }
  
  /* User name styling */
  .ipcr-table td[data-label="Name"] strong {
    font-size: 0.95rem;
    color: var(--primary);
  }
  
  /* Badge sizing */
  .ipcr-table td .badge {
    font-size: 0.75rem;
    padding: 4px 8px;
  }
  
  /* Code tag (employee ID) */
  .ipcr-table td code {
    font-size: 0.75rem;
    padding: 2px 6px;
  }
  
  /* Evaluator info compact */
  .ipcr-table td .text-muted-sm {
    font-size: 0.72rem;
  }
}

/* Very small screens - even more compact */
@media (max-width: 480px) {
  .ipcr-table tr {
    padding: 10px 10px 10px 10px !important;
    margin-bottom: 10px !important;
  }
  
  .ipcr-table td {
    padding: 3px 0 !important;
    font-size: 0.8rem;
  }
  
  .ipcr-table td:before {
    min-width: 75px;
    max-width: 75px;
    font-size: 0.7rem;
  }
  
  .ipcr-table td[data-label="Name"] strong {
    font-size: 0.9rem;
  }
  
  /* Settings button slightly smaller on very small screens */
  .user-action-mobile {
    padding: 5px 8px;
    font-size: 0.75rem;
  }
  
  .user-action-mobile i {
    font-size: 0.85rem;
  }
  
  /* Adjust padding for employee ID column */
  .ipcr-table td[data-label="Employee ID"] {
    padding-right: 40px !important;
  }
  
  /* Position settings button */
  .ipcr-table td.user-actions {
    top: 6px;
    right: 6px;
  }
}


/* ══════════════════════════════════════════════════════════
   PERIOD ACTIONS - MOBILE RESPONSIVE BUTTON
   ══════════════════════════════════════════════════════════ */

/* Desktop: Show normal action buttons, hide settings icon */
.period-action-mobile {
  display: none;
}

.period-action-desktop {
  display: flex;
}

/* Mobile: Hide action buttons, show settings icon */
@media (max-width: 767px) {
  .ipcr-table tbody tr {
    position: relative;
  }
  
  .period-action-desktop {
    display: none !important;
  }
  
  .period-action-mobile {
    display: inline-block !important;
    position: relative;
  }
  
  /* Actions row - position in top right corner */
  .ipcr-table td.period-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    border: none;
    margin: 0;
    padding: 0 !important;
    width: auto;
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
    z-index: 101;
    pointer-events: none;
  }
  
  /* Override hover state on mobile - keep absolute positioning */
  .ipcr-table tbody tr:hover td.period-actions {
    position: absolute !important;
    top: 8px;
    right: 8px;
  }
  
  .ipcr-table td.period-actions:before {
    display: none;
  }
  
  .period-action-mobile {
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 0.8rem;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: none !important;
    pointer-events: auto;
    position: relative;
    touch-action: manipulation;
  }
  
  .period-action-mobile:hover {
    background: var(--gray-50);
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
  }
  
  .period-action-mobile i {
    font-size: 0.95rem;
    margin: 0;
  }
  
  /* Add padding-right to first row to avoid overlap with settings button */
  .ipcr-table td[data-label="Period"] {
    padding-right: 45px !important;
  }
}

/* Very small screens - smaller settings button */
@media (max-width: 480px) {
  .period-action-mobile {
    width: 30px;
    height: 30px;
  }
  
  .period-action-mobile i {
    font-size: 0.85rem;
  }
  
  /* Position settings button */
  .ipcr-table td.period-actions {
    top: 6px;
    right: 6px;
  }
}


/* ── USER MODAL - MOBILE OPTIMIZATION ──────────────────────── */

/* Mobile optimization for user modal */
@media (max-width: 768px) {
  /* Make modal responsive on mobile */
  #userModal .modal-dialog {
    margin: 0.5rem;
    max-width: calc(100% - 1rem);
  }
  
  #userModal .modal-content {
    max-height: calc(100vh - 1rem);
    border-radius: var(--border-r);
  }
  
  #userModal .modal-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
  }
  
  #userModal .modal-title {
    font-size: 1rem;
    font-weight: 600;
  }
  
  #userModal .modal-body {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
  }
  
  #userModal .modal-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--gray-200);
    gap: 8px;
  }
  
  #userModal .modal-footer .btn {
    flex: 1;
    padding: 10px 16px;
    font-size: 0.9rem;
  }
  
  /* Compact form fields */
  #userModal .form-label {
    font-size: 0.85rem;
    margin-bottom: 4px;
    font-weight: 500;
  }
  
  #userModal .form-control,
  #userModal .form-select {
    font-size: 0.9rem;
    padding: 8px 12px;
  }
  
  #userModal .form-text {
    font-size: 0.75rem;
    margin-top: 4px;
  }
  
  #userModal .required-star {
    font-size: 0.75rem;
  }
  
  /* Reduce gaps in form rows */
  #userModal .row.g-3 {
    row-gap: 12px !important;
    column-gap: 8px !important;
  }
  
  /* Make all columns full width on mobile except special cases */
  #userModal .col-md-4,
  #userModal .col-md-6,
  #userModal .col-md-3,
  #userModal .col-md-1,
  #userModal .col-12 {
    flex: 0 0 100%;
    max-width: 100%;
  }
  
  /* Keep first name and last name side by side */
  #userModal .col-md-4:has(#fn-field),
  #userModal .col-md-3:has(#ln-field) {
    flex: 0 0 calc(50% - 4px);
    max-width: calc(50% - 4px);
  }
  
  /* Hide suffix on very small screens or make it small */
  #userModal .col-md-1:has(#sx-field) {
    flex: 0 0 100%;
    max-width: 100%;
  }
  
  /* Feedback messages smaller */
  #userModal .invalid-feedback,
  #userModal .valid-feedback {
    font-size: 0.75rem;
  }
  
  /* Badges in info text */
  #userModal .badge {
    font-size: 0.7rem;
    padding: 3px 6px;
  }
}

/* Very small screens - even more compact */
@media (max-width: 480px) {
  #userModal .modal-header {
    padding: 10px 12px;
  }
  
  #userModal .modal-body {
    padding: 12px;
  }
  
  #userModal .modal-footer {
    padding: 10px 12px;
  }
  
  #userModal .modal-title {
    font-size: 0.95rem;
  }
  
  #userModal .form-label {
    font-size: 0.8rem;
  }
  
  #userModal .form-control,
  #userModal .form-select {
    font-size: 0.85rem;
    padding: 7px 10px;
  }
  
  #userModal .row.g-3 {
    row-gap: 10px !important;
  }
  
  /* Stack first name and last name on very small screens */
  #userModal .col-md-4:has(#fn-field),
  #userModal .col-md-3:has(#ln-field) {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

/* Smooth scrolling for modal body */
#userModal .modal-body {
  scroll-behavior: smooth;
}

/* Style scrollbar in modal (webkit browsers) */
#userModal .modal-body::-webkit-scrollbar {
  width: 6px;
}

#userModal .modal-body::-webkit-scrollbar-track {
  background: var(--gray-100);
}

#userModal .modal-body::-webkit-scrollbar-thumb {
  background: var(--gray-400);
  border-radius: 3px;
}

#userModal .modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--gray-500);
}


/* ── ACTIONS MODALS - COMPACT SIZE ──────────────────────────── */

/* Make user actions modal smaller and more compact */
#userActionsModal .modal-dialog,
#deptActionsModal .modal-dialog {
  max-width: 340px;
}

#confirmActionModal .modal-dialog {
  max-width: 420px;
}

#userActionsModal .modal-header,
#deptActionsModal .modal-header,
#confirmActionModal .modal-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-200);
}

#userActionsModal .modal-title,
#deptActionsModal .modal-title,
#confirmActionModal .modal-title {
  font-size: 0.95rem;
  font-weight: 600;
}

#userActionsModal .modal-body,
#deptActionsModal .modal-body {
  padding: 14px;
}

#confirmActionModal .modal-body {
  padding: 16px;
}

#userActionsModal .modal-body h6,
#deptActionsModal .modal-body h6 {
  font-size: 0.9rem;
  margin-bottom: 3px;
  font-weight: 600;
}

#userActionsModal .modal-body small,
#deptActionsModal .modal-body small {
  font-size: 0.75rem;
  line-height: 1.3;
  display: block;
}

#userActionsModal .modal-body .mb-3,
#deptActionsModal .modal-body .mb-3 {
  margin-bottom: 12px !important;
}

#userActionsModal .d-grid,
#deptActionsModal .d-grid {
  gap: 7px !important;
}

#userActionsModal .btn,
#deptActionsModal .btn {
  padding: 9px 12px;
  font-size: 0.85rem;
  font-weight: 500;
}

#userActionsModal .btn i,
#deptActionsModal .btn i {
  font-size: 0.85rem;
  margin-right: 6px;
}

/* Confirmation modal styling */
#confirmActionModal .modal-body {
  padding: 16px;
}

#confirmActionModal #confirm-icon {
  font-size: 2.2rem !important;
  margin-bottom: 8px;
}

#confirmActionModal #confirm-message {
  font-size: 0.875rem;
  line-height: 1.5;
}

#confirmActionModal .modal-footer {
  padding: 10px 14px;
  gap: 8px;
}

#confirmActionModal .modal-footer .btn {
  padding: 8px 14px;
  font-size: 0.875rem;
  flex: 1;
}

#confirmActionModal .alert {
  padding: 8px 10px;
  font-size: 0.8rem;
  margin-bottom: 10px;
}

#confirmActionModal .alert i {
  font-size: 0.85rem;
}

/* Mobile specific */
@media (max-width: 768px) {
  #userActionsModal .modal-dialog,
  #deptActionsModal .modal-dialog,
  #confirmActionModal .modal-dialog {
    max-width: 90%;
    margin: 1rem auto;
  }
  
  #userActionsModal .modal-body,
  #deptActionsModal .modal-body {
    padding: 14px;
  }
  
  #confirmActionModal .modal-body {
    padding: 16px;
  }
  
  #userActionsModal .btn,
  #deptActionsModal .btn {
    padding: 9px 12px;
    font-size: 0.875rem;
  }
  
  #confirmActionModal #confirm-icon {
    font-size: 2.2rem !important;
  }
}

@media (max-width: 480px) {
  #userActionsModal .modal-dialog,
  #deptActionsModal .modal-dialog,
  #confirmActionModal .modal-dialog {
    max-width: 95%;
    margin: 0.75rem auto;
  }
  
  #userActionsModal .modal-header,
  #deptActionsModal .modal-header,
  #confirmActionModal .modal-header {
    padding: 12px 14px;
  }
  
  #userActionsModal .modal-title,
  #deptActionsModal .modal-title,
  #confirmActionModal .modal-title {
    font-size: 0.95rem;
  }
  
  #userActionsModal .modal-body,
  #deptActionsModal .modal-body {
    padding: 12px;
  }
  
  #confirmActionModal .modal-body {
    padding: 14px;
  }
  
  #userActionsModal .modal-body h6,
  #deptActionsModal .modal-body h6 {
    font-size: 0.9rem;
  }
  
  #userActionsModal .btn,
  #deptActionsModal .btn {
    padding: 8px 12px;
    font-size: 0.85rem;
  }
  
  #confirmActionModal #confirm-icon {
    font-size: 2rem !important;
  }
  
  #confirmActionModal #confirm-message {
    font-size: 0.85rem;
  }
}

/* ══════════════════════════════════════════════════════════════════
   GLOBAL MODAL FIXES - Applied to all modals across the system
   ══════════════════════════════════════════════════════════════════ 
   
   Z-INDEX HIERARCHY:
   - Content:        1-10
   - Topbar:         900
   - Sidebar:        999
   - Modal Backdrop: 1050
   - Modal:          1055
   - Tooltips:       1070
   ══════════════════════════════════════════════════════════════════ */

/* Ensure all modals have proper z-index above page headers and content */
.modal {
  z-index: 1055 !important;
}

.modal-backdrop {
  z-index: 1050 !important;
}

/* Override any potential conflicts */
.modal.show {
  z-index: 1055 !important;
}

.modal-backdrop.show {
  z-index: 1050 !important;
}

/* Desktop: Center all modals and control max-widths */
@media (min-width: 769px) {
  /* Default modal dialogs - reasonable size */
  .modal-dialog:not(.modal-sm):not(.modal-lg):not(.modal-xl) {
    max-width: 600px;
    margin: 1.75rem auto;
  }
  
  /* Large modals - for forms with many fields */
  .modal-dialog.modal-lg {
    max-width: 800px;
    margin: 1.75rem auto;
  }
  
  /* Extra large modals - for previews and detailed content */
  .modal-dialog.modal-xl {
    max-width: 90vw;
    margin: 1.75rem auto;
  }
  
  /* Small modals - for confirmations and simple actions */
  .modal-dialog.modal-sm {
    max-width: 400px;
    margin: 1.75rem auto;
  }
  
  /* Vertical centering for all modals with modal-dialog-centered */
  .modal-dialog-centered {
    display: flex;
    align-items: center;
    min-height: calc(100vh - 3.5rem);
  }
  
  /* Ensure modal bodies can scroll if content is too tall */
  .modal-body {
    max-height: calc(100vh - 250px);
    overflow-y: auto;
  }
  
  /* Compact spacing for better use of space */
  .modal-body .row.g-3 {
    row-gap: 0.75rem !important;
  }
}

/* Mobile: Full-width with margins */
@media (max-width: 768px) {
  .modal-dialog {
    margin: 0.5rem auto;
    max-width: calc(100% - 1rem);
  }
  
  .modal-body {
    max-height: calc(100vh - 180px);
    overflow-y: auto;
    padding: 1rem;
  }
}

/* Smooth scrolling for modal bodies */
.modal-body {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--gray-400) transparent;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
  background-color: var(--gray-400);
  border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background-color: var(--gray-500);
}


/* ══════════════════════════════════════════════════════════
   CARD SETTINGS BUTTON - TOP RIGHT CORNER
   ══════════════════════════════════════════════════════════ */

/* Position settings/action buttons in top right corner of cards */
.card-header {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-right: 60px; /* Make room for the button */
}

.card-header .card-settings-btn,
.card-header .btn-settings,
.card-header .settings-button {
  position: absolute !important;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  z-index: 10;
  padding: 6px 12px;
  font-size: 0.85rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: all 0.2s ease;
  margin: 0 !important;
}

.card-header .card-settings-btn:hover,
.card-header .btn-settings:hover,
.card-header .settings-button:hover {
  background: #fff;
  border-color: var(--gray-400);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  transform: translateY(-50%) scale(1.05);
  opacity: 1 !important; /* Prevent transparency on hover */
}

.card-header .card-settings-btn:hover i,
.card-header .btn-settings:hover i,
.card-header .settings-button:hover i {
  opacity: 1 !important; /* Ensure icon stays fully visible */
  color: var(--gray-800) !important; /* Ensure icon color is solid */
}

.card-header .card-settings-btn i,
.card-header .btn-settings i,
.card-header .settings-button i {
  font-size: 1rem;
  margin: 0;
  opacity: 1 !important; /* Ensure icon is always fully visible */
  color: var(--gray-700); /* Solid color */
}

/* Add padding to card header title to prevent overlap with settings button */
.card-header h5,
.card-header h6 {
  padding-right: 0;
  margin: 0;
}

/* For dark card headers, adjust button styling */
.card-header.bg-primary .card-settings-btn,
.card-header.bg-primary .btn-settings,
.card-header.bg-primary .settings-button,
.card-header.bg-dark .card-settings-btn,
.card-header.bg-dark .btn-settings,
.card-header.bg-dark .settings-button {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

.card-header.bg-primary .card-settings-btn:hover,
.card-header.bg-primary .btn-settings:hover,
.card-header.bg-primary .settings-button:hover,
.card-header.bg-dark .card-settings-btn:hover,
.card-header.bg-dark .btn-settings:hover,
.card-header.bg-dark .settings-button:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
}

/* Responsive adjustments for cards */
@media (max-width: 768px) {
  .card-header {
    padding: 14px 50px 14px 22px; /* Increased right padding to 50px */
    position: relative; /* Ensure dropdown positioning context */
    min-height: 48px; /* Ensure enough height for button */
  }
  
  .card-header h5,
  .card-header h6 {
    font-size: 0.9rem;
    padding-right: 0;
    flex: 1;
    min-width: 0; /* Allow text to wrap/truncate */
  }
  
  .card-header .card-settings-btn,
  .card-header .btn-settings,
  .card-header .settings-button {
    position: absolute !important;
    top: 50% !important;
    right: 10px !important;
    transform: translateY(-50%) !important;
    padding: 5px 8px;
    font-size: 0.85rem;
    width: 38px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0; /* Prevent button from shrinking */
    z-index: 20; /* Above card content */
  }
  
  .card-header .card-settings-btn i,
  .card-header .btn-settings i,
  .card-header .settings-button i {
    font-size: 1rem;
    margin: 0;
    opacity: 1 !important;
    color: var(--gray-700);
  }
  
  /* Prevent icon transparency on hover */
  .card-header .card-settings-btn:hover i,
  .card-header .btn-settings:hover i,
  .card-header .settings-button:hover i {
    opacity: 1 !important;
    color: var(--gray-800) !important;
  }
  
  /* Dropdown menu positioning */
  .card-header .dropdown-menu {
    position: absolute !important;
    right: 10px !important;
    left: auto !important;
    top: calc(100% + 2px) !important;
    margin: 0 !important;
    min-width: 180px;
    z-index: 1050 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
  }
}

@media (max-width: 480px) {
  .card-header {
    padding: 12px 46px 12px 16px; /* Increased right padding to 46px */
    min-height: 44px; /* Ensure enough height for button */
  }
  
  .card-header h5,
  .card-header h6 {
    font-size: 0.85rem;
    padding-right: 0;
    flex: 1;
    min-width: 0;
  }
  
  .card-header .card-settings-btn,
  .card-header .btn-settings,
  .card-header .settings-button {
    position: absolute !important;
    top: 50% !important;
    right: 8px !important;
    transform: translateY(-50%) !important;
    padding: 4px 7px;
    font-size: 0.75rem;
    width: 34px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  
  .card-header .card-settings-btn i,
  .card-header .btn-settings i,
  .card-header .settings-button i {
    font-size: 0.95rem;
    margin: 0;
    opacity: 1 !important;
    color: var(--gray-700);
  }
  
  /* Prevent icon transparency on hover */
  .card-header .card-settings-btn:hover i,
  .card-header .btn-settings:hover i,
  .card-header .settings-button:hover i {
    opacity: 1 !important;
    color: var(--gray-800) !important;
  }
  
  /* Fix: Ensure dropdown menu doesn't overlap card header title */
  .card-header .dropdown-menu {
    right: 8px !important;
    left: auto !important;
    top: calc(100% + 2px) !important;
    margin: 0 !important;
    z-index: 1050 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
  }
  
  /* Ensure dropdown button stays above card content */
  .card-header .card-settings-btn.dropdown-toggle {
    z-index: 20 !important;
  }
}

/* ══════════════════════════════════════════════════════════
   CRITICAL FIX: Department button hover (FINAL OVERRIDE)
   Force hover styles to work despite Bootstrap specificity
   ══════════════════════════════════════════════════════════ */

/* Delete button - RED hover with maximum specificity */
.table-container .ipcr-table tbody tr td.dept-actions .dept-action-desktop form button.btn.btn-sm.btn-outline-danger:hover,
.ipcr-table tbody tr td.dept-actions .dept-action-desktop form button.btn-outline-danger:hover,
form .dept-action-desktop button.btn-outline-danger:hover,
button.btn.btn-outline-danger:hover {
  background-color: #dc3545 !important;
  border-color: #dc3545 !important;
  color: #ffffff !important;
}

/* Edit button - BLUE hover with maximum specificity */
.table-container .ipcr-table tbody tr td.dept-actions .dept-action-desktop button.btn.btn-sm.btn-outline-primary:hover,
.ipcr-table tbody tr td.dept-actions .dept-action-desktop button.btn-outline-primary:hover,
.dept-action-desktop button.btn-outline-primary:hover,
button.btn.btn-outline-primary:hover {
  background-color: #0d6efd !important;
  border-color: #0d6efd !important;
  color: #ffffff !important;
}
