/* ============================================================
   DESIGN SYSTEM — Vazirmatn Variable Font + Turquoise/Purple
   ============================================================ */

/* ── Font ── */
@font-face {
  font-family: 'Vazirmatn';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(../libs/fonts/Vazirmatn-Variable.woff2) format('woff2-variations');
}

/* ── Tokens ── */
:root {
  --primary: #2dd4bf;
  --primary-hover: #14b8a6;
  --primary-light: #ccfbf1;
  --secondary: #8b5cf6;
  --secondary-hover: #7c3aed;
  --secondary-light: #ede9fe;
  --success: #22c55e;
  --success-light: #dcfce7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --info: #3b82f6;
  --info-light: #dbeafe;
  --bg-gradient: linear-gradient(145deg, #e0f2fe 0%, #e9d5ff 100%);
  --card-bg: #ffffff;
  --text-primary: #1e1b4b;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-full: 9999px;
  --transition: 0.2s ease;
}

/* ── Reset ── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  background: var(--bg-gradient);
  min-height: 100vh;
  color: var(--text-primary);
  line-height: 1.6;
}
input,
select,
textarea,
button {
  font-family: inherit;
  font-size: inherit;
}
a {
  color: inherit;
  text-decoration: none;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.btn:hover {
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}
.btn .spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}
.btn.loading .spinner {
  display: inline-block;
}
.btn.loading .btn-text {
  opacity: 0.5;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: var(--text-primary);
}
.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(45, 212, 191, 0.4);
}
.btn-secondary {
  background: linear-gradient(135deg, var(--secondary), var(--secondary-hover));
  color: white;
}
.btn-secondary:hover {
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4);
}
.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover {
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.3);
}
.btn-outline {
  background: transparent;
  border: 2px solid var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--border-light);
}
.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}
.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
}
.btn-block {
  width: 100%;
}

/* ── Forms ── */
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  font-size: 0.9rem;
  background: white;
  transition: all var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.15);
}
.form-control.error {
  border-color: var(--danger);
}
.form-control::placeholder {
  color: var(--text-muted);
}
.form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.form-row .form-group {
  flex: 1;
  min-width: 150px;
}
.input-group {
  position: relative;
}
.input-group i {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 0.9rem;
}
.input-group .form-control {
  padding-right: 40px;
}

/* ── Cards ── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
}
.card-accent {
  border-top: 5px solid var(--primary);
}
.card-accent-purple {
  border-top: 5px solid var(--secondary);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.2rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--border-light);
}
.card-header h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  color: var(--text-primary);
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-success {
  background: var(--success-light);
  color: #166534;
}
.badge-warning {
  background: var(--warning-light);
  color: #92400e;
}
.badge-danger {
  background: var(--danger-light);
  color: #991b1b;
}
.badge-info {
  background: var(--info-light);
  color: #075985;
}
.badge-purple {
  background: var(--secondary-light);
  color: #5b21b6;
}
.badge-muted {
  background: #f3f4f6;
  color: #9ca3af;
}

/* ── Calendar Manager (Requirement #8) ── */
.calendar-manager {
  max-width: 460px;
}
.calendar-manager .cal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.calendar-manager .cal-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
}
.calendar-manager .cal-nav {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 8px;
}
.calendar-manager .cal-nav:hover {
  color: var(--secondary);
  background: var(--secondary-light);
}
.calendar-manager .cal-weekdays,
.calendar-manager .cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
}
.calendar-manager .cal-weekdays {
  margin-bottom: 6px;
}
.calendar-manager .cal-wd {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--secondary);
  padding: 4px;
}
.calendar-manager .cal-day {
  padding: 8px 0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  background: var(--success-light);
  color: #166534;
  transition:
    transform 0.05s ease,
    box-shadow 0.15s ease;
  user-select: none;
}
.calendar-manager .cal-day:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
}
.calendar-manager .cal-day.holiday {
  background: var(--danger-light);
  color: #991b1b;
  border-color: var(--danger);
  font-weight: 700;
}
.calendar-manager .cal-day.today {
  outline: 2px solid var(--primary);
}
.calendar-manager .cal-day.selected-day {
  outline: 2px solid var(--secondary);
  background: var(--secondary-light);
  color: #5b21b6;
}
.calendar-manager .cal-day .cal-hours {
  display: block;
  font-size: 0.65rem;
  opacity: 0.75;
  margin-top: 2px;
  font-weight: 400;
}
.calendar-manager .cal-day .cal-hours-custom {
  opacity: 1;
  font-weight: 700;
  color: var(--secondary);
}
.calendar-manager .cal-empty {
  padding: 8px 0;
}

