:root {
  --bg: #f8fafc;
  --sidebar-bg: #ffffff;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --green: #10b981;
  --red: #ef4444;
  --orange: #f59e0b;
  --purple: #8b5cf6;
  --grad: linear-gradient(135deg, #4f46e5, #8b5cf6);
  --shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.04), 0 4px 12px -2px rgba(0, 0, 0, 0.02);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* SIDEBAR */
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 200;
  transition: transform .3s;
}

.sidebar-close {
  display: none;
  position: absolute;
  top: 20px;
  right: 15px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: all 0.2s;
}

.sidebar-close:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.3);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.4rem;
  font-weight: 800;
  padding: 0 24px 30px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo i {
  background: var(--grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 1.8rem;
}

.grad {
  background: var(--grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 12px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(79, 70, 229, 0.3) transparent;
}

.sidebar-nav::-webkit-scrollbar {
  width: 5px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(79, 70, 229, 0.3), rgba(139, 92, 246, 0.3));
  border-radius: 10px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #4f46e5, #8b5cf6);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 500;
  font-size: .95rem;
  transition: all .2s;
  text-decoration: none;
}

.nav-item i {
  width: 18px;
  text-align: center;
}

.nav-item:hover {
  background: rgba(0, 0, 0, 0.02);
  color: var(--text);
}

.nav-item.active {
  background: rgba(79, 70, 229, 0.08);
  color: var(--primary);
  border: 1px solid rgba(79, 70, 229, 0.15);
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .85rem;
  color: var(--muted);
}

/* MAIN */
.main-content {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0; /* Resolve flex minimum width expansion bug */
}

/* TOPBAR */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 32px;
  background: rgba(255, 255, 255, .8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
}

.topbar-title {
  font-size: 1.2rem;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}

.live-clock {
  font-size: .9rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.avatar {
  width: 38px;
  height: 38px;
  background: var(--grad);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

/* TABS */
.tab-section {
  display: none;
  padding: 32px;
  animation: fadeUp .4s ease;
  max-width: 100%;
  box-sizing: border-box;
}

.tab-section.active {
  display: block;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* CARDS */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  margin-bottom: 24px;
  max-width: 100%;
  box-sizing: border-box;
}

.card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.card h3 i {
  color: var(--primary);
}

/* STAT CARDS */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  transition: transform .2s;
}

.stat-card:hover {
  transform: translateY(-4px);
}

.stat-icon {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-icon.blue {
  background: rgba(59, 130, 246, .12);
  color: var(--primary);
}

.stat-icon.green {
  background: rgba(16, 185, 129, .12);
  color: var(--green);
}

.stat-icon.purple {
  background: rgba(139, 92, 246, .12);
  color: var(--purple);
}

.stat-icon.orange {
  background: rgba(245, 158, 11, .12);
  color: var(--orange);
}

.stat-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stat-num {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}

.stat-label {
  font-size: .8rem;
  color: var(--muted);
  margin-top: 4px;
}

/* DASH GRID */
.dash-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 24px;
}

/* DONUT */
.donut-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  margin: 10px 0;
}

.donut-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.4rem;
  font-weight: 800;
}

.donut-legend {
  display: flex;
  justify-content: center;
  gap: 24px;
  font-size: .85rem;
  color: var(--muted);
  margin-top: 10px;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}

.green-dot {
  background: var(--green);
}

.red-dot {
  background: var(--red);
}

/* SECTION HEADERS (Unified) */
.section-bar,
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 20px;
}

.section-bar h2,
.section-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0;
}

.section-header p {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 4px;
}

@media(max-width: 1024px) {

  .section-bar,
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .section-bar .btn,
  .section-header .btn {
    width: auto;
    justify-content: flex-start;
  }
}

@media(max-width: 640px) {

  .section-bar .btn,
  .section-header .btn {
    width: 100% !important;
    justify-content: center !important;
  }
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 50px;
  font-family: inherit;
  font-weight: 600;
  font-size: .95rem;
  cursor: pointer;
  border: none;
  transition: all .25s;
}

.btn-primary {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 4px 14px rgba(79, 70, 229, .25);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(79, 70, 229, .35);
}

.btn-ghost {
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: rgba(0, 0, 0, .02);
}

.full-width {
  width: 100%;
  justify-content: center;
}

/* FORMS */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: .85rem;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-group input, .form-group select{width:100%;padding:12px 14px;background:#ffffff;border:1px solid var(--border);border-radius:12px;color:var(--text);font-family:inherit;font-size:.95rem;outline:none;transition:border .2s;color-scheme:light;}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px;
}

.form-group select option{background:#ffffff;color:var(--text);padding:12px;}

.hint {
  color: var(--muted);
  font-size: .75rem;
  font-weight: 400;
}

.pay-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: end;
}

