:root {
  --primary: #003366;
  --primary-dark: #002244;
  --primary-light: #1e4b8a;
  --accent: #f59e0b;
  --accent-hover: #d97706;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --radius: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.top-nav {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: white;
  padding: 1rem 1.5rem;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: white;
}

.brand-icon {
  font-size: 1.75rem;
}

.brand-logo-img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.35));
  transition: transform 0.2s ease;
}

.brand:hover .brand-logo-img {
  transform: scale(1.06);
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.brand-text p {
  font-size: 0.75rem;
  opacity: 0.85;
}

.nav-links {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.btn-nav {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.2s ease;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-nav:hover {
  background: rgba(255, 255, 255, 0.25);
}

.btn-nav-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  background: rgba(255, 255, 255, 0.15);
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1;
}

.btn-nav-icon:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.55);
  transform: rotate(30deg) scale(1.05);
}

/* Main Container */
.main-wrapper {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 2rem auto;
  padding: 0 1rem;
}

.main-wrapper-wide {
  max-width: 1300px;
}

/* Card */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 2rem;
}

.card-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
}

.card-header h2 {
  font-size: 1.35rem;
  color: var(--primary-dark);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-header p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.card-body {
  padding: 1.75rem;
}

/* Form Styles */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.col-span-2 {
  grid-column: span 2;
}

label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
}

.required {
  color: var(--danger);
}

input, select, textarea {
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px; /* Prevents auto-zoom on iOS mobile */
  color: var(--text-main);
  background-color: #ffffff;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
  min-height: 44px;
}

input[type="radio"], input[type="checkbox"] {
  width: 18px !important;
  min-height: 18px !important;
  height: 18px !important;
  padding: 0 !important;
  margin: 0 !important;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-block;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 51, 102, 0.15);
}

.input-with-btn {
  display: flex;
  gap: 0.5rem;
}