/* Employment-date sub-line under the efficiency cell in monthly reports */
.emp-date-note {
  display: block;
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}
.emp-date-note.hire {
  color: #166534;
}
.emp-date-note.termination {
  color: #991b1b;
}

/* ── Toggle Switch ── */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 22px;
  transition: background 0.25s ease;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.25s ease;
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--primary);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

/* ── Tables ── */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 500px;
  overflow-y: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
th,
td {
  padding: 10px 8px;
  text-align: center;
  border-bottom: 1px solid var(--border-light);
}
th {
  background: var(--border-light);
  font-weight: 700;
  color: var(--text-secondary);
  position: sticky;
  top: 0;
  z-index: 1;
}
tr:hover {
  background: #f8fafc;
}

/* ── Main Grid Layout ── */
.main-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.main-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Contain report sub-tabs so the inner table-scroll never triggers body-level scroll */
#rptDaily,
#rptMonthly,
#rptRange {
  max-width: 100%;
  overflow: hidden;
}

/* ── Mobile Sort Controls (desktop: hidden, BEFORE media query for correct source-order) ── */
.mobile-sort-controls {
  display: none !important;
}
.mobile-sort-controls label {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 2px;
  font-weight: 600;
}
.mobile-sort-controls .form-control {
  height: 36px;
  font-size: 0.8rem;
  padding: 4px 10px;
  min-width: 130px;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE CARD VIEW — Viewports < 1024px
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 1023px) {
  /* Hide table header; cards carry their own labels */
  .table-scroll table thead {
    display: none;
  }
  .table-scroll table tbody {
    display: block;
  }
  .table-scroll table tr {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 8px 16px;
    padding: 12px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
  }
  .table-scroll table td {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: auto;
    margin: 0;
    padding: 2px 4px;
    border: none;
    text-align: right;
    font-size: 0.82rem;
    flex: 0 0 auto;
  }
  /* Key-value pair — label and content side-by-side */
  .table-scroll table td::before {
    content: attr(data-label) ':';
    font-weight: 600;
    font-size: 0.72rem;
    color: var(--text-secondary);
    white-space: nowrap;
  }
  .table-scroll table td .badge {
    font-size: 0.72rem;
  }

  /* Employee name — card title, full width */
  .table-scroll table td:first-child {
    flex: 1 1 100%;
    font-weight: 700;
    font-size: 0.9rem;
    padding: 0 4px 4px 4px;
    margin-bottom: 2px;
    border-bottom: 1px solid var(--border-light);
  }
  .table-scroll table td:first-child::before {
    display: none;
  }

  /* Action cell — push to end (left side in RTL) */
  .table-scroll table td.action-cell,
  .table-scroll table td[data-label='عملیات'] {
    margin-right: auto;
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    padding: 2px 0;
    border: none;
  }
  .table-scroll table td.action-cell::before,
  .table-scroll table td[data-label='عملیات']::before {
    display: none;
  }
  .table-scroll table td .log-actions {
    display: inline-flex;
  }
  .table-scroll table td .log-action-row {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 5px;
    background: var(--border-light);
    border-radius: var(--radius-sm);
  }
  .table-scroll table td .log-action-row .action-btns {
    display: inline-flex;
    gap: 4px;
  }
  .table-scroll table td .log-action-row .btn {
    height: 26px;
    width: 26px;
    min-width: 26px;
    font-size: 0.65rem;
    padding: 0;
  }
  .table-scroll table td .log-action-row .log-action-label {
    font-size: 0.75rem;
    white-space: nowrap;
  }

  /* Monthly ops button cell — align to left naturally via parent */
  .table-scroll table td:has(button[onclick*='openMonthlyOpsModal']) {
    margin-right: auto;
  }

  /* Remove sticky header behavior on cards */
  .table-scroll table th {
    position: static;
  }

  /* Report controls stack */
  .report-controls {
    flex-direction: column;
  }
  .report-controls .form-control {
    width: 100%;
    max-width: 100% !important;
  }

  /* Mobile sort controls — visible on mobile, hidden on desktop */
  .mobile-sort-controls {
    display: flex !important;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
    margin-bottom: 12px;
  }

  /* Top performer widget — vertical on mobile/tablet */
  .top-performer-widget {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 16px;
  }
  .tpw-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
  }
  .tpw-list {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
  }
  .tpw-item {
    width: 100%;
    box-sizing: border-box;
    /* justify-content: space-between; */
  }
}