.search-box {
  width: 100%;
  padding: 10px 16px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  font-size: .9rem;
  outline: none;
  margin-bottom: 18px;
}

.search-box:focus {
  border-color: var(--primary);
}

/* PROFESSIONAL TABLE STYLING */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.92rem;
}

.table th {
  text-align: center;
  padding: 16px 20px;
  color: var(--muted);
  font-weight: 600;
  background: rgba(0, 0, 0, 0.015);
  border-bottom: 2px solid var(--border);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.table td {
  text-align: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  transition: background 0.2s;
}

.table tr:last-child td {
  border-bottom: none;
}

.table tr:hover td {
  background: rgba(0, 0, 0, 0.01);
}

/* Backwards compatibility for data-table */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Client Visits Log Table — Fixed Layout to prevent stretch ── */
#tab-client-visits .table-responsive {
  overflow-x: auto;
  border-radius: 12px;
}

#tab-client-visits .data-table {
  table-layout: fixed;
  width: 100%;
  min-width: 1600px;
  font-size: 0.82rem;
}

#tab-client-visits .data-table th,
#tab-client-visits .data-table td {
  padding: 10px 10px;
  vertical-align: middle;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Column widths — total = 100% */
#tab-client-visits .data-table th:nth-child(1),
#tab-client-visits .data-table td:nth-child(1) { width: 9%; } /* Staff */
#tab-client-visits .data-table th:nth-child(2),
#tab-client-visits .data-table td:nth-child(2) { width: 9%; } /* Client */
#tab-client-visits .data-table th:nth-child(3),
#tab-client-visits .data-table td:nth-child(3) { width: 8%; }  /* Purpose */
#tab-client-visits .data-table th:nth-child(4),
#tab-client-visits .data-table td:nth-child(4) { width: 7%;  } /* Date */
#tab-client-visits .data-table th:nth-child(5),
#tab-client-visits .data-table td:nth-child(5) { width: 7%;  } /* Check-In */
#tab-client-visits .data-table th:nth-child(6),
#tab-client-visits .data-table td:nth-child(6) { width: 7%;  } /* Check-Out */
#tab-client-visits .data-table th:nth-child(7),
#tab-client-visits .data-table td:nth-child(7) { width: 9%; } /* Duration */
#tab-client-visits .data-table th:nth-child(8),
#tab-client-visits .data-table td:nth-child(8) { width: 10%; font-size: 0.76rem; padding-right: 15px; } /* GPS */
#tab-client-visits .data-table th:nth-child(9),
#tab-client-visits .data-table td:nth-child(9) { width: 11%; font-size: 0.78rem; } /* Address */
#tab-client-visits .data-table th:nth-child(10),
#tab-client-visits .data-table td:nth-child(10) { width: 11%; min-width: 140px; text-align: center; } /* Status */
#tab-client-visits .data-table th:nth-child(11),
#tab-client-visits .data-table td:nth-child(11) { width: 12%; min-width: 160px; text-align: center; } /* Verification */

/* KPI stat cards in client visits — stay in row without overflow */
#tab-client-visits .stat-cards {
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 20px;
}

/* ── Employee Management Table — Fixed Layout to prevent stretch ── */
#tab-employees .table-responsive {
  overflow-x: auto;
  border-radius: 12px;
}

#tab-employees .data-table {
  table-layout: fixed;
  width: 100%;
  min-width: 1200px;
  font-size: 0.82rem;
}

#tab-employees .data-table th,
#tab-employees .data-table td {
  padding: 10px 8px;
  vertical-align: middle;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Column widths — total = 100% */
#tab-employees .data-table th:nth-child(1),
#tab-employees .data-table td:nth-child(1) { width: 3%; } /* Checkbox */
#tab-employees .data-table th:nth-child(2),
#tab-employees .data-table td:nth-child(2) { width: 8%; } /* ID */
#tab-employees .data-table th:nth-child(3),
#tab-employees .data-table td:nth-child(3) { width: 10%; } /* Password */
#tab-employees .data-table th:nth-child(4),
#tab-employees .data-table td:nth-child(4) { width: 9%; } /* Joining Date */
#tab-employees .data-table th:nth-child(5),
#tab-employees .data-table td:nth-child(5) { width: 11%; } /* Name */
#tab-employees .data-table th:nth-child(6),
#tab-employees .data-table td:nth-child(6) { width: 10%; } /* Branch */
#tab-employees .data-table th:nth-child(7),
#tab-employees .data-table td:nth-child(7) { width: 9%; } /* Role */
#tab-employees .data-table th:nth-child(8),
#tab-employees .data-table td:nth-child(8) { width: 11%; } /* Monthly Salary */
#tab-employees .data-table th:nth-child(9),
#tab-employees .data-table td:nth-child(9) { width: 9%; } /* Daily Salary */
#tab-employees .data-table th:nth-child(10),
#tab-employees .data-table td:nth-child(10) { width: 9%; } /* Hourly Salary */
#tab-employees .data-table th:nth-child(11),
#tab-employees .data-table td:nth-child(11) { width: 5%; text-align: center; } /* Push */
#tab-employees .data-table th:nth-child(12),
#tab-employees .data-table td:nth-child(12) { width: 6%; text-align: center; } /* Actions */

/* BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
  white-space: nowrap;
  vertical-align: middle;
}

.badge-green {
  background: rgba(16, 185, 129, .12);
  color: var(--green);
}

.badge-red {
  background: rgba(239, 68, 68, .12);
  color: var(--red);
}

.badge-blue {
  background: rgba(59, 130, 246, .12);
  color: var(--primary);
}

.badge-orange {
  background: rgba(245, 158, 11, .12);
  color: var(--orange);
}


/* ACTION BTNS */
.action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: .9rem;
  transition: background .2s;
}

.action-btn.edit {
  color: var(--primary);
}

.action-btn.edit:hover {
  background: rgba(59, 130, 246, .12);
}

.action-btn.del {
  color: var(--red);
}

.action-btn.del:hover {
  background: rgba(239, 68, 68, .12);
}

.action-btn.unbind {
  color: var(--orange);
}

.action-btn.unbind:hover {
  background: rgba(245, 158, 11, .12);
}

/* ATTENDANCE */
.att-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  align-items: start;
}

.checkin-card {}

.face-scanner {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  border-radius: 20px;
  overflow: hidden;
  border: 2px solid var(--border);
}

.scan-ring {
  position: absolute;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  border: 2px solid rgba(79, 70, 229, .3);
}

.scan-icon {
  font-size: 5rem;
  color: rgba(0, 0, 0, .05);
  z-index: 1;
}

.scan-bar {
  position: absolute;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  top: 0;
  animation: scanDown 2s infinite linear;
  opacity: 0;
}

@keyframes scanDown {
  0% {
    top: 0;
    opacity: 0;
  }

  10% {
    opacity: 1;
  }

  90% {
    opacity: 1;
  }

  100% {
    top: 100%;
    opacity: 0;
  }
}

.face-scanner.scanning .scan-bar {
  opacity: 1;
}

.face-scanner.scanning .scan-ring {
  border-color: var(--primary);
  animation: pulse-ring 1s infinite;
}

.face-scanner.success .scan-ring {
  border-color: var(--green);
}

.face-scanner.fail .scan-ring {
  border-color: var(--red);
}

@keyframes pulse-ring {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, .4);
  }

  50% {
    box-shadow: 0 0 0 12px rgba(59, 130, 246, 0);
  }
}

/* WEBCAM inside scanner */
#webcamVideo {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 18px;
  opacity: 0;
  transition: opacity .4s;
}

#webcamVideo.active {
  opacity: 1;
}

#webcamCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.gps-status {
  padding: 10px 16px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid var(--border);
  font-size: .85rem;
  color: var(--muted);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.gps-status.ok {
  border-color: rgba(16, 185, 129, .3);
  color: var(--green);
  background: rgba(16, 185, 129, .08);
}

.gps-status.fail {
  border-color: rgba(239, 68, 68, .3);
  color: var(--red);
  background: rgba(239, 68, 68, .08);
}

.check-msg {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: .9rem;
  display: none;
}

.check-msg.ok {
  background: rgba(16, 185, 129, .1);
  border: 1px solid rgba(16, 185, 129, .25);
  color: var(--green);
  display: block;
}

.check-msg.fail {
  background: rgba(239, 68, 68, .1);
  border: 1px solid rgba(239, 68, 68, .25);
  color: var(--red);
  display: block;
}

/* BRANCHES */
.branches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.branch-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  position: relative;
  transition: transform .2s;
}

.branch-card:hover {
  transform: translateY(-4px);
}

.branch-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.branch-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  flex: 1;
  min-width: 150px;
  line-height: 1.4;
}

.branch-city {
  color: var(--muted);
  font-size: .85rem;
  margin-bottom: 8px;
}

.branch-address {
  font-size: .82rem;
  color: var(--text-muted, #94a3b8);
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.5;
}

.branch-address i {
  color: var(--primary);
  margin-top: 2px;
  flex-shrink: 0;
  font-size: .8rem;
}

.branch-coords {
  font-size: .8rem;
  font-family: monospace;
  color: var(--primary);
  background: rgba(59, 130, 246, .08);
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.branch-del {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  transition: color .2s;
}

.branch-del:hover {
  color: var(--red);
}

.empty-card {
  grid-column: 1/-1;
  text-align: center;
  color: var(--muted);
  padding: 60px;
  background: var(--card-bg);
  border: 1px dashed var(--border);
  border-radius: 18px;
}

/* PAYROLL */
.payroll-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 0;
}

.slip-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 300px;
  color: var(--muted);
  gap: 16px;
}