.btn-lookup {
  background: #f1f5f9;
  border: 1px solid var(--border);
  padding: 0 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-lookup:hover {
  background: #e2e8f0;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Primary Button */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #000;
  font-weight: 700;
  padding: 0.9rem 1.5rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  box-shadow: 0 2px 4px rgba(245, 158, 11, 0.3);
  transition: transform 0.1s, box-shadow 0.2s;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(245, 158, 11, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

/* Status Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-pending { background: #fef3c7; color: #92400e; }
.badge-shortlisted { background: #e0f2fe; color: #075985; }
.badge-interviewed { background: #f3e8ff; color: #6b21a8; }
.badge-appointed { background: #dcfce7; color: #166534; }
.badge-notselected { background: #fee2e2; color: #991b1b; }
.badge-refused { background: #fff1f2; color: #be123c; border: 1px solid #fecdd3; }

/* Metrics Bar: Desktop (> 1024px) */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

/* iPad / Tablet Metrics (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
  .metrics-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.15rem;
  }

  .metrics-grid .metric-card[data-status=""] {
    grid-column: span 2;
  }
}

.metric-card {
  background: white;
  border: 1px solid var(--border);
  padding: 0.95rem 1.1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
  user-select: none;
  position: relative;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.metric-card.active-filter {
  background: #f8fafc;
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  box-shadow: 0 0 0 3px rgba(0, 51, 102, 0.15), 0 4px 12px rgba(0, 51, 102, 0.08);
}

.metric-card.active-filter::after {
  content: '✓ Filtered';
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 0.60rem;
  font-weight: 700;
  color: var(--primary);
  background: rgba(0, 51, 102, 0.08);
  padding: 1px 5px;
  border-radius: 4px;
  pointer-events: none;
}

.metric-card.active-filter .metric-title {
  margin-right: 48px;
}

.metric-title {
  font-size: 0.72rem;
  line-height: 1.25;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-value {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-top: 0.25rem;
}

/* Toolbar */
.toolbar {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.toolbar-group {
  display: flex;
  gap: 0.45rem;
  flex-wrap: nowrap;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
}

.toolbar-filter-row {
  display: flex;
  gap: 0.45rem;
  flex-wrap: nowrap;
  align-items: center;
  flex-shrink: 0;
}

.toolbar-filter-row select {
  width: auto;
  min-width: 125px;
  max-width: 165px;
  height: 38px;
  min-height: 38px;
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
}

.toolbar-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: nowrap;
  align-items: center;
  flex-shrink: 0;
}

.toolbar-actions button,
.toolbar-actions .btn-primary,
.toolbar-actions .btn-success {
  height: 38px;
  min-height: 38px;
  padding: 0.35rem 0.85rem !important;
  font-size: 0.85rem !important;
  white-space: nowrap !important;
  width: auto !important;
}

.search-input {
  width: auto;
  min-width: 150px;
  max-width: 240px;
  flex: 1 1 200px;
  height: 38px;
  min-height: 38px;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

.btn-secondary {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid var(--border);
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
  height: 38px;
  min-height: 38px;
  white-space: nowrap;
}

.btn-secondary:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  padding: 0.65rem 1.1rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.25);
  transition: all 0.15s ease;
  min-height: 42px;
  white-space: nowrap;
}

.btn-success:hover {
  background: linear-gradient(135deg, #059669, #047857);
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.35);
}

/* Dedicated High-Visibility WhatsApp Action Button */
.btn-whatsapp {
  background: #25D366 !important;
  color: #ffffff !important;
  border: 1px solid #1ebe5d !important;
  font-weight: 700 !important;
  font-size: 0.85rem !important;
  padding: 0.55rem 1.1rem !important;
  border-radius: 6px !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.45rem !important;
  text-decoration: none !important;
  box-shadow: 0 2px 5px rgba(37, 211, 102, 0.35) !important;
  transition: all 0.15s ease !important;
  min-height: 38px !important;
  white-space: nowrap !important;
}

.btn-whatsapp:hover {
  background: #1ebd5a !important;
  color: #ffffff !important;
  box-shadow: 0 3px 8px rgba(37, 211, 102, 0.5) !important;
  transform: translateY(-1px);
}

.btn-whatsapp:active {
  transform: translateY(0);
}

/* Dedicated Email Dispatch Action Button */
.btn-email {
  background: linear-gradient(135deg, #0284c7, #0369a1) !important;
  color: #ffffff !important;
  border: 1px solid #0284c7 !important;
  font-weight: 700 !important;
  font-size: 0.85rem !important;
  padding: 0.55rem 1.1rem !important;
  border-radius: 6px !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.45rem !important;
  text-decoration: none !important;
  box-shadow: 0 2px 5px rgba(2, 132, 199, 0.3) !important;
  transition: all 0.15s ease !important;
  min-height: 38px !important;
  white-space: nowrap !important;
}

.btn-email:hover {
  background: linear-gradient(135deg, #0369a1, #075985) !important;
  color: #ffffff !important;
  box-shadow: 0 3px 8px rgba(2, 132, 199, 0.45) !important;
  transform: translateY(-1px);
}

.btn-email:active {
  transform: translateY(0);
}


/* Tables & Horizontal Scroll Container */
.table-container {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
  position: relative;
  background: #ffffff;
}

.table-container::-webkit-scrollbar {
  height: 6px;
}

.table-container::-webkit-scrollbar-track {
  background: #f8fafc;
}

.table-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table, .data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
  min-width: 820px; /* Maintains tabular integrity with horizontal touch scroll */
}

th {
  background: #f8fafc;
  padding: 0.85rem 1rem;
  font-weight: 600;
  color: #475569;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th.sortable-th {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}

th.sortable-th:hover {
  background-color: #f1f5f9;
  color: var(--primary-dark);
}

.sort-icon {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.78rem;
  color: #94a3b8;
  transition: color 0.15s ease;
  vertical-align: middle;
}

th.sortable-th:hover .sort-icon {
  color: var(--primary);
}

th.sortable-th.sorted-asc,
th.sortable-th.sorted-desc {
  background-color: #eff6ff;
  color: #1d4ed8;
  font-weight: 700;
}

th.sortable-th.sorted-asc .sort-icon,
th.sortable-th.sorted-desc .sort-icon {
  color: #1d4ed8;
  font-weight: 800;
}

td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:hover {
  background: #f8fafc;
}

/* Actions in Table */
.action-btns {
  display: flex;
  gap: 0.4rem;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  font-weight: 600;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.btn-sm:hover {
  background: #f8fafc;
}

.btn-sm-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-sm-primary:hover {
  background: var(--primary-light);
}

/* Mobile Cards Container (Hidden on Desktop by default) */
.mobile-cards-container {
  display: none;
}

.mobile-sort-bar {
  display: none;
}

/* View Switcher Toggle Button Group (Desktop) */
.view-switcher-toggle {
  display: inline-flex;
  align-items: center;
  background: #f1f5f9;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
  height: 38px;
  box-sizing: border-box;
}

.view-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  border: none;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.2;
  height: 32px;
  box-sizing: border-box;
  user-select: none;
}

.view-toggle-btn:hover {
  color: #0f172a;
  background: rgba(255, 255, 255, 0.6);
}

.view-toggle-btn.active {
  background: #ffffff;
  color: #003366;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  border: 1px solid #cbd5e1;
}

/* Desktop & Tablet Grid View Mode */
@media (min-width: 768px) {
  .view-grid-mode .desktop-table-container {
    display: none !important;
  }

  .view-grid-mode .mobile-cards-container {
    display: grid !important;
    gap: 1.15rem !important;
    padding: 1.25rem !important;
    background: #f8fafc !important;
    box-sizing: border-box !important;
  }

  .view-grid-mode .officer-card {
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.15rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    box-sizing: border-box;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  }

  .view-grid-mode .officer-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 51, 102, 0.08);
    border-color: #93c5fd;
  }
}

/* iPad / Tablet: 2 balanced columns for visual card grid */
@media (min-width: 768px) and (max-width: 1024px) {
  .view-grid-mode .mobile-cards-container {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* Desktop: 3 to 4 fluid columns for visual card grid */
@media (min-width: 1025px) {
  .view-grid-mode .mobile-cards-container {
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)) !important;
  }
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-content {
  background: #ffffff;
  border-radius: var(--radius);
  max-width: 650px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  position: relative;
  animation: popIn 0.2s ease-out;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-content > form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.modal-header {
  padding: 1.15rem 1.4rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.modal-body {
  padding: 1.25rem 1.4rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
}

.modal-footer {
  padding: 1rem 1.4rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.6rem;
  background: #f8fafc;
  flex-shrink: 0;
}

/* Footer */
footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: white;
  margin-top: auto;
}

/* -------------------------------------------------------------
   iPad / Tablet Responsive Tier (768px - 1024px)
   ------------------------------------------------------------- */
@media (min-width: 768px) and (max-width: 1024px) {
  .top-nav {
    padding: 0.75rem 1.25rem !important;
  }

  .main-wrapper {
    padding: 0 1rem !important;
    margin: 1.25rem auto !important;
  }

  /* Responsive Toolbar on iPad */
  .toolbar {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.75rem !important;
    align-items: stretch !important;
    width: 100% !important;
  }

  .toolbar-group {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
    align-items: center !important;
    width: 100% !important;
  }

  .search-input {
    flex: 1 1 200px !important;
    min-width: 180px !important;
    max-width: 100% !important;
    height: 40px !important;
  }

  .toolbar-filter-row {
    display: flex !important;
    gap: 0.5rem !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
  }

  .toolbar-filter-row select {
    min-width: 130px !important;
    max-width: 180px !important;
    height: 40px !important;
    padding: 0.35rem 0.65rem !important;
  }

  .toolbar-filter-row .btn-secondary {
    height: 40px !important;
    padding: 0 0.85rem !important;
  }

  .toolbar-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 0.5rem !important;
    width: 100% !important;
    border-top: 1px solid #f1f5f9 !important;
    padding-top: 0.65rem !important;
  }

  .toolbar-actions .view-switcher-toggle {
    display: inline-flex !important;
  }

  .desktop-table-container {
    display: block !important;
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-sort-bar {
    display: none !important;
  }

  .modal-content {
    max-width: 720px !important;
    width: 90% !important;
    max-height: 85vh !important;
  }
}

/* -------------------------------------------------------------
   Mobile Phones (< 768px)
   ------------------------------------------------------------- */
@media (max-width: 767px) {
  .top-nav {
    padding: 0.75rem 1rem;
  }

  .nav-container {
    gap: 0.5rem;
  }

  .brand-icon {
    font-size: 1.4rem;
  }

  .brand-logo-img {
    width: 36px;
    height: 36px;
  }

  .brand-text h1 {
    font-size: 1.02rem;
    line-height: 1.2;
  }

  .btn-nav {
    padding: 0.45rem 0.8rem;
    font-size: 0.8rem;
    min-height: 38px;
  }

  .main-wrapper {
    margin: 1rem auto;
    padding: 0 0.75rem;
  }

  #login-section {
    margin-top: 1.5rem !important;
  }

  .card {
    margin-bottom: 1.25rem;
    border-radius: 10px;
  }

  .card-header {
    padding: 1rem 1.15rem;
  }

  .card-body {
    padding: 1rem 1.15rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .col-span-2 {
    grid-column: span 1;
  }

  /* Metrics Grid on mobile: Total spans 2 cols, then 3 neat pairs of status cards */
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
    margin-bottom: 1rem;
  }

  .metrics-grid .metric-card[data-status=""] {
    grid-column: span 2;
  }

  .metric-card {
    padding: 0.75rem 0.85rem;
  }

  .metric-title {
    font-size: 0.68rem;
  }

  .metric-value {
    font-size: 1.4rem;
  }

  /* Top Nav Mobile */
  .top-nav {
    padding: 0.65rem 0.85rem !important;
  }

  .nav-container {
    gap: 0.5rem !important;
  }

  .brand {
    gap: 0.6rem !important;
  }

  .brand-logo-img {
    width: 34px !important;
    height: 34px !important;
  }

  .brand-text h1 {
    font-size: 0.98rem !important;
    line-height: 1.25 !important;
  }

  .brand-text p {
    font-size: 0.72rem !important;
  }

  .btn-nav-icon {
    width: 38px !important;
    height: 38px !important;
    font-size: 1.15rem !important;
  }

  .btn-nav {
    padding: 0.45rem 0.75rem !important;
    font-size: 0.82rem !important;
    min-height: 38px !important;
  }

  /* Toolbar on Mobile */
  .toolbar {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.65rem !important;
    width: 100% !important;
  }

  .toolbar-group {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    gap: 0.5rem !important;
    align-items: stretch !important;
  }

  .search-input {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: 42px !important;
    min-height: 42px !important;
    max-height: 42px !important;
    flex: none !important;
    padding: 0.45rem 0.85rem !important;
    font-size: 16px !important;
    box-sizing: border-box !important;
  }

  .toolbar-filter-row {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
    width: 100% !important;
  }

  .toolbar-filter-row select {
    flex: 1 1 calc(50% - 0.25rem) !important;
    min-width: 120px !important;
    max-width: 100% !important;
    width: auto !important;
    height: 42px !important;
    min-height: 42px !important;
    font-size: 14px !important;
    box-sizing: border-box !important;
  }

  .toolbar-filter-row .btn-secondary {
    flex: 0 0 auto !important;
    height: 42px !important;
    min-height: 42px !important;
    padding: 0 0.85rem !important;
    white-space: nowrap !important;
  }

  .toolbar-actions {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    gap: 0.5rem !important;
  }

  .toolbar-actions button,
  .toolbar-actions .btn-primary,
  .toolbar-actions .btn-success {
    width: 100% !important;
    justify-content: center !important;
    height: 42px !important;
    min-height: 42px !important;
    font-size: 0.9rem !important;
    box-sizing: border-box !important;
  }

  /* Mobile View: No Horizontal Scroll - Card-Like UI */
  .mobile-table-hint {
    display: none !important;
  }

  .view-switcher-toggle {
    display: none !important;
  }

  .desktop-table-container {
    display: none !important;
  }

  .mobile-sort-bar {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 0.85rem;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    box-sizing: border-box;
    width: 100%;
  }

  .mobile-sort-label {
    font-weight: 700;
    color: var(--primary-dark);
    font-size: 0.82rem;
    white-space: nowrap;
  }

  .mobile-sort-select {
    flex: 1;
    min-height: 40px !important;
    height: 40px !important;
    padding: 0.35rem 0.65rem !important;
    font-size: 0.85rem !important;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--text-main);
  }

  .mobile-cards-container {
    display: flex !important;
    flex-direction: column;
    gap: 0.85rem;
    padding: 0.85rem;
    width: 100%;
    box-sizing: border-box;
    background: #f8fafc;
  }

  /* Officer Mobile Card */
  .officer-card {
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    box-sizing: border-box;
    width: 100%;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
  }

  .officer-card:active {
    border-color: var(--primary);
  }

  .officer-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 0.55rem;
  }

  .officer-card-name {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--primary-dark);
    margin: 0;
    line-height: 1.25;
  }

  .officer-card-id {
    font-size: 0.76rem;
    color: var(--text-muted);
    margin-top: 3px;
  }

  .officer-card-badges {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
    flex-shrink: 0;
  }

  .officer-card-post {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
  }

  .officer-card-post-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: #1d4ed8;
    line-height: 1.3;
  }

  .officer-card-club {
    font-size: 0.85rem;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 0.4rem;
  }

  .officer-card-contact {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
  }

  .officer-card-phone-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    background: #f1f5f9;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--primary-dark);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.85rem;
    min-height: 38px;
    box-sizing: border-box;
  }

  .officer-card-wa-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    background: #dcfce7;
    border: 1px solid #86efac;
    border-radius: 6px;
    color: #15803d;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.85rem;
    min-height: 38px;
    box-sizing: border-box;
  }

  .officer-card-email {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-decoration: none;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
    margin-top: 2px;
  }

  /* Prominent ONLY TELL Box */
  .officer-card-onlytell {
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
    display: flex;
    gap: 0.55rem;
    align-items: flex-start;
    box-sizing: border-box;
  }

  .officer-card-onlytell.has-content {
    background: #fef9c3;
    border: 1.5px dashed #ca8a04;
    color: #854d0e;
  }

  .officer-card-onlytell-label {
    font-size: 0.74rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #a16207;
    display: block;
    margin-bottom: 0.2rem;
  }

  .officer-card-onlytell-text {
    font-size: 0.88rem;
    font-weight: 700;
    color: #713f12;
    line-height: 1.35;
    word-break: break-word;
  }

  .officer-card-onlytell.no-content {
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    padding: 0.45rem 0.75rem;
  }

  .officer-card-onlytell.no-content .officer-card-onlytell-label {
    color: #94a3b8;
  }

  .officer-card-onlytell.no-content .officer-card-onlytell-text {
    font-size: 0.8rem;
    color: #94a3b8;
    font-weight: normal;
    font-style: italic;
  }

  /* Remarks */
  .officer-card-remark {
    font-size: 0.82rem;
    color: #475569;
    background: #f8fafc;
    padding: 0.45rem 0.65rem;
    border-radius: 6px;
    border-left: 3px solid #cbd5e1;
    line-height: 1.35;
  }

  .officer-card-committee {
    font-size: 0.8rem;
    color: #0369a1;
    background: #f0f9ff;
    padding: 0.4rem 0.65rem;
    border-radius: 6px;
    border-left: 3px solid #38bdf8;
    line-height: 1.35;
  }

  /* Actions Row */
  .officer-card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-top: 0.35rem;
    padding-top: 0.65rem;
    border-top: 1px solid #f1f5f9;
  }

  .officer-card-actions button {
    width: 100% !important;
    min-height: 42px !important;
    height: 42px !important;
    font-size: 0.88rem !important;
    font-weight: 700 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.35rem !important;
    border-radius: 8px !important;
    box-sizing: border-box !important;
  }

  /* Modals on Mobile */
  .modal-backdrop {
    padding: 0.5rem !important;
    align-items: center !important;
  }

  .modal-content {
    max-height: 92vh !important;
    border-radius: 14px !important;
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
  }

  .modal-header {
    padding: 0.85rem 1rem !important;
    flex-shrink: 0 !important;
  }

  .modal-header h3 {
    font-size: 1.05rem !important;
  }

  .modal-body {
    padding: 1rem 0.9rem !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    flex: 1 1 auto !important;
    max-height: calc(92vh - 130px) !important;
  }

  .modal-footer {
    padding: 0.75rem 0.9rem !important;
    flex-direction: column-reverse !important;
    gap: 0.5rem !important;
    flex-shrink: 0 !important;
    background: #f8fafc !important;
    border-top: 1px solid var(--border) !important;
  }

  .modal-footer button {
    width: 100% !important;
    min-height: 44px !important;
    justify-content: center !important;
    font-size: 0.9rem !important;
  }

  /* Search Member Roster container in modal */
  .candidate-search-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.5rem !important;
  }

  .candidate-search-row input {
    width: 100% !important;
    min-height: 44px !important;
  }

  .candidate-search-row button {
    width: 100% !important;
    justify-content: center !important;
    min-height: 44px !important;
  }

  .candidate-post-row {
    grid-template-columns: 1fr !important;
    gap: 0.5rem !important;
  }
}

