/* ==========================================================================
   CareMetrix — Timesheets (People & Workforce)
   Staff timesheets generated from roster shifts (tbl_timesheet): a
   Weekly/Fortnight/Monthly/Custom Date toolbar identical to the Rosters
   page's own (same interaction, new class prefix), status tabs
   (All/Draft/Submitted/Approved/Rejected/Exported to Xero) matching the
   Rosters status-tab look, a compact filter + summary-hours row, a wide
   horizontally-scrolling table with a per-row ⋮ menu whose actions depend
   on the record's own status, and a View drawer + Approve/Reject/Export
   confirm modal. Same page-scoped-CSS + IIFE + mountOverlays() convention
   as Leave Approval / Shift Requests.
   ========================================================================== */

.tst { --tst-pink: #D0479A; --tst-pink-soft: #FBEAF4; }

.tst-pagepath { margin-bottom: 20px; }
.tst-card { overflow: visible; padding: 20px 24px 24px; }

.tst-headrow {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin: 0 -24px; padding: 0 24px 18px; border-bottom: 1px solid var(--border);
}
.tst-headrow #tstViewTabs { background: var(--surface-3); flex: none; }
.tst-headrow__daterange { display: flex; align-items: center; gap: 10px; flex: none; }

.tst-daterange { display: flex; align-items: center; gap: 10px; }
.tst-navbtn {
  width: 34px; height: 34px; border-radius: 10px;
  border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  display: grid; place-items: center; transition: all .16s var(--ease);
}
.tst-navbtn:hover { border-color: var(--brand-violet); color: var(--brand-purple); }
.tst-navbtn svg { width: 17px; height: 17px; }
.tst-rangelabel { font-weight: 600; font-size: 15px; color: var(--text); white-space: nowrap; min-width: 176px; text-align: right; }
.tst-rangelabel[hidden] { display: none; }

.tst-custominline { display: flex; align-items: center; gap: 6px; }
.tst-custominline[hidden] { display: none; }
.tst-custominline input { width: auto; padding: 6px 10px; font-size: 13px; font-weight: 700; border: 1.5px solid var(--form-border); border-radius: var(--r-sm); background: var(--surface); color: var(--text); }
.tst-custominline__sep { color: var(--text-3); font-weight: 700; }

.tst-iconbtn--solo {
  width: 36px; height: 36px; border-radius: var(--r-btn); display: grid; place-items: center;
  border: 1.5px solid var(--tst-pink); background: var(--surface); color: var(--tst-pink); transition: all .14s var(--ease);
}
.tst-iconbtn--solo svg { width: 17px; height: 17px; }
.tst-iconbtn--solo:hover { background: var(--tst-pink-soft); }

/* ------------------------------------------- status tabs + view-period tabs */

.tst-toprow {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin: 0 -24px; padding: 16px 24px; border-bottom: 1px solid var(--border);
}
.tst-statustabs { background: #fff; padding: 0; gap: 18px; }
.tst-statustabs button { display: flex; align-items: center; gap: 8px; padding: 0 0 12px; border-radius: 0; font-size: 13.5px; font-weight: 700; color: var(--text-2); }
.tst-statustabs button.is-active { background: transparent; box-shadow: none; color: var(--brand-purple); border-bottom: 2px solid var(--brand-purple); }
.tst-count { background: var(--surface-3); color: var(--text-2); border-radius: 999px; font-size: 11px; font-weight: 600; padding: 1px 8px; min-width: 18px; text-align: center; }
.tst-statustabs button.is-active .tst-count { background: var(--violet-bg); color: var(--brand-purple); }

.tst-pinkbtn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border: 1.5px solid var(--tst-pink); border-radius: var(--r-btn);
  background: var(--surface); color: var(--tst-pink);
  font-size: 13px; font-weight: 700; transition: all .14s var(--ease);
}
.tst-pinkbtn:hover { background: var(--tst-pink-soft); }
.tst-pinkbtn svg { width: 16px; height: 16px; }
.tst-pinkbtn.is-open { background: var(--tst-pink-soft); }

/* inline collapsible filter row, same shape as Operational Policies'
   .pol-filters — several labeled fields + Clear + gradient Apply filters,
   revealed in the page flow rather than a floating popover */
.tst-filters { padding: 16px 18px; margin: 16px -24px 0; background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.tst-filters[hidden] { display: none; }
.tst-filters__row { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.tst-filter { display: flex; flex-direction: column; gap: 6px; flex: 1 1 0; min-width: 160px; }
.tst-filter__label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.tst-filters__actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; margin-left: auto; }
@media (max-width: 760px) {
  .tst-filters__row { flex-direction: column; align-items: stretch; }
  .tst-filters__actions { margin-left: 0; }
}

/* -------------------------------------------------------------- bulk bar */

.tst-bulkbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--violet-bg); border-radius: var(--r-md); padding: 12px 18px; margin-top: 16px; }
.tst-bulkbar[hidden] { display: none; }
.tst-bulkbar span { font-size: 13px; font-weight: 700; color: var(--brand-purple); }
.tst-bulkbar__actions { display: flex; gap: 8px; }