.slip-placeholder i {
  font-size: 3rem;
  opacity: .3;
}

.slip-output {}

.slip-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.slip-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.slip-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}

.slip-row span:first-child {
  color: var(--muted);
}

.slip-row.total {
  border-top: 2px solid var(--border);
  border-bottom: none;
  margin-top: 8px;
  padding-top: 14px;
  font-size: 1.1rem;
  font-weight: 800;
}

.slip-row.total span:last-child {
  background: var(--grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.slip-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.mt-30 {
  margin-top: 0;
}

/* MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  backdrop-filter: blur(6px);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 24px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow);
  animation: slideUp .3s ease;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
  transition: color .2s;
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 24px 28px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 28px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: #f8fafc;
  border-radius: 0 0 24px 24px;
}

/* Custom scrollbar — modal body */
.modal-body::-webkit-scrollbar {
  width: 5px;
}

.modal-body::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #4f46e5, #8b5cf6);
  border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #3730a3, #7c3aed);
}

.modal-body {
  scrollbar-width: thin;
  scrollbar-color: #4f46e5 transparent;
}

/* TOAST */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 20px;
  font-size: .9rem;
  z-index: 1000;
  opacity: 0;
  transform: translateY(10px);
  transition: all .3s;
  pointer-events: none;
  box-shadow: var(--shadow);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success {
  border-color: rgba(16, 185, 129, .3);
  color: var(--green);
}

.toast.error {
  border-color: rgba(239, 68, 68, .3);
  color: var(--red);
}

/* COORDINATE SECTION */
.coord-section {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
}

.coord-label {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.coord-label i {
  color: var(--primary);
}

.coord-hint-toggle {
  margin-left: auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(59, 130, 246, .15);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid rgba(59, 130, 246, .25);
  flex-shrink: 0;
}

.coord-hint-toggle:hover {
  background: rgba(59, 130, 246, .25);
}

.coord-help-box {
  margin-top: 10px;
  padding: 12px 14px;
  background: rgba(59, 130, 246, .06);
  border: 1px solid rgba(59, 130, 246, .15);
  border-radius: 10px;
  font-size: .82rem;
  color: #93c5fd;
  line-height: 1.6;
}

.coord-help-box b {
  color: var(--text);
}

.coord-tag {
  font-size: .7rem;
  font-weight: 600;
  background: rgba(139, 92, 246, .15);
  color: var(--purple);
  border: 1px solid rgba(139, 92, 246, .2);
  padding: 1px 7px;
  border-radius: 20px;
  margin-left: 4px;
  vertical-align: middle;
}

.field-hint {
  font-size: .75rem;
  color: var(--muted);
  margin-top: 5px;
}

.address-preview {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(16, 185, 129, .08);
  border: 1px solid rgba(16, 185, 129, .2);
  border-radius: 10px;
  font-size: .83rem;
  color: var(--green);
}

.address-preview i {
  margin-top: 2px;
  flex-shrink: 0;
}

/* ======= RESPONSIVE TABLES (card-row pattern) ======= */
@media(max-width:640px) {

  /* Admin tables */
  .data-table {
    display: block;
    width: 100%;
    white-space: normal;
    overflow-x: visible;
  }

  .data-table tbody {
    display: block;
    width: 100%;
  }

  .data-table thead {
    display: none;
  }

  .data-table tr {
    display: block;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 10px;
    overflow: hidden;
  }

  .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    font-size: .88rem;
    white-space: normal;
  }

  .data-table td:last-child {
    border-bottom: none;
  }

  .data-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: .76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
    flex-shrink: 0;
    margin-right: 12px;
  }

  .data-table td:empty {
    display: none;
  }

  /* Employee portal tables */
  .emp-table thead {
    display: none;
  }

  .emp-table tr {
    display: block;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 10px;
    overflow: hidden;
  }

  .emp-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    font-size: .88rem;
    white-space: normal;
  }

  .emp-table td:last-child {
    border-bottom: none;
  }

  .emp-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: .76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
    flex-shrink: 0;
    margin-right: 12px;
  }
}

/* ======= RESPONSIVE ======= */