@media (max-width: 480px) {
  .brand-text p {
    display: none !important;
  }

  .brand-text h1 {
    font-size: 0.88rem !important;
    line-height: 1.2 !important;
  }

  .brand-logo-img {
    width: 30px !important;
    height: 30px !important;
  }

  .top-nav {
    padding: 0.5rem 0.65rem !important;
  }

  .btn-nav {
    padding: 0.35rem 0.6rem !important;
    font-size: 0.78rem !important;
  }

  .toolbar-filter-row select {
    flex: 1 1 100% !important;
    width: 100% !important;
  }

  .toolbar-filter-row .btn-secondary {
    flex: 1 1 100% !important;
    width: 100% !important;
  }

  .metric-value {
    font-size: 1.35rem !important;
  }

  .metric-card {
    padding: 0.7rem 0.75rem !important;
  }

  .modal-backdrop {
    padding: 0 !important;
    align-items: flex-end !important;
  }

  .modal-content {
    border-radius: 16px 16px 0 0 !important;
    max-height: 94vh !important;
  }

  #login-section .card {
    margin: 1rem auto !important;
    max-width: 100% !important;
  }
}

/* -------------------------------------------------------------
   Offer Letter Designer Modal Styles
   ------------------------------------------------------------- */
.designer-split-container {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.designer-form-pane {
  flex: 1 1 50%;
  max-width: 52%;
  min-width: 320px;
  padding: 1.25rem;
  overflow-y: auto;
  background: #ffffff;
  border-right: 2px solid var(--border);
}

.designer-preview-pane {
  flex: 1 1 50%;
  padding: 1.5rem 1rem;
  overflow-y: auto;
  background: #475569;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.tag-chip {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  color: #0369a1;
  font-family: monospace;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.tag-chip:hover {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
  transform: translateY(-1px);
}

@media (max-width: 900px) {
  .designer-split-container {
    flex-direction: column !important;
  }
  .designer-form-pane {
    max-width: 100% !important;
    flex: 1 1 auto !important;
    border-right: none !important;
    border-bottom: 2px solid var(--border) !important;
  }
  .designer-preview-pane {
    max-width: 100% !important;
    flex: 1 1 auto !important;
  }
}

@media (max-width: 680px) {
  .post-master-add-grid,
  .edit-post-grid-top {
    grid-template-columns: 1fr !important;
    gap: 0.5rem !important;
  }
}

/* Settings Dropdown Styles */
.settings-dropdown-wrapper {
  position: relative;
  display: inline-block;
  z-index: 100;
}

.settings-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.2), 0 8px 10px -6px rgba(0,0,0,0.15);
  min-width: 260px;
  z-index: 9999;
  padding: 0.4rem;
}

