/* ------------------------------------------------------------------
   Payroll Console - admin theme
------------------------------------------------------------------ */
:root {
  --sidebar-w: 258px;
  --header-h: 60px;
  --ink: #0f1d33;
  --ink-soft: #5b6b83;
  --line: #e3e8ef;
  --brand: #12603f;
  --brand-2: #178054;
  --brand-soft: #eaf5f0;
  --surface: #f5f7fa;
  --amber: #b7791f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
}

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 15% -10%, #1c7a54 0%, #0d3f2c 45%, #08251a 100%);
  display: flex;
}
.login-wrap { margin: auto; width: 100%; max-width: 420px; padding: 24px; }
.login-card { background: #fff; border-radius: 16px; padding: 34px 30px 24px; }
.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand h1 { font-size: 1.35rem; font-weight: 700; margin: 12px 0 2px; }
.login-brand p { color: var(--ink-soft); font-size: .85rem; margin: 0; }
.login-foot { text-align: center; color: var(--ink-soft); font-size: .74rem; margin: 18px 0 0; }

.brand-mark {
  width: 54px; height: 54px; border-radius: 15px; margin: 0 auto;
  display: grid; place-items: center; font-size: 1.5rem; color: #fff;
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
}
.brand-mark.sm { width: 34px; height: 34px; border-radius: 10px; font-size: 1rem; margin: 0; }

/* ---------- Layout ---------- */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-h); z-index: 1035;
  background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 0 18px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: .96rem; }
.brand-text small { color: var(--ink-soft); font-size: .7rem; }
.header-date { color: var(--ink-soft); font-size: .82rem; }
.btn-ghost { background: transparent; border: 0; color: var(--ink); }
.btn-ghost:hover { background: #f1f4f8; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft);
  color: var(--brand); display: grid; place-items: center; font-size: .72rem; font-weight: 700;
}

.app-sidebar {
  position: fixed; top: var(--header-h); bottom: 0; left: 0; width: var(--sidebar-w); z-index: 1030;
  background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; justify-content: space-between;
  overflow-y: auto; padding: 14px 12px;
  transition: transform .22s ease;
}
.nav-section {
  font-size: .66rem; letter-spacing: .09em; text-transform: uppercase;
  color: #98a4b6; padding: 14px 10px 6px; font-weight: 700;
}
.app-sidebar .nav-link {
  display: flex; align-items: center; gap: 10px;
  color: var(--ink); border-radius: 9px; padding: 9px 11px; font-weight: 500; font-size: .875rem;
}
.app-sidebar .nav-link i { font-size: 1rem; color: var(--ink-soft); width: 18px; }
.app-sidebar .nav-link:hover { background: #f2f5f9; }
.app-sidebar .nav-link.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.app-sidebar .nav-link.active i { color: var(--brand); }
.sidebar-foot { border-top: 1px dashed var(--line); padding: 10px; color: var(--ink-soft); }
.sidebar-backdrop { display: none; }

.app-main {
  margin-left: var(--sidebar-w); padding: calc(var(--header-h) + 20px) 22px 40px;
  min-height: 100vh; position: relative;
}

@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.open { transform: translateX(0); box-shadow: 0 12px 40px rgba(15,29,51,.18); }
  .app-main { margin-left: 0; }
  .sidebar-backdrop.show {
    display: block; position: fixed; inset: var(--header-h) 0 0 0;
    background: rgba(15,29,51,.4); z-index: 1029;
  }
}

/* ---------- Content chrome ---------- */
.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; justify-content: space-between; margin-bottom: 18px; }
.page-head h2 { font-size: 1.28rem; font-weight: 700; margin: 0; }
.page-head p { margin: 2px 0 0; color: var(--ink-soft); font-size: .84rem; }

.card {
  border: 1px solid var(--line); border-radius: 13px;
  box-shadow: 0 1px 2px rgba(15,29,51,.04);
}
.card-header {
  background: #fff; border-bottom: 1px solid var(--line);
  font-weight: 600; border-radius: 13px 13px 0 0 !important; padding: 13px 16px;
}

