*:root {
  --brand-red: #d92322;
  --brand-red-dark: #b91c1c;
  --brand-green: #0f8e38;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  touch-action: pan-y;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}

/* Ensure hamburger button is hidden by default on larger screens */
.hamburger {
  display: none;
}

/* Hide hamburger when auth (login/register) is visible */
.auth-visible .hamburger {
  display: none !important;
}

html {
  overscroll-behavior: none;
  touch-action: pan-y;
}

/* Prevent body scrolling when auth forms are visible */
.no-scroll {
  overflow: hidden !important;
  box-shadow: 0 6px 18px rgba(5, 150, 105, 0.18);
}

/* Download button should be the brand red */
.btn-download {
  background: var(--brand-red) !important;
  color: #fff !important;
  border: none !important;
}

.btn-download:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(217, 35, 34, 0.18);
}

body {
  font-family: Georgia, serif;
  background: #f5f5f5;
  min-height: auto;
  display: flex;
  overflow-y: auto;
  overscroll-behavior: none;
  touch-action: pan-y;
}

.container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
}

.auth-container {
  background: white;
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  max-width: 500px;
  width: 100%;
}

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 250px;
  height: 100vh;
  /* Lighter brand red */
  background: var(--brand-red);
  color: white;
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 250px;
}

.sidebar.hidden {
  display: none;
}

.sidebar-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sidebar-payslips {
  margin-top: 10px;
  width: 100%;
}

.payslip-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  padding: 12px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  font-family: Georgia, serif;
  width: 100%;
  touch-action: manipulation;
  pointer-events: auto;
}

.payslip-link:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: white;
}

.payslip-icon {
  font-size: 14px;
  line-height: 1;
}

.payslip-count {
  margin-left: auto;
  background: #ff6b6b;
  color: #fff;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 12px;
}

.sidebar-profile {
  margin-top: 8px;
  width: 100%;
}

.profile-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  padding: 12px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  font-family: Georgia, serif;
  width: 100%;
  touch-action: manipulation;
  pointer-events: auto;
}

.profile-link:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: white;
}

.profile-icon {
  font-size: 14px;
  line-height: 1;
}

.hidden {
  display: none !important;
}

/* Ensure modals are hidden by default to prevent FOUC */
.modal {
  display: none;
}

.modal.visible {
  display: flex;
}

.sidebar-header .logo {
  width: 100px;
  height: auto;
  margin-bottom: 15px;
  object-fit: contain;
}

.sidebar-header h2 {
  font-size: 22px;
  margin-bottom: 10px;
  font-family: Georgia, serif;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 20px 0 0 0;
  width: 100%;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  font-family: Georgia, serif;
  width: 100%;
  text-align: left;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateX(4px);
}