.settings-dropdown-menu.show {
  display: block;
}

.settings-dropdown-item {
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.85rem;
  font-size: 0.875rem;
  background: transparent;
  border: none;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.settings-dropdown-item:hover {
  background: #f1f5f9;
  transform: translateX(2px);
}

.settings-dropdown-item.post-master-item:hover {
  background: #ecfdf5;
}

.settings-dropdown-item.designer-item:hover {
  background: #fdf2e9;
}

@media (max-width: 600px) {
  .settings-dropdown-menu {
    left: auto !important;
    right: 0 !important;
    width: 270px !important;
    max-width: 88vw !important;
  }
}

/* ==========================================================================
   OFFICIAL DISTRICT CABINET OFFER LETTER TEMPLATES (5 DISTINCT STYLES)
   ========================================================================== */

/* Template Choice Cards in Admin Modal */
.template-choice-card {
  transition: all 0.2s ease;
  user-select: none;
}
.template-choice-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}
.template-choice-card.active {
  border-color: #0284c7 !important;
  background: #f0f9ff !important;
  box-shadow: 0 0 0 2px #0284c7, 0 4px 10px rgba(2, 132, 199, 0.15) !important;
}

/* 1. CLASSIC DIPLOMATIC (Default) */
.layout-classic,
#designer-live-letter.layout-classic {
  background: #ffffff !important;
}