/* ------------------------------------------------------------- searchrow */

.tst-searchrow { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 16px 0 14px; }
.tst-search { position: relative; display: flex; align-items: center; flex: 1; min-width: 240px; max-width: 480px; }
.tst-search svg { position: absolute; left: 14px; width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.tst-search input {
  width: 100%; box-sizing: border-box;
  font-size: 13px; padding: 9px 14px 9px 40px;
  border: 1.5px solid var(--form-border); border-radius: var(--r-pill);
  background: var(--surface); outline: none; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.tst-search input:focus { border-color: var(--form-focus); box-shadow: 0 0 0 3px var(--form-focus-ring); }
.tst-searchrow__pagination { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin-left: auto; }
.tst-searchrow__perpage { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-3); white-space: nowrap; }
.tst-searchrow__perpage select { border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 12.5px; background: var(--surface); color: var(--text); }

/* ------------------------------------------------------------------ table */

.tst-tablewrap { border: 1px solid var(--commontable2-cell-border); border-radius: 12px; overflow-x: auto; }
.tst-tablewrap .tst-grouphead-row:first-child td:first-child { border-top-left-radius: 11px; }
.tst-tablewrap .tst-grouphead-row:first-child td:last-child { border-top-right-radius: 11px; }
.tst-table { width: 100%; min-width: 0; table-layout: auto; }
.tst-table td { word-wrap: break-word; overflow-wrap: break-word; }
.tst-table tbody td { padding: clamp(8px, 0.8vw, 12px); }
.tst-table th, .tst-table td { white-space: normal; }
.tst-table .tst-morebtn { width: 28px; height: 28px; }
.tst-table .tst-status { padding: 0 8px; font-size: 11px; }
.tst-table input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--brand-purple); cursor: pointer; }

/* per-group shift-column header row, shown only while that group is
   expanded — the page no longer has a persistent global <thead> since the
   Clock In/Out and per-shift columns only make sense once a staff's
   accordion is open */
.tst-shifthead-row td {
  padding: clamp(10px, 1.1vw, 14px); background: var(--commontable2-header-bg);
  color: #393746; font-size: clamp(11px, .85vw, 12px); font-weight: 600;
  border-bottom: 1px solid var(--commontable2-cell-border);
}

/* colored left-edge accent bar on every shift row, same convention as the
   other admin review tables (e.g. Leave Approval) — not applied to the
   full-width staff group header row */
