/* ═══════════════════════════════════════════════════════════
   HR & PAYROLL — admin/HR-only screen. Employees table, pay
   component cards, payroll run cards + modals. Desktop-first grid
   layouts collapse into stacked cards on phones.
═══════════════════════════════════════════════════════════ */

#screen-hr-payroll {
  --hrp-space: clamp(12px, 2vw, 24px);
}

/* ── Hero ─────────────────────────────────────────────────────────── */
#screen-hr-payroll .hrp-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: var(--hrp-space) var(--hrp-space) 0;
  padding: 20px 22px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--navy-dark, #0f2438), var(--navy, #16324f));
  color: #fff;
  box-shadow: 0 16px 34px rgba(20, 40, 60, .18);
}
#screen-hr-payroll .hrp-hero__eyebrow {
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .65);
  margin-bottom: 4px;
}
#screen-hr-payroll .hrp-hero__copy h1 {
  margin: 0 0 4px;
  font-size: clamp(20px, 3vw, 26px);
  font-weight: 800;
  letter-spacing: -.02em;
}
#screen-hr-payroll .hrp-hero__copy p {
  margin: 0;
  max-width: 460px;
  font-size: 12.5px;
  line-height: 1.55;
  color: rgba(255, 255, 255, .78);
}
#screen-hr-payroll .hrp-hero__stats {
  display: flex;
  flex-shrink: 0;
  gap: 10px;
}
#screen-hr-payroll .hrp-hero__stat {
  flex-shrink: 0;
  text-align: center;
  min-width: 84px;
  padding: 10px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .16);
}
#screen-hr-payroll .hrp-hero__stat strong {
  display: block;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.1;
}
#screen-hr-payroll .hrp-hero__stat span {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 255, 255, .7);
  white-space: nowrap;
}

