/* Payroll pipeline — monthly export workflow */
.payroll-pipeline {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

/* Pipeline card — flat children: title, steps, meta, actions */
.pipeline-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  background: var(--surface);
  background-image: var(--gradient-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-md) var(--space-lg);
  border-left: 3px solid var(--border);
}

.pipeline-card--in-progress { border-left-color: var(--accent-2); }
.pipeline-card--to-lock { border-left-color: var(--warning); }
.pipeline-card--locked { border-left-color: var(--accent); }
.pipeline-card--exported { border-left-color: var(--success); }

/* Title: label + badge */
.pipeline-card__title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.pipeline-card__label {
  font-weight: var(--font-semibold);
  color: var(--text);
  white-space: nowrap;
}

/* Step dots — compact progression indicator */
.pipeline-card__steps {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.pipeline-card__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--surface-2);
  flex-shrink: 0;
}

.pipeline-card__dot--filled {
  background: var(--text-muted);
}

.pipeline-card__dot--current {
  width: 8px;
  height: 8px;
}

/* Current dot glow per status */
.pipeline-card--in-progress .pipeline-card__dot--current {
  background: var(--accent-2);
  box-shadow: 0 0 0 3px var(--accent-2-bg, rgba(123, 168, 212, 0.15));
}

.pipeline-card--to-lock .pipeline-card__dot--current {
  background: var(--warning);
  box-shadow: 0 0 0 3px var(--warning-bg, rgba(224, 144, 80, 0.15));
}

.pipeline-card--locked .pipeline-card__dot--current {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg, rgba(167, 139, 250, 0.15));
}

.pipeline-card--exported .pipeline-card__dot--current {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-bg, rgba(74, 202, 139, 0.15));
}

.pipeline-card__connector {
  width: 8px;
  height: 2px;
  background: var(--surface-2);
  flex-shrink: 0;
}

.pipeline-card__connector--filled {
  background: var(--text-muted);
}

/* Meta text */
.pipeline-card__meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  flex: 1;
  min-width: 0;
}

/* Actions */
.pipeline-card__actions {
  display: flex;
  gap: var(--space-sm);
  flex-shrink: 0;
}

/* Year separator */
.pipeline-year-separator {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-sm) var(--space-lg);
}

.pipeline-year-separator::before,
.pipeline-year-separator::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(to var(--dir, right), transparent, var(--border));
}

.pipeline-year-separator::after {
  --dir: left;
}

.pipeline-year-separator__label {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
}

/* Preview table */
.payroll-preview__table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  background-image: var(--gradient-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  margin-top: var(--space-lg);
}

.payroll-preview__table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  white-space: nowrap;
}

.payroll-preview__table th,
.payroll-preview__table td {
  padding: var(--space-md) var(--space-lg);
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.payroll-preview__table th {
  font-weight: var(--font-semibold);
  color: var(--text-muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  position: sticky;
  top: 0;
  background: var(--surface);
}

/* Grouped header row — sticky group labels */
.payroll-preview__group-header th {
  color: var(--accent);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  border-bottom: 2px solid var(--border);
  padding-bottom: var(--space-xs);
  text-align: left;
}

.payroll-preview__group-header th:not(:first-child) {
  position: sticky;
  left: var(--sticky-col-width, 0);
  z-index: 1;
  background: var(--surface);
}

/* Sticky first column (employee name) */
.payroll-preview__table th:first-child,
.payroll-preview__table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
}

.payroll-preview__table thead th:first-child {
  z-index: 2;
}

.payroll-preview__totals td:first-child {
  background: var(--surface-2);
}

.payroll-preview__table tbody tr:hover td:first-child {
  background: var(--surface-2);
}

/* Employee name + badge cell */
.payroll-preview__cell--employee {
  white-space: nowrap;
  text-align: left;
}

.payroll-preview__table th:first-child {
  text-align: left;
}

.payroll-preview__totals td:first-child {
  text-align: left;
}

.payroll-preview__cell--employee > * {
  display: inline;
  vertical-align: middle;
}

.payroll-preview__cell--employee {
  max-width: 30ch;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: max-width 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.payroll-preview__cell--employee .badge {
  margin-left: var(--space-sm);
  opacity: 1;
  transition: opacity 0.3s ease;
}

.is-scrolled .payroll-preview__cell--employee {
  max-width: 12ch;
}

.is-scrolled .payroll-preview__cell--employee .badge {
  opacity: 0;
  pointer-events: none;
}

.payroll-preview__name {
  font-weight: var(--font-medium);
}

/* OT highlight colors */
.payroll-preview__cell--warning {
  color: var(--warning);
}

.payroll-preview__cell--danger {
  color: var(--danger);
}

/* Totals row */
.payroll-preview__totals {
  background: var(--surface-2);
}

.payroll-preview__totals td {
  font-weight: var(--font-semibold);
  border-top: 2px solid var(--border);
  border-bottom: none;
}

.payroll-preview__table tbody tr:last-child td {
  border-bottom: none;
}

.payroll-preview__table tbody tr:hover {
  background: var(--surface-2);
}

.payroll-preview__cell--numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.payroll-preview__cell--zone {
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text-muted);
}

.payroll-preview__cell--meal {
  font-size: var(--text-sm);
  white-space: nowrap;
}

/* Note toggle icon in table */
.payroll-preview__cell--note-header {
  width: 44px;
  text-align: center;
}

.payroll-preview__cell--note-toggle {
  text-align: center;
  width: 44px;
}

.payroll-preview__note-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.payroll-preview__note-icon:hover {
  color: var(--accent);
  background: var(--surface-2);
}

.payroll-preview__note-icon--active,
.payroll-preview__note-icon--has-note {
  color: var(--accent);
}

/* Expandable note row */
.payroll-preview__note-row td {
  padding: 0 !important;
  border-bottom: 1px solid var(--border);
}

.payroll-preview__note-expand {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-lg);
  background: var(--surface-2);
}

.payroll-preview__note-expand .btn {
  flex-shrink: 0;
}

.payroll-preview__note-textarea {
  align-self: stretch;
}

.payroll-preview__note-label {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 120px;
}

.payroll-preview__note-textarea {
  flex: 1;
  resize: vertical;
  min-height: 44px;
  font-size: var(--text-sm);
}

.payroll-preview__note-readonly {
  flex: 1;
  font-size: var(--text-sm);
  color: var(--text);
  margin: 0;
  padding: var(--space-xs) 0;
}

/* Attachments preview on send form */
.payroll-attachments {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.payroll-attachment {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* Desktop: flat row — title | steps | meta | actions */
@media (min-width: 641px) {
  .pipeline-card {
    flex-direction: row;
    align-items: center;
    gap: var(--space-2xl);
  }

  .pipeline-card__title {
    width: 200px;
  }
}

@media (max-width: 640px) {
  .pipeline-card {
    position: relative;
  }

  .pipeline-card__title {
    flex: 1;
  }

  .pipeline-card__steps {
    position: absolute;
    top: calc(var(--space-md) + 0.45em);
    right: var(--space-lg);
  }

  .pipeline-card__actions {
    width: 100%;
  }

  .pipeline-card__actions .btn {
    flex: 1;
  }
}