.stat-card { display: flex; align-items: center; gap: 14px; padding: 18px; }
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.2rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-label { color: var(--ink-soft); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.bg-brand-soft { background: var(--brand-soft); color: var(--brand); }
.bg-amber-soft { background: #fdf3e0; color: var(--amber); }
.bg-slate-soft { background: #eef1f6; color: #52627a; }
.bg-rose-soft  { background: #fdeceb; color: #b3261e; }

.table { font-size: .85rem; }
.table > thead th {
  background: #f7f9fc; color: var(--ink-soft); text-transform: uppercase;
  font-size: .69rem; letter-spacing: .05em; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table > tbody td { vertical-align: middle; }
.table-hover > tbody > tr:hover > * { background: #f7fbf9; }

.badge-soft { border-radius: 999px; padding: .3em .7em; font-weight: 600; font-size: .7rem; }
.badge-active { background: var(--brand-soft); color: var(--brand); }
.badge-inactive { background: #eef1f6; color: #64748b; }

.form-label { font-weight: 600; font-size: .8rem; color: #3b4a61; margin-bottom: .3rem; }

.emp-photo-frame {
  width: 96px;
  height: 118px;
  border-radius: 50%;
  overflow: hidden;
  background: #e7f2ec;
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--brand);
  display: grid;
  place-items: center;
  position: relative;
  flex: 0 0 96px;
  color: var(--brand);
  font-weight: 800;
  font-size: 1.15rem;
}
.emp-photo-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.form-control, .form-select { border-color: #d8dfe9; font-size: .875rem; }
.form-control:focus, .form-select:focus {
  border-color: var(--brand-2); box-shadow: 0 0 0 .18rem rgba(23,128,84,.14);
}
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover, .btn-primary:focus { background: var(--brand-2); border-color: var(--brand-2); }
.btn-outline-primary { color: var(--brand); border-color: var(--brand); }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); }

.content-loader {
  position: absolute; inset: var(--header-h) 0 0 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: rgba(245,247,250,.72); color: var(--ink-soft);
}

.birthday-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.birthday-item:last-child { border-bottom: 0; }
.cake { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: #fdf3e0; }

.kv { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--ink-soft); }
.kv span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }
.kv.total { border-top: 2px solid var(--ink); border-bottom: 0; margin-top: 6px; padding-top: 10px; font-size: 1rem; }

.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.dropzone {
  border: 2px dashed #c7d2e0; border-radius: 13px; padding: 30px; text-align: center;
  background: #fbfcfe; cursor: pointer; transition: .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand-2); background: var(--brand-soft); }
.code-chip {
  display: inline-block; background: #eef1f6; border-radius: 6px;
  padding: 1px 7px; font-size: .72rem; font-weight: 700; color: #42536b; margin: 2px;
}

/* ---- Attendance preview matrix (editable review sheet) ---- */
.att-matrix {
  font-size: .75rem;
  border-collapse: separate;
  border-spacing: 0;
  width: max-content;
  min-width: 100%;
  margin-bottom: 0;
}
.att-matrix th, .att-matrix td {
  padding: .25rem .3rem;
  vertical-align: middle;
  background-clip: padding-box;
  white-space: nowrap;
}
.att-matrix .sticky-col {
  position: sticky; left: 0; z-index: 4;
  background: #fff; min-width: 160px;
  box-shadow: 4px 0 8px -2px rgba(0,0,0,.12);
}
/* View Attendance: freeze Code + Name as one left block */
#avScroll .att-matrix .sticky-emp {
  position: sticky !important;
  left: 0 !important;
  z-index: 6 !important;
  background: #fff !important;
  min-width: 200px;
  max-width: 220px;
  width: 210px;
  box-shadow: 6px 0 10px -3px rgba(0,0,0,.2);
  white-space: normal;
}
#avScroll .att-matrix thead th.sticky-emp {
  z-index: 8 !important;
  top: 0 !important;
  background: #eef1f6 !important;
}
#avScroll .att-matrix tbody tr.att-row-active > td.sticky-emp {
  background: #e8f1ff !important;
}
#avScroll .att-matrix tbody tr:hover > td.sticky-emp {
  background: #f3f6fa !important;
}
#avScroll .att-matrix tbody tr.att-row-active:hover > td.sticky-emp {
  background: #e8f1ff !important;
}
.att-matrix .sticky-code {
  position: sticky; left: 0; z-index: 4;
  background: #fff;
  width: 78px; min-width: 78px; max-width: 78px;
}
.att-matrix .sticky-name {
  position: sticky; left: 78px; z-index: 4;
  background: #fff;
  width: 168px; min-width: 168px; max-width: 168px;
  white-space: normal;
  box-shadow: 6px 0 10px -4px rgba(0,0,0,.18);
}
.att-matrix thead th {
  position: sticky; top: 0; z-index: 5;
  background: #f8f9fa !important;
}
.att-matrix thead th.sticky-col,
.att-matrix thead th.sticky-code {
  z-index: 7; left: 0; background: #eef1f6 !important;
}
.att-matrix thead th.sticky-name {
  z-index: 7; left: 78px; background: #eef1f6 !important;
}

/* Self-contained horizontal + vertical scroller (page itself does not scroll sideways) */
.att-scroll {
  width: 100%;
  max-width: 100%;
  max-height: 65vh;
  overflow: auto;
  overflow-x: auto;
  overflow-y: auto;
  position: relative;
  display: block;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #dee2e6;
  border-radius: .375rem;
  background: #fff;
}
/* Avoid Bootstrap .table-responsive fighting sticky columns */
.att-scroll.table-responsive {
  overflow: auto !important;
}

/* View Attendance: fixed-size pane — whole table scrolls inside this box */
#avScroll {
  width: 100%;
  max-width: 100%;
  height: calc(100vh - 340px);
  min-height: 360px;
  max-height: none;
  overflow: scroll !important; /* always show both scrollbars when needed */
  overflow-x: auto !important;
  overflow-y: auto !important;
  box-sizing: border-box;
}
#avScroll .att-matrix {
  width: max-content;
  min-width: 100%;
}