@media (max-width: 640px) {
  .tpw-best-unit {
    width: 100%;
    text-align: center;
    justify-content: center;
  }
  .table-scroll table td.action-cell,
  .table-scroll table td[data-label='عملیات'] {
    /* margin-right: auto;
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    padding: 2px 0;
    border: none; */
    width: 100%;
    justify-content: center;
  }
  .table-scroll table td .log-actions {
    display: inline-flex;
    max-width: 95%;
  }

  .table-scroll table td .log-action-row .log-action-label {
    font-size: 0.75rem;
    white-space: pre-wrap;
    display: flex;
    flex-wrap: wrap;
  }
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 1.2rem;
  background: var(--border-light);
  border-radius: var(--radius-sm);
  padding: 4px;
}
.tab {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.tab.active {
  background: white;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}
.tab:hover:not(.active) {
  color: var(--text-primary);
}
.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

/* ── Modals ── */
/* Prevent background scrolling while a modal/confirm overlay is open */
body.modal-open {
  overflow: hidden;
}

/* User Operations modal (مودیال عملیات پرسنل) — activity item cards */
.monthly-ops-item {
  background: #fff;
  border: 1px solid var(--border-light);
  border-right: 3px solid var(--primary);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
  font-size: 0.82rem;
}
.monthly-ops-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.monthly-ops-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.monthly-ops-badges {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}
.monthly-ops-comment {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border-light);
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.7;
  width: 100%;
  white-space: normal;
  word-break: break-word;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-overlay.show {
  display: flex;
}
.modal {
  background: white;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s ease;
  padding-bottom: 2rem;
}
.modal-header {
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 {
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.modal-close:hover {
  color: var(--danger);
  background: var(--danger-light);
}
.modal-body {
  padding: 1.5rem;
}
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── Toast ── */
.toast-container {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  color: white;
  font-weight: 600;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.3s ease;
  min-width: 280px;
  max-width: 420px;
}
.toast-success {
  background: linear-gradient(135deg, #22c55e, #16a34a);
}
.toast-error {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}
.toast-warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

/* ── Confirm Dialog ── */
.confirm-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  padding: 20px;
}
.confirm-overlay.show {
  display: flex;
}
.confirm-box {
  background: white;
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.confirm-box p {
  margin-bottom: 1.5rem;
  font-size: 1rem;
  color: var(--text-secondary);
}
.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* ── Global Loader ── */
.global-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.global-loader.show {
  display: flex;
}
.loader-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── Charts ── */
.chart-container {
  margin-top: 1rem;
  max-height: 320px;
  position: relative;
}

/* ── Top Performer Widget ── */
.top-performer-widget {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-radius: 16px;
  margin-bottom: 20px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  box-shadow: var(--shadow-sm);
}
.tpw-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.tpw-emoji {
  font-size: 1.4rem;
  line-height: 1;
  flex-shrink: 0;
}
.tpw-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}
.tpw-best-unit {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border-radius: var(--radius-full);
  padding: 6px 16px;
  font-size: 0.78rem;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}
.tpw-best-unit strong {
  font-weight: 800;
  font-size: 0.85rem;
}
.tpw-list {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.tpw-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 4px 8px;
}
.tpw-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  background: var(--border-light);
  border-radius: var(--radius-full);
}
.tpw-rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: white;
  flex-shrink: 0;
}
.tpw-rank-1 {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}
.tpw-rank-2 {
  background: linear-gradient(135deg, #94a3b8, #64748b);
}
.tpw-rank-3 {
  background: linear-gradient(135deg, #cd7c2f, #a0522d);
}
.tpw-item-info {
  line-height: 1.3;
}
.tpw-item-name {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-primary);
}
.tpw-item-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: flex;
  gap: 4px;
}
.tpw-item-score {
  font-weight: 700;
  color: var(--secondary);
  font-size: 0.78rem;
}

/* ── Leaderboard ── */
/* (legacy — kept for backward compat during transition) */
.top-performers {
  background: linear-gradient(135deg, #fefce8, #fef9c3);
  border-radius: var(--radius-md);
  padding: 1rem;
}
.top-performers h4 {
  font-size: 0.9rem;
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.top-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}
.top-rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: white;
  flex-shrink: 0;
}
.top-rank-1 {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}
.top-rank-2 {
  background: linear-gradient(135deg, #94a3b8, #64748b);
}
.top-rank-3 {
  background: linear-gradient(135deg, #cd7c2f, #a0522d);
}
.leaderboard-best-unit {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
  margin-top: 0.8rem;
}
.leaderboard-best-unit h4 {
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
}
.leaderboard-best-unit p {
  font-size: 1.3rem;
  font-weight: 700;
}

/* ── Employee Details Bar ── */
.emp-details-bar {
  background: var(--border-light);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  display: none;
}
.emp-details-bar.show {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}
.emp-detail-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.emp-detail-item i {
  color: var(--secondary);
}

/* ── Report actions ── */
.report-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 1rem;
}

/* ── Select-All row (below employee dropdown) ── */
.select-all-row {
  margin-bottom: 0.75rem;
}

/* ── Employee details bar wrapper (bar + inline "+" add button) ── */
.emp-details-wrap {
  position: relative;
  margin-bottom: 1rem;
}
.emp-details-wrap .emp-details-bar {
  margin-bottom: 0;
  padding-left: 52px;
}
.emp-add-inline-btn {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  color: white;
  background: linear-gradient(135deg, var(--success), var(--secondary));
  box-shadow: 0 3px 10px rgba(139, 92, 246, 0.35);
  transition: all var(--transition);
  z-index: 2;
}
.emp-add-inline-btn:hover {
  transform: translateY(-50%) scale(1.08);
  box-shadow: 0 4px 14px rgba(34, 197, 94, 0.45);
}
.emp-add-inline-btn:active {
  transform: translateY(-50%) scale(1);
}

/* ── Daily report per-log action buttons ── */
td.action-cell {
  text-align: right;
}
.log-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: stretch;
  min-width: 180px;
}
.log-action-row {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: space-between;
  background: var(--border-light);
  border-radius: var(--radius-sm);
  padding: 5px 6px;
}
.log-action-row .log-action-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.log-action-row .log-action-label em {
  font-style: normal;
  color: var(--text-muted);
}
/* Action buttons group — pushed to the left edge with 4px gap */
.log-action-row .action-btns {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
  margin-left: auto;
}
.log-action-row .action-btns .btn {
  height: 30px;
  width: 30px;
  min-width: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 6px;
  font-size: 0.72rem;
}
.log-action-row .action-btns .btn-danger {
  border-radius: 6px;
}

/* ── Utilities ── */
.hidden {
  display: none !important;
}
.text-center {
  text-align: center;
}
.text-muted {
  color: var(--text-muted);
}
.mt-1 {
  margin-top: 0.5rem;
}
.mt-2 {
  margin-top: 1rem;
}
.mb-1 {
  margin-bottom: 0.5rem;
}
.mb-2 {
  margin-bottom: 1rem;
}
.flex {
  display: flex;
}
.gap-1 {
  gap: 0.5rem;
}
.gap-2 {
  gap: 1rem;
}
.flex-wrap {
  flex-wrap: wrap;
}
.items-center {
  align-items: center;
}
.justify-between {
  justify-content: space-between;
}

/* ── Animations ── */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes slideIn {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
@keyframes modalIn {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ── Flatpickr Jalaali Theme ── */
.jalaali-datepicker,
.flatpickr-input,
.jalali-dp-display {
  cursor: pointer !important;
}
.jalali-dp-popup {
  z-index: 99999 !important;
}
.jalali-dp-calendar {
  font-family: 'Vazirmatn', Tahoma, sans-serif;
}
.jalali-dp-calendar button:hover {
  background: var(--border-light);
}
.is-holiday-datepicker {
  background-color: #fee2e2 !important;
  color: #991b1b !important;
}
.flatpickr-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5zM1 4v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V4H1z'/%3E%3Cpath d='M10 6.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 10px center !important;
  background-size: 16px !important;
  padding-left: 14px !important;
  padding-right: 36px !important;
}
.flatpickr-calendar {
  font-family: 'Vazirmatn', Tahoma, sans-serif !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-lg) !important;
  border: 1px solid var(--border) !important;
}
.flatpickr-months .flatpickr-month {
  background: linear-gradient(135deg, var(--primary), var(--secondary)) !important;
  color: white !important;
  border-radius: var(--radius-md) var(--radius-md) 0 0 !important;
}
.flatpickr-months .flatpickr-month .flatpickr-current-month {
  color: white !important;
  font-weight: 600 !important;
}
.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
  color: white !important;
  fill: white !important;
}
.flatpickr-months .flatpickr-prev-month:hover,
.flatpickr-months .flatpickr-next-month:hover {
  color: var(--primary-light) !important;
}
.flatpickr-current-month .flatpickr-monthDropdown-months {
  background: transparent !important;
  color: white !important;
}
span.flatpickr-weekday {
  color: var(--secondary) !important;
  font-weight: 600 !important;
}
.flatpickr-day {
  border-radius: var(--radius-sm) !important;
  font-size: 0.85rem !important;
  transition: all 0.15s !important;
}
.flatpickr-day:hover {
  background: var(--primary-light) !important;
  border-color: var(--primary) !important;
  color: var(--text-primary) !important;
}
.flatpickr-day.selected,
.flatpickr-day.selected:hover {
  background: var(--secondary) !important;
  border-color: var(--secondary) !important;
  color: white !important;
}
.flatpickr-day.today {
  border-color: var(--primary) !important;
  color: var(--primary) !important;
  font-weight: 700 !important;
}
.flatpickr-day.today.selected {
  background: var(--primary) !important;
  color: white !important;
}
.flatpickr-day.flatpickr-disabled,
.flatpickr-day.flatpickr-disabled:hover {
  color: var(--border) !important;
}
.flatpickr-day.notAllowed {
  color: var(--border) !important;
}
.flatpickr-day.rangeStart,
.flatpickr-day.rangeEnd {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
}
.flatpickr-day.inRange {
  background: var(--primary-light) !important;
  box-shadow: none !important;
}