/* 2. ROYAL HERITAGE */
.layout-heritage,
#designer-live-letter.layout-heritage {
  background-color: #fffdf7 !important;
  font-family: "Georgia", "Times New Roman", Garamond, serif !important;
  border: 3px double #d97706 !important;
  outline: 1px solid #b45309;
  outline-offset: -7px;
  box-shadow: 0 0 0 5px #fef3c7 inset, 0 6px 18px rgba(180, 83, 9, 0.12) !important;
}
.layout-heritage .letterhead,
#designer-live-letter.layout-heritage #prev-header {
  border-bottom: 2.5px solid #d97706 !important;
  position: relative;
}
.layout-heritage .letterhead::after,
#designer-live-letter.layout-heritage #prev-header::after {
  content: "♦ ❖ ♦";
  display: block;
  text-align: center;
  color: #d97706;
  font-size: 0.75rem;
  letter-spacing: 0.35em;
  margin-top: 3px;
}
.layout-heritage .recipient-box,
.layout-heritage .recipient-block,
#designer-live-letter.layout-heritage div[style*="border-left: 3px solid"] {
  background: #fffbeb !important;
  border: 1px solid #fde68a !important;
  border-left: 4.5px solid #b45309 !important;
  border-radius: 4px !important;
}
.layout-heritage .appointment-callout,
.layout-heritage .post-callout,
#designer-live-letter.layout-heritage div[style*="linear-gradient(135deg, #f0fdf4"] {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%) !important;
  border: 1.5px solid #d97706 !important;
  border-left: 5px solid #b45309 !important;
  box-shadow: 0 2px 6px rgba(180, 83, 9, 0.08) !important;
}
.layout-heritage .subject-line,
#designer-live-letter.layout-heritage #prev-subjectLine {
  color: #78350f !important;
  text-decoration-color: #d97706 !important;
}