.att-cell { cursor: pointer; min-width: 54px; position: relative; }
.att-cell:hover { outline: 2px solid rgba(13,110,253,.35); outline-offset: -2px; }
.att-cell.att-active {
  outline: 2px solid #0d6efd !important;
  outline-offset: -2px;
  background: rgba(13,110,253,.16) !important;
  box-shadow: inset 0 0 0 1px #0d6efd;
  z-index: 1;
}
.att-matrix tbody tr.att-row-active > td {
  background: rgba(13,110,253,.06);
}
.att-matrix tbody tr.att-row-active > td.sticky-col,
.att-matrix tbody tr.att-row-active > td.sticky-code,
.att-matrix tbody tr.att-row-active > td.sticky-name {
  background: #e8f1ff !important;
}
.att-matrix tbody tr:hover > td:not(.att-active) {
  background: rgba(0,0,0,.025);
}
.att-matrix tbody tr:hover > td.sticky-col,
.att-matrix tbody tr:hover > td.sticky-code,
.att-matrix tbody tr:hover > td.sticky-name {
  background: #f3f6fa !important;
}
.att-matrix tbody tr.att-row-active:hover > td.sticky-col,
.att-matrix tbody tr.att-row-active:hover > td.sticky-code,
.att-matrix tbody tr.att-row-active:hover > td.sticky-name {
  background: #e8f1ff !important;
}
.att-cell.att-edited { background: rgba(25,135,84,.12); }
.att-cell.att-cellerr { background: rgba(220,53,69,.12); }
.att-day-head {
  white-space: nowrap; min-width: 52px; vertical-align: bottom !important;
}
.att-day-head .att-bulk-btn {
  display: block; margin: 0 auto 2px; padding: 0 4px; line-height: 1.1;
  border: 0; background: transparent; color: #6c757d; font-size: .7rem;
}
.att-day-head .att-bulk-btn:hover { color: #0d6efd; }
.att-emp-check { width: 1.1rem; height: 1.1rem; cursor: pointer; }

/* Half days: paid (within the HD credit) green, unpaid / LOP blue */
.att-cell.rm-HD-paid .code-chip { background: #d1e7dd; color: #0f5132; }
.att-cell.rm-HD-lop  .code-chip { background: #cfe2ff; color: #084298; }

/* Field (F) — payable like Present; Late Join (LJ) — ignored for pay */
.att-cell.rm-F  .code-chip { background: #d1e7dd; color: #0f5132; }
.att-cell.rm-LJ .code-chip { background: #e9ecef; color: #495057; }
.att-cell.rm-P  .code-chip { background: #d1e7dd; color: #0f5132; }
.att-cell.rm-A  .code-chip { background: #f8d7da; color: #842029; }

/* Editable leave balance cells (opening / credit / closing) */
.lv-input { min-width: 62px; }
.lv-input.lv-edited { background: rgba(255, 193, 7, .18); border-color: #ffc107; font-weight: 600; }