/* --- 1200px: Large tablets / small desktops --- */
@media(max-width:1200px) {
  .stat-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .dash-grid {
    grid-template-columns: 1fr;
  }

  .payroll-wrap {
    grid-template-columns: 1fr;
  }

  .att-grid {
    grid-template-columns: 1fr;
  }

  .feature-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* --- 1024px: Tablets --- */
@media(max-width:1024px) {
  .hero-title {
    font-size: 2.8rem;
  }

  .payroll-container {
    grid-template-columns: 1fr;
  }

  .section-heading h2 {
    font-size: 2rem;
  }
}

/* --- 900px: Sidebar + content shift --- */
@media(max-width:900px) {
  .stat-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .branches-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* --- 768px: Mobile landscape --- */
@media(max-width:768px) {

  /* Sidebar becomes a drawer */
  .sidebar {
    transform: translateX(-100%);
    z-index: 9999;
    box-shadow: 4px 0 30px rgba(0, 0, 0, .5);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: flex;
  }

  .main-content {
    margin-left: 0;
  }

  .menu-toggle {
    display: block;
  }

  /* Topbar */
  .topbar {
    padding: 12px 16px;
  }

  .topbar-title {
    font-size: 1rem;
  }

  .live-clock {
    display: none;
  }

  /* Tabs */
  .tab-section {
    padding: 16px;
  }

  /* Stat cards */
  .stat-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .stat-num {
    font-size: 1.6rem;
  }

  .stat-icon {
    width: 44px;
    height: 44px;
    font-size: 1.1rem;
  }

  /* Dashboard grid */
  .dash-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  /* Section bar */
  .section-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .section-bar .btn {
    width: auto;
    justify-content: flex-start;
  }

  /* Cards */
  .card {
    padding: 18px;
  }

  /* Tables — horizontal scroll */
  .data-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .data-table::-webkit-scrollbar {
    height: 4px;
  }

  .data-table::-webkit-scrollbar-thumb {
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    border-radius: 10px;
  }

  /* Attendance grid */
  .att-grid {
    grid-template-columns: 1fr;
  }

  /* Payroll */
  .payroll-wrap {
    grid-template-columns: 1fr;
  }

  .pay-row {
    grid-template-columns: 1fr;
  }

  /* Branches */
  .branches-grid {
    grid-template-columns: 1fr;
  }

  /* Modal */
  .modal {
    max-width: 100%;
    margin: 12px;
    border-radius: 18px;
  }

  .modal-header {
    padding: 18px 20px;
  }

  .modal-body {
    padding: 18px 20px;
  }

  .modal-footer {
    padding: 14px 20px 18px;
    flex-direction: row;
  }

  .modal-footer .btn {
    flex: 1;
    justify-content: center;
  }

  /* Coord section */
  .pay-row.coord-row {
    grid-template-columns: 1fr;
  }

  /* Slip actions */
  .slip-actions {
    flex-direction: column;
  }

  .slip-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* Payroll history table action column */
  .payroll-wrap .card {
    padding: 16px;
  }
}

/* --- 480px: Mobile portrait --- */
@media(max-width:480px) {
  .stat-cards {
    grid-template-columns: 1fr;
  }

  .pay-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 10px 12px;
  }

  .tab-section {
    padding: 12px;
  }

  .card {
    padding: 14px;
    border-radius: 14px;
  }

  .section-heading h2 {
    font-size: 1.6rem;
  }

  .stat-card {
    padding: 16px;
    gap: 12px;
  }

  .hero-title {
    font-size: 2rem;
  }

  /* Payroll slip */
  .slip-header-row {
    flex-direction: column;
    gap: 10px;
  }

  /* Modal full-screen on very small devices */
  .modal-overlay {
    align-items: flex-end;
  }

  .modal {
    border-radius: 20px 20px 0 0;
    max-height: 95vh;
    margin: 0;
  }
}

/* --- Sidebar overlay backdrop on mobile --- */
@media(max-width:768px) {
  .sidebar.open ~ .sidebar-backdrop {
    display: block;
  }
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 9998;
  backdrop-filter: blur(2px);
}

/* --- Section Actions responsive layout --- */
.section-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

@media(max-width: 600px) {
  .topbar-admin-details {
    display: none !important;
  }
  .topbar-admin-wrapper {
    border-left: none !important;
    padding-left: 0 !important;
  }
}

@media(max-width: 480px) {
  .lang-select {
    padding: 6px 8px !important;
    font-size: 0.8rem !important;
    margin-right: 8px !important;
  }
  .section-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
  .section-actions .btn {
    width: 100%;
    justify-content: center;
  }
  .section-actions .badge {
    text-align: center;
    width: 100%;
  }
}


/* ======= PRINT — Only Salary Slip ======= */
@media print {

  /* Hide everything except the main content area for simplicity during print targeting */
  .sidebar,
  .topbar,
  .sidebar-backdrop,
  .section-bar,
  .payroll-form-card,
  .mt-30,
  .modal-overlay,
  .toast,
  .menu-toggle,
  .live-clock,
  .avatar {
    display: none !important;
  }

  /* Reset main content layout */
  .main-content {
    margin-left: 0 !important;
    padding: 0 !important;
    display: block !important;
  }

  /* Hide all tab sections except the payroll one */
  .tab-section {
    display: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .tab-section#tab-payroll {
    display: block !important;
  }

  /* Within payroll, hide the history and the form */
  #tab-payroll>*:not(.payroll-wrap) {
    display: none !important;
  }

  .payroll-wrap {
    display: block !important;
  }

  .payroll-wrap>.payroll-form-card {
    display: none !important;
  }

  .salary-slip-card {
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: none !important;
    box-shadow: none !important;
  }

  /* Ensure only slipOutput is visible and fills the page */
  #slipOutput {
    display: block !important;
    background: #fff !important;
    color: #111 !important;
    padding: 20px;
    font-family: 'Outfit', Arial, sans-serif;
  }

  /* Clean up slip rows for print */
  #slipOutput .slip-row {
    border-bottom: 1px solid #ddd !important;
  }

  #slipOutput .slip-row span:first-child {
    color: #555 !important;
  }

  #slipOutput .slip-header-row {
    border-bottom: 2px solid #111 !important;
  }

  #slipOutput .slip-row.total {
    border-top: 2px solid #111 !important;
    font-size: 1.2rem;
  }

  #slipOutput .slip-row.total span:last-child {
    background: none !important;
    -webkit-text-fill-color: #1a56db !important;
    color: #1a56db !important;
  }

  #slipOutput .badge {
    background: #e6f9f1 !important;
    color: #059669 !important;
    border: 1px solid #059669 !important;
  }

  /* Hide Print/Download buttons inside slip */
  #slipOutput .slip-actions {
    display: none !important;
  }
}