.tst-table tbody tr.tst-shiftrow td:first-child { position: relative; padding-left: 22px; color: var(--text-3); font-weight: 600; }
.tst-table tbody tr.tst-shiftrow td:first-child::before {
  content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 4px;
  border-radius: 0 4px 4px 0; background: linear-gradient(180deg, #E24FA8, #9B5CF6);
}

/* ------------------------------------------------------- staff group head */

.tst-grouphead-row td { padding: 0; background: var(--surface-2); }
.tst-grouphead-row:not(:first-child) td { border-top: 1px solid var(--border); }
.tst-grouphead {
  width: 100%; display: flex; align-items: center; gap: 16px;
  padding: 18px 20px; text-align: left;
}
.tst-grouphead__check { flex: none; width: 16px; height: 16px; accent-color: var(--brand-purple); cursor: pointer; }

.tst-grouphead__toggle {
  flex: 1; display: flex; align-items: center; flex-wrap: wrap; row-gap: 10px; column-gap: 18px;
  text-align: left; transition: background .14s var(--ease); border-radius: var(--r-md);
}
.tst-grouphead__chevron { flex: none; width: 22px; height: 22px; display: grid; place-items: center; color: var(--text-3); transition: transform .18s var(--ease); margin-left: auto; }
.tst-grouphead.is-open .tst-grouphead__chevron { transform: rotate(90deg); color: var(--brand-purple); }
.tst-grouphead__chevron svg { width: 16px; height: 16px; }

.tst-grouphead__staff { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; min-width: 200px; }
.tst-grouphead__name { display: block; font-size: 13.5px; font-weight: 700; color: var(--text); }
.tst-grouphead__sub { display: block; font-size: 11px; color: var(--text-3); margin-top: 1px; font-weight: 600; }

.tst-grouphead__stat { display: flex; flex-direction: column; gap: 2px; flex: 1 1 0; min-width: 78px; }
.tst-grouphead__stat label { font-size: 10px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em; }
.tst-grouphead__stat b { font-size: 13.5px; font-weight: 700; color: var(--text); }

.tst-shiftrow td:nth-child(2) { padding-left: 46px; }

.tst-person { display: flex; align-items: center; gap: 10px; }
.tst-avatar { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px; font-weight: 600; color: #fff; }
.tst-person__name { font-size: 13px; font-weight: 700; color: var(--text); }
.tst-person__sub { font-size: 11px; color: var(--text-3); margin-top: 1px; }

.tst-shiftwhen { font-size: 12.5px; font-weight: 700; color: var(--text); }
.tst-shiftwhen small { display: block; font-weight: 600; color: var(--text-3); font-size: 11px; }
.tst-notrecorded { color: var(--text-3); font-style: italic; font-weight: 500; }
.tst-hrs { font-weight: 600; color: var(--text); }
.tst-hrs--purple { color: var(--brand-purple); }

.tst-ot { display: flex; align-items: center; gap: 6px; }
.tst-ot__badge { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
.tst-ot__badge--pending { background: var(--amber-bg); color: var(--amber); }
.tst-ot__badge--approved { background: var(--green-bg); color: var(--green); }
.tst-ot__badge--rejected { background: var(--red-bg); color: var(--red); }

.tst-status { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 12px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.tst-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tst-status--1 { background: var(--surface-3); color: var(--text-2); }
.tst-status--2 { background: var(--amber-bg); color: var(--amber); }
.tst-status--3 { background: var(--green-bg); color: var(--green); }
.tst-status--4 { background: var(--red-bg); color: var(--red); }
.tst-status--5 { background: var(--violet-bg); color: var(--brand-purple); }

.tst-morebtn { width: 32px; height: 32px; border-radius: 9px; border: none; background: transparent; color: var(--text-3); display: inline-grid; place-items: center; cursor: pointer; transition: all .16s var(--ease); }
.tst-morebtn svg { width: 18px; height: 18px; }
.tst-morebtn:hover, .tst-morebtn[aria-expanded="true"] { background: var(--violet-bg); color: var(--brand-purple); }

.tst-rowmenu { position: fixed; z-index: 120; min-width: 170px; padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); display: none; }
.tst-rowmenu.is-open { display: block; }
.tst-rowmenu__item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; font-size: 13.5px; font-weight: 600; color: var(--text-2); text-align: left; transition: background .16s var(--ease); }
.tst-rowmenu__item svg { width: 16px; height: 16px; flex: none; }
.tst-rowmenu__item--view { color: var(--brand-purple); }
.tst-rowmenu__item--view:hover { background: var(--violet-bg); }
.tst-rowmenu__item--approve { color: var(--green); }
.tst-rowmenu__item--approve:hover { background: var(--green-bg); }
.tst-rowmenu__item--danger { color: var(--red); }
.tst-rowmenu__item--danger:hover { background: var(--red-bg); }
.tst-rowmenu__item--export { color: var(--brand-purple); }
.tst-rowmenu__item--export:hover { background: var(--violet-bg); }

/* ================================================================ drawer */

.tst-fd__section { font-size: 11.5px; font-weight: 600; color: var(--tst-pink); text-transform: uppercase; letter-spacing: .05em; margin: 22px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.tst-fd__section:first-child { margin-top: 0; }

.tst-staffcard { display: flex; align-items: center; gap: 14px; background: var(--violet-bg); border-radius: 14px; padding: 14px 16px; margin-bottom: 4px; }
.tst-staffcard .tst-avatar { width: 44px; height: 44px; font-size: 15px; }
.tst-staffcard__name { font-size: 14.5px; font-weight: 600; color: var(--text); }
.tst-staffcard__sub { font-size: 12px; color: var(--text-2); margin-top: 2px; }

.tst-view__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.tst-view__field { display: flex; flex-direction: column; gap: 5px; }
.tst-view__label { font-size: 10.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.tst-view__value { font-size: 13.5px; font-weight: 700; color: var(--text); }

.tst-clockbox { display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); border-radius: 12px; padding: 14px 16px; }
.tst-clockbox__row { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.tst-clockbox__row b { color: var(--text); font-weight: 700; }
.tst-clockbox__addr { font-size: 11px; color: var(--text-3); }

.tst-history { display: flex; gap: 12px; }
.tst-history__rail { display: flex; flex-direction: column; align-items: center; flex: none; }
.tst-history__dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--surface-3); flex: none; }
.tst-history__dot svg { width: 13px; height: 13px; }
.tst-history__dot--submit { background: var(--amber); }
.tst-history__dot--approve { background: var(--green); }
.tst-history__dot--reject { background: var(--red); }
.tst-history__dot--export { background: var(--brand-purple); }
.tst-history__line { flex: 1; width: 2px; background: var(--border); margin: 4px 0; min-height: 18px; }
.tst-history:last-child .tst-history__line { display: none; }
.tst-history__body { padding-bottom: 18px; }
.tst-history__title { font-size: 13px; font-weight: 600; color: var(--text); }
.tst-history__sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.tst-history__note { font-size: 12.5px; color: var(--text-2); margin-top: 6px; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }

.tst-notebox { font-size: 13px; color: var(--text-2); line-height: 1.55; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.tst-notebox--empty { color: var(--text-3); font-style: italic; }

/* --------------------------------------------------------------- modal -- */

.tst-modal { position: fixed; inset: 0; z-index: 150; padding: 20px; display: none; align-items: center; justify-content: center; background: rgba(36, 28, 60, .45); }
.tst-modal.show { display: flex; }
.tst-modal__box { width: 440px; max-width: 100%; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 26px; max-height: 88vh; overflow-y: auto; }
.tst-modal__icon { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 12px; margin-bottom: 14px; }
.tst-modal__icon--approve { background: var(--green-bg); color: var(--green); }
.tst-modal__icon--reject { background: var(--red-bg); color: var(--red); }
.tst-modal__icon--export { background: var(--violet-bg); color: var(--brand-purple); }
.tst-modal h3 { font-size: 16.5px; font-weight: 600; margin: 0 0 8px; }
.tst-modal p { font-size: 13px; color: var(--text-2); line-height: 1.55; margin: 0; }
.tst-modal__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.tst .btn--danger-solid { background: var(--red); color: #fff; border: none; }
.tst .btn--green-solid { background: var(--green); color: #fff; border: none; }
.tst .btn--purple-solid { background: var(--grad-brand); color: #fff; border: none; }

@media (max-width: 900px) {
  .tst-headrow, .tst-toprow, .tst-filters, .tst-searchrow { flex-direction: column; align-items: stretch; }
  .tst-searchrow__pagination { margin-left: 0; }
  .tst-view__grid { grid-template-columns: 1fr; }
}