/* ── Responsive ── */

/* ── Centralized Attendance Select ── */
#sharedLeaveType {
  height: 38px;
  width: 180px;
  padding: 6px 10px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Dynamic Row Layout (Phase 3) ── */
.dynamic-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 8px;
  width: 100%;
}
.dynamic-row .field-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  white-space: nowrap;
}
.dynamic-row .dyn-label-group,
.dynamic-row .dyn-qty-group,
.dynamic-row .dyn-att-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.dynamic-row .dyn-label-group {
  flex: 2;
  min-width: 140px;
}
.dynamic-row .dyn-qty-group {
  flex: 0 0 110px;
}
.dynamic-row .dyn-att-group {
  flex: 0 0 130px;
}
.dynamic-row .dyn-btn-group {
  display: flex;
  gap: 4px;
  align-items: flex-end;
  padding-bottom: 1px;
  flex: 0 0 auto;
}
.dynamic-row .dyn-btn-group .btn {
  height: 38px;
  width: 38px;
  min-width: 38px;
  max-width: 38px;
  flex: 0 0 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 0.82rem;
  border-radius: 8px;
}
.dynamic-row .leave-wrapper {
  display: none;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: flex-end;
}
.dynamic-row .dyn-leave-unit {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
}
.dynamic-row .dyn-leave-unit .form-control {
  width: 55px;
  height: 38px;
  text-align: center;
  padding: 4px 6px;
  font-size: 0.82rem;
}
.dynamic-row .form-control {
  height: 38px;
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: 8px;
}
.dynamic-row select.form-control {
  appearance: auto;
  -webkit-appearance: auto;
  -moz-appearance: auto;
  background-position: left 8px center;
  padding-left: 28px;
  padding-right: 10px;
}
/* ── Dynamic Defect Row (Phase 3) ── */
.dynamic-defect-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 8px;
  width: 100%;
}
.dynamic-defect-row .defect-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  white-space: nowrap;
  display: block;
  width: 100%;
}
.dynamic-defect-row .dyn-defect-type-wrap {
  flex: 2;
  min-width: 150px;
}
.dynamic-defect-row .dyn-defect-type-wrap .form-control {
  width: 100%;
  height: 38px;
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: 8px;
  appearance: auto;
  -webkit-appearance: auto;
  -moz-appearance: auto;
  background-position: left 8px center;
  padding-left: 28px;
  padding-right: 10px;
}
.dynamic-defect-row .dyn-defect-qty-wrap {
  flex: 0 0 90px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
}
.dynamic-defect-row .dyn-defect-qty-wrap .form-control {
  width: 100%;
  height: 38px;
  font-size: 0.85rem;
  padding: 6px 8px;
  text-align: center;
  border-radius: 8px;
}
.dynamic-defect-row .dyn-btn-group {
  display: flex;
  gap: 4px;
  align-items: flex-end;
  padding-bottom: 1px;
  flex: 0 0 auto;
}
.dynamic-defect-row .dyn-btn-group .btn {
  height: 38px;
  width: 38px;
  min-width: 38px;
  max-width: 38px;
  flex: 0 0 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 0.82rem;
  border-radius: 8px;
}
/* ── Edit Defect Row ── */
.edit-defect-row .form-control {
  height: 38px;
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: 8px;
}
.edit-defect-row select.form-control {
  appearance: auto;
  -webkit-appearance: auto;
  -moz-appearance: auto;
  background-position: left 8px center;
  padding-left: 28px;
  padding-right: 10px;
}