.nav-link.active {
  background: var(--brand-red);
  color: white;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.nav-link .nav-icon {
  font-size: 16px;
  min-width: 20px;
}

.nav-link .nav-text {
  flex: 1;
}

.nav-btn {
  width: 100%;
  padding: 12px;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  font-family: Georgia, serif;
  text-align: center;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: white;
}

.nav-btn.active {
  background: white;
  color: var(--brand-red);
  border-color: var(--brand-red);
}

.sidebar-footer {
  text-align: center;
  margin-top: 50px;
}

.btn-logout {
  width: 100%;
  padding: 12px;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid white;
  border-radius: 5px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  font-family: Georgia, serif;
}

.btn-logout:hover {
  background: white;
  color: var(--brand-red);
}

.main-content {
  margin-left: 250px;
  width: calc(100% - 250px);
  padding: 30px;
  background: white;
  min-height: 100vh;
  overflow-y: auto;
  max-height: 100vh;
}

.main-content.full-width {
  margin-left: 0;
  width: 100%;
}

.form-container {
  padding: 40px;
  animation: fadeIn 0.3s ease-in;
  background: white;
  max-width: 500px;
  width: 100%;
  margin: 0 auto;
}

.form-container.hidden {
  display: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.form-container h1 {
  color: #333;
  margin-bottom: 30px;
  text-align: center;
  font-size: 24px;
  font-family: Georgia, serif;
}

.form-logo {
  width: 150px;
  height: auto;
  margin: 0 auto 20px;
  display: block;
  object-fit: contain;
}

.app-title {
  text-align: center;
  color: #333;
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 20px;
  font-family: Georgia, serif;
}

.form-footer {
  text-align: center;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #eee;
  color: #999;
  font-size: 12px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: #555;
  font-weight: 500;
  font-size: 14px;
  font-family: Georgia, serif;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 14px;
  font-family: Georgia, serif;
  transition: border-color 0.3s;
  user-select: text;
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--brand-green);
  box-shadow: 0 0 0 3px rgba(15, 142, 56, 0.08);
}

.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrapper input {
  width: 100%;
  padding-right: 40px;
}

.password-toggle {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: #666;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.3s;
  user-select: none;
  -webkit-user-select: none;
}

.password-toggle:hover {
  color: #333;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--brand-red);
  color: white;
  border: none;
  border-radius: 5px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  margin-top: 10px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(217, 35, 34, 0.18);
}

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

.btn-secondary {
  padding: 10px 20px;
  background: #f5f5f5;
  color: #333;
  border: 1px solid #ddd;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.3s;
  margin-top: 10px;
}

.btn-secondary:hover {
  background: #ebebeb;
}

/* Back to Dashboard link-style button (used in available payslips section) */
.btn-link {
  display: inline-block;
  background: transparent;
  color: var(--brand-red);
  border: 2px solid var(--brand-red);
  padding: 14px 24px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, transform 0.06s;
}

.btn-link:hover {
  background: var(--brand-red);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.18);
}

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


/* Small spinner used in buttons */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-left: 8px;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}


.toggle-text {
  text-align: center;
  margin-top: 20px;
  color: #666;
  font-size: 14px;
  font-family: Georgia, serif;
}

.toggle-text a {
  color: var(--brand-green);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}

.toggle-text a:hover {
  text-decoration: underline;
}

.message {
  padding: 15px;
  margin-bottom: 20px;
  border-radius: 8px;
  text-align: center;
  /* keep element out of layout and always available; control visibility via opacity */
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.98);
  z-index: 10002;
  max-width: 92%;
  width: 420px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.18);
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 180ms ease, visibility 200ms;
}

.message.visible {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.message.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.dashboard {
  padding: 30px;
  background: white;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.dashboard.hidden {
  display: none;
}

.dashboard h1 {
  color: white;
  margin-bottom: 16px;
  font-family: Georgia, serif;
  background: var(--brand-red);
  border: 2px solid var(--brand-red);
  padding: 14px 16px;
  border-radius: 6px;
  font-size: 18px;
  font-weight: 600;
}

.dashboard p {
  color: #666;
  margin-bottom: 20px;
  font-family: Georgia, serif;
}

.staff-info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
  padding: 16px;
  background: #f5f5f5;
  border-radius: 8px;
  border: 1px solid #eee;
}

.staff-info-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.staff-info-item strong {
  font-size: 12px;
  color: #999;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.staff-info-item span {
  font-size: 16px;
  color: #333;
  font-weight: 700;
}

.payslip-section,
.upload-section,
.status-section {
  margin-top: 30px;
  padding: 20px;
  background: #f9f9f9;
  border-radius: 5px;
  border: 1px solid #eee;
}

.payslip-section h2,
.upload-section h2,
.status-section h2 {
  color: #333;
  margin-bottom: 20px;
  font-size: 18px;
  font-family: Georgia, serif;
}

.payslip-list {
  background: white;
  padding: 20px;
  border-radius: 5px;
  margin-top: 30px;
}

.payslip-list p {
  color: #999;
  text-align: center;
}

.payslip-list ul {
  list-style-position: inside;
  color: #333;
}

.payslip-list li {
  padding: 8px 0;
  border-bottom: 1px solid #eee;
}

.payslip-list li:last-child {
  border-bottom: none;
}

.profile-container {
  background: white;
  padding: 40px;
  border-radius: 8px;
  margin: 30px auto 0;
  max-width: 600px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.profile-container h2 {
  color: var(--brand-red);
  margin-bottom: 30px;
  font-family: Georgia, serif;
  font-size: 28px;
  font-weight: 600;
  text-align: center;
}

.update-profile-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.update-profile-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.update-profile-form label {
  color: #333;
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: Georgia, serif;
}

.update-profile-form input,
.update-profile-form select {
  padding: 12px 14px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  font-size: 15px;
  font-family: Georgia, serif;
  background: #fafafa;
  transition: border-color 0.3s, background-color 0.3s, box-shadow 0.3s;
}

.update-profile-form input::placeholder {
  color: #999;
}

.update-profile-form input:hover,
.update-profile-form select:hover {
  background: #fff;
  border-color: #d0d0d0;
}

.update-profile-form input:focus,
.update-profile-form select:focus {
  outline: none;
  border-color: var(--brand-red);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.12);
}

#updateProfileMessage {
  padding: 14px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  margin-top: 10px;
}