/* ============================================================
   ADMIN LOGIN OVERLAY
   ============================================================ */
.admin-login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at 10% 20%, #f8fafc 0%, #e2e8f0 100%);
  z-index: 10000;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: 'Outfit', sans-serif;
}

.login-card {
  background: #ffffff;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 30px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
  animation: fadeIn 0.4s ease;
}

.login-header {
  text-align: center;
  margin-bottom: 30px;
}

.login-header i {
  font-size: 2.8rem;
  margin-bottom: 12px;
  background: var(--grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

.login-header h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
}

.login-card .form-group {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
}

.login-card .form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.login-card .form-group input {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 12px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-card .form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.logout-btn {
  transition: all 0.2s ease;
}

.logout-btn:hover {
  background: rgba(239, 68, 68, 0.15) !important;
  color: #ef4444 !important;
  border-color: rgba(239, 68, 68, 0.4) !important;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   LIVE GPS TRACKING TAB
   ============================================================ */
.tracking-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  align-items: start;
}

.tracking-map-card {
  min-height: 560px;
}

.tracking-list-card {
  max-height: 600px;
  display: flex;
  flex-direction: column;
}

.tracking-emp-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 460px;
  padding-right: 4px;
}

.tracking-emp-list::-webkit-scrollbar {
  width: 4px;
}
.tracking-emp-list::-webkit-scrollbar-track {
  background: transparent;
}
.tracking-emp-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
}

.tracking-emp-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.tracking-emp-item:hover {
  background: rgba(59,130,246,0.08);
  border-color: rgba(59,130,246,0.2);
  transform: translateX(2px);
}

.tracking-emp-item.active {
  background: rgba(59,130,246,0.1);
  border-color: rgba(59,130,246,0.3);
}

.tracking-emp-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
  position: relative;
}

.tracking-emp-avatar.online {
  background: rgba(16,185,129,0.15);
  color: #10b981;
  border: 1px solid rgba(16,185,129,0.3);
}

.tracking-emp-avatar.idle {
  background: rgba(245,158,11,0.15);
  color: #f59e0b;
  border: 1px solid rgba(245,158,11,0.3);
}

.tracking-emp-avatar.unexpected {
  background: rgba(239,68,68,0.15);
  color: #ef4444;
  border: 1px solid rgba(239,68,68,0.3);
  box-shadow: 0 0 8px rgba(239,68,68,0.2);
}

.tracking-emp-avatar.stale {
  background: rgba(245,158,11,0.15);
  color: #f59e0b;
  border: 1px solid rgba(245,158,11,0.2);
}

.tracking-emp-avatar.offline {
  background: rgba(107,114,128,0.15);
  color: #9ca3af;
  border: 1px solid rgba(107,114,128,0.2);
}

.tracking-pulse {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--card-bg);
  z-index: 2;
}

.tracking-pulse.online {
  background: #10b981;
  animation: trackPulseGreen 2s infinite;
}