/* 3. MODERN EXECUTIVE */
.layout-modern,
#designer-live-letter.layout-modern {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  border-left: 8px solid var(--primary, #003366) !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.06) !important;
}
.layout-modern .letterhead,
#designer-live-letter.layout-modern #prev-header {
  border-bottom: 2px solid #0284c7 !important;
}
.layout-modern .recipient-box,
.layout-modern .recipient-block,
#designer-live-letter.layout-modern div[style*="border-left: 3px solid"] {
  background: #ffffff !important;
  border: 1.5px solid #e2e8f0 !important;
  border-left: 4.5px solid #0284c7 !important;
  border-radius: 8px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04) !important;
}
.layout-modern .appointment-callout,
.layout-modern .post-callout,
#designer-live-letter.layout-modern div[style*="linear-gradient(135deg, #f0fdf4"] {
  background: #f8fafc !important;
  border: 1.5px solid #cbd5e1 !important;
  border-radius: 8px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04) !important;
}
.layout-modern .post-badge,
#designer-live-letter.layout-modern #prev-appointmentBadge {
  border-radius: 9999px !important;
  background: #0284c7 !important;
  color: #ffffff !important;
}

/* 4. PRESIDENTIAL BANNER */
.layout-presidential,
#designer-live-letter.layout-presidential {
  background: #ffffff !important;
  border-top: 6px solid var(--primary, #003366) !important;
  border-bottom: 6px solid var(--gold, #d97706) !important;
  border-left: 1px solid #e2e8f0 !important;
  border-right: 1px solid #e2e8f0 !important;
}
.layout-presidential .letterhead,
#designer-live-letter.layout-presidential #prev-header {
  background: linear-gradient(135deg, var(--primary, #003366) 0%, #001f3f 100%) !important;
  color: #ffffff !important;
  padding: 0.9rem 1.2rem !important;
  border-radius: 8px !important;
  margin-bottom: 1rem !important;
  border-bottom: 3px solid #d97706 !important;
}
.layout-presidential .letterhead-text h1,
#designer-live-letter.layout-presidential #prev-headerTitle {
  color: #ffffff !important;
}
.layout-presidential .letterhead-text h2,
#designer-live-letter.layout-presidential #prev-subHeader {
  color: #fde047 !important;
}
.layout-presidential .letterhead-text p,
#designer-live-letter.layout-presidential #prev-officeTitle {
  color: #e2e8f0 !important;
  opacity: 0.95;
}
.layout-presidential .recipient-box,
.layout-presidential .recipient-block,
#designer-live-letter.layout-presidential div[style*="border-left: 3px solid"] {
  background: #f0f9ff !important;
  border: 1px solid #bae6fd !important;
  border-left: 4.5px solid #d97706 !important;
}
.layout-presidential .appointment-callout,
.layout-presidential .post-callout,
#designer-live-letter.layout-presidential div[style*="linear-gradient(135deg, #f0fdf4"] {
  background: linear-gradient(135deg, #f8fafc 0%, #eff6ff 100%) !important;
  border: 1.5px solid #003366 !important;
  border-left: 5px solid #d97706 !important;
}