#updateProfileMessage.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

#updateProfileMessage.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 25px;
  justify-content: center;
  flex-wrap: wrap;
}

.form-actions .btn-secondary {
  flex: 1;
  min-width: 140px;
  padding: 12px 20px;
  background: #f5f5f5;
  color: #333;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  margin-top: 0;
}

.form-actions .btn-secondary:hover {
  background: #ebebeb;
  border-color: #d0d0d0;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

.form-actions .btn-secondary:active {
  transform: translateY(0);
}

.form-actions .btn-primary {
  flex: 1;
  min-width: 140px;
  padding: 12px 20px;
  background: var(--brand-red);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  margin-top: 0;
}

.form-actions .btn-primary:hover {
  background: #b81a19;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(220, 38, 38, 0.25);
}

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

/* Payslips Table Styles */
.payslips-table-container {
  width: 100%;
  overflow-x: auto;
}

.payslips-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
}

.payslips-table thead {
  background: #f5f5f5;
  border-bottom: 2px solid #ddd;
}

.payslips-table th {
  padding: 15px;
  text-align: left;
  font-weight: 700;
  color: #333;
  font-family: Georgia, serif;
  font-size: 14px;
}

.payslips-table td {
  padding: 12px 15px;
  border-bottom: 1px solid #eee;
  color: #555;
}

.payslips-table tbody tr:hover {
  background: #f9f9f9;
}

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

/* Pagination Styles */
.pagination-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 25px;
  flex-wrap: wrap;
}


.pagination-info {
  color: #666;
  font-size: 14px;
  font-weight: 500;
}

.pagination-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.pagination-btn {
  background: white;
  color: var(--brand-green);
  border: 2px solid var(--brand-green);
  padding: 8px 12px;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
  background: var(--brand-green);
  color: white;
}

.pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination-page-input {
  width: 60px;
  padding: 8px;
  border: 2px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  text-align: center;
}

.pagination-page-input:focus {
  outline: none;
  border-color: var(--brand-green);
}

.payslip-display {
  margin-top: 30px;
  padding: 25px;
  background: #f9f9f9;
  border-radius: 5px;
  border: 1px solid #eee;
  width: 100%;
  box-sizing: border-box;
}

.payslip-display h2 {
  color: #333;
  margin-bottom: 20px;
  font-size: 18px;
  font-family: Georgia, serif;
  word-wrap: break-word;
}

.payslip-display.hidden {
  display: none;
}

#payslipContent {
  background: white;
  padding: 18px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-family: 'Courier New', monospace !important;
  font-size: 13px;
  line-height: 1.7;
  color: #333;
  overflow-x: auto;
  overflow-y: auto;
  /* Preserve exact whitespace and line breaks from the original .txt */
  white-space: pre !important;
  /* Ensure tabs/indentation render consistently */
  tab-size: 4;
  -moz-tab-size: 4;
  /* Prevent wrapping or collapse by other rules */
  word-break: normal;
  white-space-collapse: preserve;
  /* guarded: non-standard but harmless */
  max-height: 600px;
}

.status-table {
  background: white;
  padding: 15px;
  border-radius: 5px;
  overflow-x: auto;
}

.status-table table {
  width: 100%;
  border-collapse: collapse;
}