.tracking-pulse.idle {
  background: #f59e0b;
  animation: trackPulseYellow 2s infinite;
}

.tracking-pulse.unexpected {
  background: #ef4444;
  animation: trackPulseRed 1.2s infinite;
}

.tracking-pulse.stale {
  background: #f59e0b;
  animation: trackPulseYellow 2.5s infinite;
}

.tracking-pulse.offline {
  background: #9ca3af;
}

@keyframes trackPulseGreen {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.5); }
  50% { box-shadow: 0 0 0 6px rgba(16,185,129,0); }
}

@keyframes trackPulseYellow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245,158,11,0.5); }
  50% { box-shadow: 0 0 0 6px rgba(245,158,11,0); }
}

@keyframes trackPulseRed {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.6); transform: scale(1); }
  50% { box-shadow: 0 0 0 8px rgba(239,68,68,0); transform: scale(1.15); }
}

.tracking-emp-info {
  flex: 1;
  min-width: 0;
}

.tracking-emp-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tracking-emp-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tracking-emp-coords {
  font-size: 0.7rem;
  color: var(--primary);
  font-family: 'Outfit', monospace;
  margin-top: 2px;
}

.tracking-emp-time {
  font-size: 0.72rem;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}

/* Leaflet custom popup styling */
.tracking-popup {
  font-family: 'Outfit', sans-serif;
}

.tracking-popup .leaflet-popup-content-wrapper {
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.tracking-popup .leaflet-popup-tip {
  background: #ffffff;
  border: 1px solid var(--border);
}

.tracking-popup .leaflet-popup-close-button {
  color: var(--muted);
}

/* Map empty state */
.map-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  gap: 12px;
}

.map-empty-state i {
  font-size: 3rem;
  opacity: 0.2;
}

@media (max-width: 1024px) {
  .tracking-layout {
    grid-template-columns: 1fr;
  }
  .tracking-list-card {
    max-height: 400px;
  }
}

@media (max-width: 768px) {
  #trackingMap {
    height: 350px !important;
  }
  .tracking-map-card {
    min-height: auto;
  }
}

/* Leave quota grid inside add employee modal */
.leave-quota-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  align-items: end;
}
@media(max-width:600px) {
  .leave-quota-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

/* Responsive login card on mobile devices */
@media(max-width:480px) {
  .login-card {
    margin: 16px;
    padding: 28px 20px;
    border-radius: 16px;
  }
}

/* Tablet viewport specific table min-width adjustments to prevent content squeezing */
@media (max-width: 1024px) and (min-width: 641px) {
  .table-responsive .data-table {
    display: table !important;
    width: 100% !important;
    min-width: 850px !important;
  }
}

/* ======================================== */
/* ATTENDANCE HISTORY VIEWER STYLES         */
/* ======================================== */

/* Today's Attendance Date Picker Row */
.today-att-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.today-att-header h3 {
  margin-bottom: 0;
  flex: 1;
  min-width: 180px;
}

.today-att-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.today-att-controls input[type="date"] {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: border 0.2s, box-shadow 0.2s;
  color-scheme: light;
}

.today-att-controls input[type="date"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.att-record-count {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(79, 70, 229, 0.08);
  color: var(--primary);
  white-space: nowrap;
}

/* History Button */
.btn-history {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #fff;
  padding: 8px 18px;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.25s;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.2);
  font-family: inherit;
}

.btn-history:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(59, 130, 246, 0.3);
}

/* Attendance History Modal */
.history-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
  animation: historyFadeIn 0.3s ease;
}

.history-modal-overlay.open {
  display: flex;
}

@keyframes historyFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.history-modal {
  background: var(--card-bg);
  border-radius: 24px;
  border: 1px solid var(--border);
  box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.15);
  width: 100%;
  max-width: 1100px;
  animation: historySlideUp 0.35s ease;
  margin: auto;
}

@keyframes historySlideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.history-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px;
  border-bottom: 1px solid var(--border);
}

.history-modal-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: var(--text);
}

.history-modal-header h3 i {
  background: var(--grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 1.3rem;
}

.history-modal-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.history-modal-close:hover {
  background: rgba(239, 68, 68, 0.08);
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.3);
}

.history-modal-body {
  padding: 24px 28px;
}

/* Filter Row */
.history-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
  align-items: end;
}

.history-filters .form-group {
  margin-bottom: 0;
}

.history-filters .form-group label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 5px;
}

.history-filter-actions {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

/* Summary Stats Row */
.history-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.history-stat {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.04), rgba(139, 92, 246, 0.04));
  border: 1px solid rgba(79, 70, 229, 0.1);
  border-radius: 14px;
  padding: 16px 18px;
  text-align: center;
  transition: transform 0.2s;
}