/* 5. COMPACT SINGLE-SHEET */
.layout-compact,
#designer-live-letter.layout-compact {
  padding: 1rem 1.4rem !important;
  font-size: 0.77rem !important;
  line-height: 1.38 !important;
}
.layout-compact .letterhead,
#designer-live-letter.layout-compact #prev-header {
  padding-bottom: 0.35rem !important;
  margin-bottom: 0.45rem !important;
}
.layout-compact .letterhead-logo {
  width: 44px !important;
  height: 44px !important;
}
.layout-compact .recipient-box,
.layout-compact .recipient-block,
#designer-live-letter.layout-compact div[style*="border-left: 3px solid"] {
  padding: 0.35rem 0.65rem !important;
  margin-bottom: 0.4rem !important;
}
.layout-compact .appointment-callout,
.layout-compact .post-callout,
#designer-live-letter.layout-compact div[style*="linear-gradient(135deg, #f0fdf4"] {
  padding: 0.35rem 0.65rem !important;
  margin: 0.35rem 0 !important;
}
.layout-compact p,
#designer-live-letter.layout-compact p {
  margin-bottom: 0.35rem !important;
}
.layout-compact .letter-signoff,
#designer-live-letter.layout-compact div[style*="margin-top: 1.5rem"] {
  margin-top: 0.8rem !important;
}