.status-table th {
  background: #f5f5f5;
  padding: 10px;
  text-align: left;
  font-weight: 600;
  color: #333;
  font-size: 13px;
  border-bottom: 2px solid #ddd;
}

.status-table td {
  padding: 12px 10px;
  border-bottom: 1px solid #eee;
  color: #666;
  font-size: 13px;
}

.status-table tr:hover {
  background: #f9f9f9;
}

.pagination-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  margin-top: 20px;
  padding: 15px;
  background: #f9f9f9;
  border-radius: 5px;
}

.btn-pagination {
  padding: 10px 16px;
  background: var(--brand-green);
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: Georgia, serif;
  transition: all 0.2s;
}

.btn-pagination:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(15, 142, 56, 0.12);
}

.btn-pagination:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.page-info {
  font-weight: 600;
  color: #333;
  font-family: Georgia, serif;
  min-width: 80px;
  text-align: center;
}

.staff-info-section {
  padding: 30px;
  background: white;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.staff-info-section h1 {
  color: #333;
  margin-bottom: 25px;
  font-family: Georgia, serif;
  font-size: 28px;
}

.staff-controls {
  display: flex;
  gap: 20px;
  margin-bottom: 25px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.search-box {
  flex: 1;
  min-width: 250px;
}

.search-box input {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 14px;
  font-family: Georgia, serif;
}

.search-box input:focus {
  outline: none;
  border-color: #667eea;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.filter-group label {
  font-size: 13px;
  font-weight: 600;
  color: #555;
  font-family: Georgia, serif;
}

.filter-group select {
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 14px;
  font-family: Georgia, serif;
  background: white;
  cursor: pointer;
}

.filter-group select:focus {
  outline: none;
  border-color: #667eea;
}

.staff-table-container {
  margin-bottom: 20px;
}

.staff-table {
  background: white;
  padding: 15px;
  border-radius: 5px;
  overflow-x: auto;
}

.staff-table table {
  width: 100%;
  border-collapse: collapse;
}

.staff-table th {
  background: #f5f5f5;
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: #333;
  font-size: 13px;
  border-bottom: 2px solid #ddd;
  font-family: Georgia, serif;
}

.staff-table td {
  padding: 12px;
  border-bottom: 1px solid #eee;
  color: #666;
  font-size: 13px;
  font-family: Georgia, serif;
}

.staff-table tr:hover {
  background: #f9f9f9;
}

.btn-action {
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: Georgia, serif;
}

.btn-remove {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.btn-remove:hover {
  background: #fecaca;
  color: #7f1d1d;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(217, 35, 34, 0.15);
}

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

.hidden {
  display: none !important;
}

.site-footer {
  font-size: 13px;
  color: #666;
  text-align: center;
  margin-top: 18px;
  opacity: 0.9;
}

/* Modal styles for payslip preview */
.modal {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10050;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.45);
}

.modal-content {
  position: relative;
  background: #fff;
  width: 90%;
  max-width: 980px;
  max-height: 90vh;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  z-index: 10051;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid #eee;
}

.modal-body {
  padding: 12px 18px;
  overflow: auto;
}

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid #eee;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
}

.modal-body pre {
  background: #fff;
  padding: 18px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  white-space: pre;
  tab-size: 4;
  line-height: 1.6;
  color: #111;
  max-height: 100%;
  overflow: auto;
}

@media (max-width: 600px) {
  .container {
    padding: 10px;
  }

  .form-container {
    padding: 20px;
    border-radius: 8px;
  }

  .form-container h1 {
    font-size: 20px;
    margin-bottom: 16px;
    line-height: 1.3;
  }

  .dashboard {
    padding: 16px;
  }

  .dashboard h1 {
    font-size: 22px;
    margin-bottom: 12px;
    color: white;
    background: var(--brand-red);
    border: 2px solid var(--brand-red);
    padding: 12px 14px;
    border-radius: 6px;
    font-weight: 600;
    width: auto;
    align-self: flex-end;
  }

  .dashboard > p {
    font-size: 13px;
    margin-bottom: 14px;
  }

  .payslip-section,
  .upload-section,
  .status-section {
    margin-top: 16px;
    padding: 14px;
    border-radius: 6px;
  }

  .payslip-section h2,
  .upload-section h2,
  .status-section h2 {
    font-size: 15px;
    margin-bottom: 14px;
  }

  .form-group {
    margin-bottom: 12px;
  }

  .form-group label {
    font-size: 13px;
    margin-bottom: 6px;
  }

  .form-group input,
  .form-group select {
    padding: 11px;
    font-size: 15px;
    border-radius: 5px;
  }

  .btn-primary,
  .btn-secondary {
    min-height: 40px;
    font-size: 13px;
    padding: 10px;
  }

  .sidebar {
    width: 200px;
  }

  .main-content {
    margin-left: 200px;
    width: calc(100% - 200px);
    padding: 20px;
  }

  .status-table {
    font-size: 12px;
  }

  .status-table th,
  .status-table td {
    padding: 8px 5px;
  }

  /* Available Payslips section for 600px */
  .payslips-table th {
    padding: 10px 8px;
    font-size: 12px;
  }

  .payslips-table td {
    padding: 10px 8px;
    font-size: 13px;
  }

  .pagination-container {
    gap: 10px;
  }

  .pagination-btn {
    padding: 10px;
    font-size: 13px;
  }

  .btn-link {
    padding: 11px;
    font-size: 14px;
  }

/* Additional tighter mobile tweaks for phones */
@media (max-width: 480px) {

  /* Sidebar hidden by default on small phones; shown when `.mobile-visible` is added */
  .sidebar {
    display: none;
  }

  /* Sidebar visible state for mobile (overlay) */
  .sidebar {
    /* start hidden off-canvas */
    display: flex;
    position: fixed;
    left: 0;
    top: 0;
    width: 65%;
    max-width: 300px;
    height: 100vh;
    z-index: 10000;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.15);
    transform: translateX(-110%);
    transition: transform 240ms ease-out;
    gap: 100px;
  }

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

  .sidebar-footer {
  margin-top: 70px;
  }

  /* Make main content full width and reduce padding */
  .main-content {
    margin-left: 0;
    width: 100%;
    padding: 0;
    min-height: auto;
    max-height: none;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }

  .main-content > * {
    flex-shrink: 0;
  }

  /* Dashboard improvements */
  .dashboard {
    padding: 12px 10px;
    background: white;
    width: 100%;
  }

  /* Hamburger button */
  .hamburger {
    display: none;
    position: fixed;
    top: 16px;
    left: 12px;
    z-index: 10001;
    background: var(--brand-red);
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* show hamburger on small screens */
  .hamburger.show {
    display: block;
  }

  /* Backdrop when sidebar open */
  .mobile-backdrop {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.35);
    z-index: 9999;
  }

  .mobile-backdrop.show {
    display: block;
  }

  /* Dashboard improvements */
  .dashboard {
    padding: 12px 8px 4px 8px;
    background: white;
    width: 100%;
    margin-bottom: 0;
  }

  .dashboard h1 {
    font-size: 20px;
    margin-bottom: 12px;
    line-height: 1.3;
    margin-top: 8px;
    color: white;
    background: var(--brand-red);
    border: 2px solid var(--brand-red);
    padding: 12px 14px;
    border-radius: 6px;
    font-weight: 600;
    width: auto;
    align-self: flex-end;
  }

  .dashboard > p {
    font-size: 13px;
    margin-bottom: 12px;
    line-height: 1.5;
    color: #666;
  }

  .staff-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
    padding: 16px 12px;
    background: #f9f9f9;
    border-radius: 6px;
    border: 1px solid #eee;
  }

  .staff-info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  .staff-info-item strong {
    font-size: 11px;
    color: #666;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .staff-info-item span {
    font-size: 14px;
    color: #333;
    font-weight: 600;
  }

  /* Payslip section styling */
  .payslip-section,
  .upload-section,
  .status-section {
    margin-top: 12px;
    margin-bottom: 8px;
    padding: 12px;
    background: #fafafa;
    border-radius: 8px;
    border: 1px solid #efefef;
  }

  .payslip-section h2,
  .upload-section h2,
  .status-section h2 {
    font-size: 16px;
    margin-bottom: 16px;
    color: #333;
  }

  /* Form improvements */
  .form-container {
    padding: 12px 10px 0 10px;
    max-width: 100%;
    margin: 0;
  }

  .form-logo {
    width: 120px;
  }

  .app-title {
    font-size: 14px;
  }

  .form-group {
    margin-bottom: 14px;
  }

  .form-group label {
    font-size: 13px;
    margin-bottom: 8px;
    display: block;
  }

  .form-group input,
  .form-group select {
    padding: 12px;
    font-size: 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    width: 100%;
  }

  .form-group input:focus,
  .form-group select:focus {
    border-color: var(--brand-red);
    outline: none;
    box-shadow: 0 0 0 3px rgba(217, 35, 34, 0.1);
  }

  .btn-primary {
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 600;
    width: 100%;
    border-radius: 6px;
    margin-top: 4px;
    margin-bottom: 4px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .btn-secondary {
    padding: 12px 14px;
    font-size: 14px;
    min-height: 44px;
  }

  .toggle-text {
    margin: 6px 0 0 0;
    font-size: 12px;
  }

  /* Larger list items for easier tapping */
  .payslip-list {
    background: white;
    padding: 12px;
    border-radius: 6px;
    margin-top: 16px;
    border: 1px solid #eee;
  }

  .payslip-list h2 {
    font-size: 16px;
    margin-bottom: 14px;
  }

  .payslip-list li {
    padding: 12px 0;
    font-size: 14px;
    border-bottom: 1px solid #eee;
  }

  .payslip-list li:last-child {
    border-bottom: none;
  }

  /* Payslip display */
  #payslipContent {
    font-size: 13px;
    max-height: 65vh;
    padding: 12px;
    line-height: 1.6;
    overflow-x: auto;
    overflow-y: auto;
    white-space: pre;
    background: #fafafa;
    border-radius: 6px;
  }

  .payslip-display {
    padding: 12px;
    margin-top: 12px;
  }

  .payslip-display h2 {
    font-size: 15px;
    margin-bottom: 12px;
  }

  .payslip-actions {
    margin-bottom: 12px;
  }

  /* Available Payslips section */
  #availablePayslipsSection {
    padding: 8px 0;
  }

  .btn-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 12px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 6px;
    color: var(--brand-red);
    text-decoration: none;
    cursor: pointer;
  }

  .payslips-table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 12px;
  }

  .payslips-table {
    width: 100%;
    font-size: 12px;
  }

  .payslips-table thead {
    background: #f0f0f0;
  }

  .payslips-table th {
    padding: 10px 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
    font-weight: 600;
  }

  .payslips-table td {
    padding: 10px 8px;
    font-size: 12px;
  }

  .payslips-table tbody tr {
    border-bottom: 1px solid #eee;
  }

  /* Pagination improvements */
  .pagination-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
    padding: 12px;
    background: #f9f9f9;
    border-radius: 6px;
    border: 1px solid #eee;
  }

  .pagination-info {
    text-align: center;
    font-size: 12px;
    color: #666;
  }

  .pagination-controls {
    display: flex;
    flex-direction: row;
    gap: 6px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
  }

  .pagination-controls > span {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 11px;
    order: 1;
  }

  .pagination-btn {
    padding: 6px 8px;
    font-size: 11px;
    min-height: 32px;
    flex: 0 1 auto;
    border-radius: 4px;
  }

  .pagination-page-input {
    width: 50px;
    padding: 8px;
    font-size: 12px;
    text-align: center;
  }
  }

  .payslip-actions button {
    width: 100%;
    min-height: 44px;
  }

  .download-dropdown {
    margin-bottom: 12px;
  }

  .dropdown-toggle {
    font-size: 14px;
    padding: 12px;
    min-height: 44px;
  }

  .dropdown-item {
    font-size: 13px;
    padding: 12px 14px;
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* Make staff controls stack vertically */
  .staff-controls {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .search-box,
  .filter-group {
    width: 100%;
  }

  .pagination-controls {
    padding: 12px;
    gap: 10px;
    flex-wrap: wrap;
  }

  .pagination-btn {
    flex: 1;
    min-width: auto;
    min-height: 32px;
    padding: 6px 8px;
    font-size: 11px;
  }

  .pagination-page-input {
    width: 50px;
    padding: 8px;
    font-size: 14px;
  }

  .nav-btn {
    font-size: 14px;
    padding: 12px;
    min-height: 44px;
  }

  .btn-link {
    padding: 12px;
    font-size: 14px;
    margin-bottom: 16px;
  }

  .btn-pagination {
    padding: 12px 14px;
    font-size: 14px;
  }

  .btn-logout {
    min-height: 44px;
    font-size: 14px;
  }

  /* Ensure no horizontal overflow */
  html,
  body {
    overflow-x: hidden;
  }
}

/* Download Dropdown Menu Styles */
.download-dropdown {
  position: relative;
  width: 100%;
  display: inline-block;
}

.dropdown-toggle {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 5px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  margin-top: 10px;
}

.dropdown-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.dropdown-toggle:active {
  transform: translateY(0);
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #ddd;
  border-radius: 5px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  margin-top: 5px;
  z-index: 1000;
  overflow: hidden;
}

.dropdown-menu.hidden {
  display: none;
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 12px 16px;
  background: white;
  color: #333;
  border: none;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.dropdown-item:hover {
  background: #f5f5f5;
}

.dropdown-item:active {
  background: #e8e8e8;
}

.dropdown-item:first-child {
  border-top: none;
}

.dropdown-item:not(:last-child) {
  border-bottom: 1px solid #eee;
}

/* Modal: extra mobile tweaks for better readability and touch targets */
@media (max-width: 480px) {
  .modal-content {
    width: 98%;
    max-width: 98%;
    margin: 0 6px;
    border-radius: 8px;
  }

  .modal-header,
  .modal-footer {
    padding: 10px 12px;
  }

  .modal-body {
    padding: 8px 12px;
    overflow: auto;
  }

  .modal-body pre {
  font-size: 12px;
  line-height: 1.5;
  padding: 10px;
  max-height: 70vh;
  overflow-x: auto;
  overflow-y: auto;
  white-space: pre;
  word-wrap: normal;       /* changed */
  word-break: normal;      /* add this */
  -webkit-overflow-scrolling: touch;
}

  .modal-footer {
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
  }

  .modal-footer .btn-primary,
  .modal-footer .btn-secondary,
  .modal-footer button {
    width: 100%;
    padding: 12px;
    font-size: 15px;
  }

  /* Hide PDF download button on mobile */
  #modalDownloadPdf {
    display: none;
  }

  .modal-close {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 18px;
    padding: 6px;
  }

  /* Reduce footer spacing on mobile */
  .site-footer {
    margin: 4px 0 0 0;
    padding: 8px 0;
    font-size: 11px;
  }

  /* Update Profile Section Mobile */
  .profile-container {
    padding: 24px 16px;
    margin-top: 20px;
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  }

  .profile-container h2 {
    font-size: 22px;
    margin-bottom: 24px;
  }

  .update-profile-form {
    gap: 16px;
  }

  .update-profile-form label {
    font-size: 13px;
  }

  .update-profile-form input,
  .update-profile-form select {
    padding: 11px 12px;
    font-size: 16px;
    border-radius: 5px;
  }

  .form-actions {
    gap: 10px;
    margin-top: 20px;
  }

  .form-actions .btn-secondary,
  .form-actions .btn-primary {
    flex: 1;
    min-width: 110px;
    padding: 11px 14px;
    font-size: 14px;
    border-radius: 5px;
  }

  #updateProfileMessage {
    font-size: 13px;
    padding: 12px 14px;
  }
}

/* Dark overlay shown on logout for mobile users */
.logout-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 9999;
  display: none;
}

.logout-overlay.visible {
  opacity: 1;
  pointer-events: auto;
  display: block;
}

/* Remove dark overlay from logout modal on mobile */
@media (max-width: 480px) {
  .logout-modal-mobile {
    background: transparent !important;
  }
}

#payslipModal .modal-body,
#payslipModal .modal-body pre {
  touch-action: pan-x pan-y;
}