.history-stat:hover {
  transform: translateY(-2px);
}

.history-stat .stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.history-stat .stat-title {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

/* History Table */
.history-table-wrap {
  overflow-x: auto;
  border-radius: 14px;
  border: 1px solid var(--border);
  margin-bottom: 18px;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.history-table th {
  background: rgba(79, 70, 229, 0.04);
  padding: 12px 14px;
  text-align: left;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.history-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.history-table tbody tr:last-child td {
  border-bottom: none;
}

.history-table tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.015);
}

.history-table tbody tr:hover {
  background: rgba(79, 70, 229, 0.03);
}

/* Pagination */
.history-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.history-pagination-info {
  font-size: 0.82rem;
  color: var(--muted);
}

.history-pagination-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-page-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-family: inherit;
}

.history-page-btn:hover:not(:disabled) {
  background: rgba(79, 70, 229, 0.06);
  border-color: var(--primary);
  color: var(--primary);
}

.history-page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.history-page-btn.active {
  background: var(--grad);
  color: #fff;
  border-color: transparent;
}

.history-per-page {
  padding: 6px 28px 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
}

/* Export Buttons */
.history-export-row {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.btn-export {
  padding: 7px 16px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-export:hover {
  background: rgba(79, 70, 229, 0.06);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-export.csv {
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--green);
}

.btn-export.csv:hover {
  background: rgba(16, 185, 129, 0.06);
}

.btn-export.pdf {
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--red);
}

.btn-export.pdf:hover {
  background: rgba(239, 68, 68, 0.06);
}

/* History empty state */
.history-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.history-empty i {
  font-size: 3rem;
  opacity: 0.2;
  display: block;
  margin-bottom: 14px;
}

.history-empty p {
  font-size: 0.9rem;
}

/* Nav label for Attendance History */
.nav-item.nav-history {
  font-size: 0.88rem;
}

/* Responsive History Modal */
@media (max-width: 768px) {
  .history-modal-overlay {
    padding: 12px;
  }
  
  .history-modal {
    border-radius: 18px;
  }
  
  .history-modal-header {
    padding: 18px 20px;
  }
  
  .history-modal-body {
    padding: 18px 20px;
  }
  
  .history-filters {
    grid-template-columns: 1fr;
  }
  
  .history-summary {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .today-att-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .history-summary {
    grid-template-columns: 1fr;
  }
  
  .history-pagination {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
  
  .history-pagination-controls {
    justify-content: center;
  }
}

/* Ensure photo verification modal displays on top of other modals like historyModal */
#photoModal {
  z-index: 1000;
}

/* Invalid/Missing required fields highlighting */
.form-group input.invalid,
.form-group select.invalid,
.form-group textarea.invalid {
  border-color: var(--red) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}

.invalid-feedback {
  display: block;
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 500;
  margin-top: 5px;
  animation: fadeUp .2s ease;
}

/* Highlight Face Registration Card */
.form-group:has(#empFaceDescriptor.invalid) {
  border-color: var(--red) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}

/* Bulk Import UI Enhancements */
#bulkImportDropzone.dragover {
  border-color: var(--purple) !important;
  background: rgba(139, 92, 246, 0.08) !important;
  transform: scale(1.01);
}

.badge-healed {
  background: rgba(139, 92, 246, 0.12) !important;
  color: var(--purple) !important;
  border: 1px solid rgba(139, 92, 246, 0.25) !important;
  font-size: 0.7rem !important;
  padding: 2px 6px !important;
  border-radius: 6px !important;
  font-weight: 600 !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 3px !important;
}

.healed-cell {
  background: rgba(139, 92, 246, 0.06) !important;
  border-left: 3px solid var(--purple) !important;
}

.loader-step-item {
  display: flex;
  align-items: center;
  gap: 8px;
  animation: fadeUp 0.3s ease;
}

.loader-step-item.pending {
  color: var(--muted);
}

.loader-step-item.active {
  color: var(--purple);
  font-weight: 600;
}

.loader-step-item.success {
  color: var(--green);
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.btn-purple {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: #ffffff !important;
  border: none;
}

.btn-purple:hover {
  background: linear-gradient(135deg, #6d28d9, #4338ca);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

/* Employee Table Pagination */
.emp-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
}
.emp-pagination-info {
  font-size: 0.82rem;
  color: var(--muted);
}
.emp-pagination-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}
.emp-page-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-family: inherit;
}
.emp-page-btn:hover:not(:disabled) {
  background: rgba(79, 70, 229, 0.06);
  border-color: var(--primary);
  color: var(--primary);
}
.emp-page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.emp-page-btn.active {
  background: var(--grad);
  color: #fff;
  border-color: transparent;
}