.activity-add-btn {
  height: 38px;
  width: 38px;
  min-width: 38px;
  max-width: 38px;
  flex: 0 0 38px;
  order: 2;
}
.activity-add-btn.mobile-only {
  display: none;
}
.defect-add-btn.mobile-only {
  display: none;
}
.defect-add-btn.desktop-only {
  order: 2;
}

/* ══════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — viewport < 640px
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  .card {
    padding: 1rem;
  }

  /* 1. Main Tabs: vertical stacking, centered */
  .tabs {
    flex-direction: column;
    gap: 6px;
  }
  .tabs .tab {
    width: 100%;
    justify-content: center;
    text-align: center;
    padding: 14px 16px;
    font-size: 0.9rem;
  }

  /* 2. Attendance select full width */
  #sharedLeaveType {
    width: 100% !important;
    min-width: 0;
  }
  #sharedLeaveSection > div:last-child {
    flex-direction: column;
    gap: 8px;
  }
  #sharedLeaveHoursGroup,
  #sharedLeaveMinsGroup {
    width: 100%;
  }
  #sharedLeaveHoursGroup .form-control,
  #sharedLeaveMinsGroup .form-control {
    width: 100%;
  }

  /* 3. Activity Rows: card grouping via order, delete 42px */
  #activityRowsContainer .dynamic-row {
    flex-wrap: wrap;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 12px;
    gap: 8px;
  }
  #activityRowsContainer .dynamic-row .dyn-label-group {
    order: 1;
    width: 100%;
    min-width: 0;
    flex: none;
  }
  #activityRowsContainer .dynamic-row .dyn-label-group .form-control {
    width: 100%;
  }
  #activityRowsContainer .dynamic-row .dyn-qty-group {
    order: 2;
    width: calc(100% - 48px);
    min-width: 0;
    flex: none;
  }
  #activityRowsContainer .dynamic-row .dyn-qty-group .field-label {
    display: block;
    width: 100%;
    text-align: right;
    margin-bottom: 4px;
  }
  #activityRowsContainer .dynamic-row .dyn-qty-group .form-control {
    width: 100%;
  }
  #activityRowsContainer .dynamic-row .dyn-btn-group {
    order: 3;
    width: auto;
    display: flex;
    gap: 8px;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
  }
  #activityRowsContainer .dynamic-row .activity-add-btn.desktop-only {
    display: none !important;
  }
  .activity-add-btn.mobile-only {
    display: flex;
    width: 100%;
    max-width: none;
  }
  #activityRowsContainer .dynamic-row .activity-remove-btn {
    width: 42px;
    height: 38px;
    flex: 0 0 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* 4. Defect Rows: same pattern */
  #defectRowsContainer .dynamic-defect-row {
    flex-wrap: wrap;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 12px;
    gap: 8px;
  }
  #defectRowsContainer .dynamic-defect-row .dyn-defect-type-wrap {
    order: 1;
    width: 100%;
    min-width: 0;
    flex: none;
  }
  #defectRowsContainer .dynamic-defect-row .dyn-defect-type-wrap .form-control {
    width: 100%;
  }
  #defectRowsContainer .dynamic-defect-row .dyn-defect-qty-wrap {
    order: 2;
    width: calc(100% - 48px);
    min-width: 0;
    flex: none;
  }
  #defectRowsContainer .dynamic-defect-row .dyn-defect-qty-wrap .field-label {
    display: block;
    width: 100%;
    text-align: right;
  }
  #defectRowsContainer .dynamic-defect-row .dyn-defect-qty-wrap .form-control {
    width: 100%;
    text-align: right;
  }
  #defectRowsContainer .dynamic-defect-row .dyn-btn-group {
    order: 3;
    width: auto;
    display: flex;
    gap: 8px;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
  }
  #defectRowsContainer .dynamic-defect-row .defect-add-btn.desktop-only {
    display: none !important;
  }
  .defect-add-btn.mobile-only {
    display: flex;
    width: 100%;
    height: 36px;
  }
  #defectRowsContainer .dynamic-defect-row .defect-remove-btn {
    width: 42px;
    height: 38px;
    flex: 0 0 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* 5. Submit button full width */
  #logSaveBtn {
    width: 100%;
  }

  /* 6. Report table card view at < 1024px (handled above), neutralize forced scroll */
  .table-scroll table {
    min-width: auto;
  }

  /* 7. Modal adjustments */
  .modal {
    max-width: 100%;
    margin: 10px;
    max-height: 95vh;
  }

  /* 8. Form rows stack */
  .form-row {
    flex-direction: column;
  }
  .form-row .form-group {
    min-width: 0;
    width: 100%;
  }

  /* 9. Report controls stack */
  .report-controls {
    flex-direction: column;
  }
  .report-controls .form-control {
    width: 100%;
    max-width: 100% !important;
  }
}