/* ── Tabs ─────────────────────────────────────────────────────────── */
#screen-hr-payroll #hrp-tabs {
  width: min(100%, 1200px);
  min-height: 54px;
  margin: 12px auto 0;
  padding: 6px;
  gap: 6px;
  display: flex;
  overflow-x: auto;
  background: color-mix(in srgb, var(--surface, #fff) 93%, var(--surface-blue, #eef5fa));
  border: 1px solid var(--collection-line, #e4ebf1);
  border-radius: 18px;
  box-shadow: 0 8px 20px rgba(45, 73, 96, .07);
  scrollbar-width: none;
}
#screen-hr-payroll #hrp-tabs::-webkit-scrollbar { display: none; }
#screen-hr-payroll .pg-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  min-width: max-content;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 13px;
  background: none;
  box-shadow: none;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-soft, #4a5b6c);
  cursor: pointer;
}
#screen-hr-payroll .pg-tab-btn.active {
  color: #fff;
  background: var(--navy, #426482);
  border-color: var(--navy, #426482);
  box-shadow: 0 7px 15px rgba(54, 82, 108, .16);
}

/* ── Panels + toolbar ─────────────────────────────────────────────── */
#screen-hr-payroll .hrp-panel {
  width: min(100%, 1200px);
  margin: 14px auto 0;
  padding: 0 var(--hrp-space) calc(30px + var(--nav-h, 0px));
}
#screen-hr-payroll .hrp-panel.hidden { display: none; }

#screen-hr-payroll .hrp-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px;
  background: var(--surface, #fff);
  border: 1px solid var(--collection-line, #e4ebf1);
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(45, 73, 96, .06);
}
#screen-hr-payroll .hrp-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 220px;
  min-width: 0;
  padding: 0 12px;
  min-height: 42px;
  background: var(--surface-soft, #f5f8fb);
  border: 1px solid color-mix(in srgb, var(--collection-line, #e4ebf1) 84%, #9fb8cc);
  border-radius: 12px;
  color: var(--ink-muted, #9aa9b6);
}
#screen-hr-payroll .hrp-search svg { flex-shrink: 0; width: 15px; height: 15px; }
#screen-hr-payroll .hrp-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  outline: none;
  font-size: 13px;
  color: var(--ink, #1f2d3d);
}
#screen-hr-payroll .hrp-select,
#screen-hr-payroll input[type="month"]#hrp-new-run-month {
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid color-mix(in srgb, var(--collection-line, #e4ebf1) 84%, #9fb8cc);
  border-radius: 12px;
  background: var(--surface-soft, #f5f8fb);
  color: var(--ink, #1f2d3d);
  font-size: 12.5px;
  font-weight: 700;
}

/* Scroll containers: same visible-scrollbar treatment as the Schedule
   Gantt so a long employee list / run history is obviously scrollable
   on both desktop and touch. */
#screen-hr-payroll .hrp-scroll {
  max-height: min(64vh, 620px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: auto;
  scrollbar-color: var(--navy, #426482) var(--surface-soft, #f5f8fb);
}
#screen-hr-payroll .hrp-scroll::-webkit-scrollbar { width: 10px; }
#screen-hr-payroll .hrp-scroll::-webkit-scrollbar-track { background: var(--surface-soft, #f5f8fb); }
#screen-hr-payroll .hrp-scroll::-webkit-scrollbar-thumb {
  background: var(--navy, #426482);
  border-radius: 6px;
  border: 2px solid var(--surface-soft, #f5f8fb);
}

#screen-hr-payroll .hrp-empty {
  padding: 28px 12px;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-muted, #9aa9b6);
}
#screen-hr-payroll .hrp-muted { color: var(--ink-muted, #9aa9b6); font-style: normal; }

/* ── Employees table ──────────────────────────────────────────────── */
#screen-hr-payroll .hrp-table {
  background: var(--surface, #fff);
  border: 1px solid var(--collection-line, #e4ebf1);
  border-radius: 16px;
  overflow: hidden;
}
#screen-hr-payroll .hrp-trow {
  display: grid;
  grid-template-columns: 1.4fr .9fr 1fr 1fr 1.1fr .9fr .7fr;
  gap: 8px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--collection-line, #e4ebf1);
  font-size: 12.5px;
  cursor: pointer;
  transition: background .12s ease;
}
#screen-hr-payroll .hrp-trow:last-child { border-bottom: 0; }
#screen-hr-payroll .hrp-trow:hover { background: var(--surface-blue, #eef5fa); }
#screen-hr-payroll .hrp-trow--head {
  cursor: default;
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-muted, #9aa9b6);
  background: var(--surface-soft, #f5f8fb);
}
#screen-hr-payroll .hrp-trow--head:hover { background: var(--surface-soft, #f5f8fb); }
#screen-hr-payroll .hrp-trow__name { font-weight: 800; color: var(--ink, #1f2d3d); }

/* ── Component / run cards ────────────────────────────────────────── */
#screen-hr-payroll .hrp-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
#screen-hr-payroll .hrp-comp-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  background: var(--surface, #fff);
  border: 1px solid var(--collection-line, #e4ebf1);
  border-radius: 16px;
  cursor: pointer;
  transition: box-shadow .12s ease, transform .12s ease;
}
#screen-hr-payroll .hrp-comp-card:hover { box-shadow: 0 10px 22px rgba(45, 73, 96, .1); transform: translateY(-1px); }
#screen-hr-payroll .hrp-comp-card__badge {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-weight: 800;
  font-size: 16px;
}
#screen-hr-payroll .hrp-comp-card--earning .hrp-comp-card__badge { background: color-mix(in srgb, #059669 16%, transparent); color: #059669; }
#screen-hr-payroll .hrp-comp-card--deduction .hrp-comp-card__badge { background: color-mix(in srgb, #dc453f 14%, transparent); color: #dc453f; }
#screen-hr-payroll .hrp-comp-card__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#screen-hr-payroll .hrp-comp-card__body strong { font-size: 13.5px; color: var(--ink, #1f2d3d); }
#screen-hr-payroll .hrp-comp-card__ar { font-size: 11.5px; color: var(--ink-soft, #4a5b6c); }
#screen-hr-payroll .hrp-comp-card__meta { font-size: 10.5px; font-weight: 700; color: var(--ink-muted, #9aa9b6); }

#screen-hr-payroll .hrp-run-card {
  padding: 14px 16px;
  background: var(--surface, #fff);
  border: 1px solid var(--collection-line, #e4ebf1);
  border-radius: 16px;
  cursor: pointer;
  transition: box-shadow .12s ease, transform .12s ease;
}
#screen-hr-payroll .hrp-run-card:hover { box-shadow: 0 10px 22px rgba(45, 73, 96, .1); transform: translateY(-1px); }
#screen-hr-payroll .hrp-run-card__main { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
#screen-hr-payroll .hrp-run-card__main strong { font-size: 14.5px; color: var(--ink, #1f2d3d); }
#screen-hr-payroll .hrp-run-card__meta { display: flex; gap: 14px; font-size: 11.5px; color: var(--ink-muted, #9aa9b6); font-weight: 700; }

#screen-hr-payroll .hrp-run-status-badge {
  padding: 2px 9px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .03em;
}
#screen-hr-payroll .hrp-run-status-badge--draft { background: color-mix(in srgb, #d97706 16%, transparent); color: #d97706; }
#screen-hr-payroll .hrp-run-status-badge--finalized { background: color-mix(in srgb, #0284c7 16%, transparent); color: #0284c7; }
#screen-hr-payroll .hrp-run-status-badge--paid { background: color-mix(in srgb, #059669 16%, transparent); color: #059669; }

/* ── Modals: form grid + employee pay-component editor ──────────────── */
.hrp-modal-box { max-width: 560px; width: 92vw; }
.hrp-run-box { max-width: 640px; }
#screen-hr-payroll ~ .dialog-overlay .hrp-form-grid,
.hrp-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
  margin: 10px 0;
}
.hrp-form-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-muted, #68788c);
}
.hrp-form-grid input,
.hrp-form-grid select {
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--collection-line, #e4ebf1);
  border-radius: 10px;
  background: var(--surface-soft, #f5f8fb);
  color: var(--ink, #1f2d3d);
  font-size: 13px;
}
.hrp-subheading {
  margin: 16px 0 8px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-muted, #68788c);
}
.hrp-emp-components {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}
.hrp-emp-comp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface-soft, #f5f8fb);
  border-radius: 10px;
  font-size: 12.5px;
}
.hrp-emp-comp-badge {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 800;
  font-size: 13px;
}
.hrp-emp-comp-badge--earning { background: color-mix(in srgb, #059669 18%, transparent); color: #059669; }
.hrp-emp-comp-badge--deduction { background: color-mix(in srgb, #dc453f 16%, transparent); color: #dc453f; }
.hrp-emp-comp-name { flex: 1; min-width: 0; font-weight: 700; color: var(--ink, #1f2d3d); }
.hrp-emp-comp-amount { font-weight: 800; color: var(--ink-soft, #4a5b6c); }
.hrp-emp-comp-remove {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink-muted, #9aa9b6);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.hrp-emp-comp-remove:hover { background: color-mix(in srgb, #dc453f 14%, transparent); color: #dc453f; }
.hrp-emp-add-component {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.hrp-emp-add-component select { flex: 2; }
.hrp-emp-add-component input { flex: 1; }
.hrp-emp-add-component select,
.hrp-emp-add-component input {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--collection-line, #e4ebf1);
  border-radius: 10px;
  background: var(--surface-soft, #f5f8fb);
  color: var(--ink, #1f2d3d);
  font-size: 12.5px;
}

/* ── Payroll run detail modal ─────────────────────────────────────── */
.hrp-run-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 8px 0 12px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-soft, #4a5b6c);
}
.hrp-run-items-scroll { max-height: 46vh; overflow-y: auto; }
.hrp-run-item {
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--surface-soft, #f5f8fb);
  border-radius: 12px;
}
.hrp-run-item__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}
.hrp-run-item__head strong { color: var(--ink, #1f2d3d); }
.hrp-run-item__net { margin-inline-start: auto; font-weight: 800; color: var(--navy, #426482); }
.hrp-run-item__rows { display: flex; flex-direction: column; gap: 4px; }
.hrp-run-item__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-soft, #4a5b6c);
}
.hrp-run-item__row input {
  width: 110px;
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid var(--collection-line, #e4ebf1);
  border-radius: 8px;
  background: var(--surface, #fff);
  color: var(--ink, #1f2d3d);
  font-size: 12px;
  text-align: right;
}
.hrp-run-item__row input:disabled { opacity: .6; }
.hrp-run-item__payday {
  margin-top: 6px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ink-muted, #9aa9b6);
}

/* ── Responsive: mobile ───────────────────────────────────────────── */
@media (max-width: 720px) {
  #screen-hr-payroll .hrp-hero { flex-direction: column; align-items: flex-start; gap: 12px; }
  #screen-hr-payroll .hrp-hero__stats { align-self: stretch; justify-content: space-between; }
  #screen-hr-payroll .hrp-hero__stat { flex: 1; min-width: 0; padding: 8px 6px; }
  #screen-hr-payroll .hrp-hero__stat strong { font-size: 18px; }

  /* The employee table becomes a stacked card per row — a 7-column grid
     doesn't survive a phone width, so each cell gets its own labeled
     line instead of trying to shrink columns into illegibility. */
  #screen-hr-payroll .hrp-trow--head { display: none; }
  #screen-hr-payroll .hrp-trow {
    grid-template-columns: 1fr;
    gap: 3px;
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 8px;
    border: 1px solid var(--collection-line, #e4ebf1);
  }
  #screen-hr-payroll .hrp-trow span:not(.hrp-trow__name)::before {
    content: attr(data-label);
  }
  #screen-hr-payroll .hrp-table { background: none; border: 0; }

  .hrp-form-grid { grid-template-columns: 1fr; }
  .hrp-modal-box, .hrp-run-box { width: 94vw; }
  .hrp-run-item__row input { width: 90px; }
}

@media (min-width: 769px) {
  #screen-hr-payroll .hrp-hero,
  #screen-hr-payroll .hrp-panel {
    max-width: 1200px;
  }
}
