/* Ensure HTML hidden attribute always works (prevents overlay panels from consuming layout) */
[hidden]{ display:none !important; }

html, body{ overflow-x: hidden; }
/* custom.css — Weekly KPI (Weekly_KPI) styling + Blocker modal
   FINETUNE v5
   Goals:
   - Desktop: horizontal scroll always available + an extra sticky scrollbar at bottom of viewport
   - Header: proportional + grey base, pastel group header (L1/L2/L3)
   - Cells: consistent widths (colgroup) + tidy controls
   - Modal: light mode
*/

/* =========================
   Toolbar
   ========================= */
.kpi-section{ padding: 10px 0 30px; }

.kpi-head{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap: 12px;
  margin: 8px 0 10px;
}
.kpi-actions{
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.kpi-toolbar{
  display:flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 10px 12px;
  border: 1px solid rgba(15,23,42,0.10);
  border-radius: 14px;
  background: rgba(255,255,255,0.60);
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.05);
  margin-bottom: 10px;
}
.kpi-field{
  display:flex;
  flex-direction: column;
  gap: 6px;
  min-width: 170px;
}
.kpi-field .input,
.kpi-field .select{
  height: 36px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(15,23,42,0.14);
  background: #f8fafc;
  color: #0b1220;
  outline: none;
}
.kpi-field .input:focus,
.kpi-field .select:focus{
  background: #ffffff;
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
}
.kpi-meta{ margin-left:auto; padding: 0 6px; }
.kpi-msg{ margin: 8px 2px 10px; }

/* =========================
   Table + scroll behavior
   ========================= */
:root{
  --wkpi-h1: 38px;
  --wkpi-h2: 44px;

  --wkpi-w-no: 56px;
  --wkpi-w-eid: 210px;
  --wkpi-w-area: 150px;
  --wkpi-w-tag: 120px;

  --wkpi-w-date: 140px;
  --wkpi-w-week: 92px;
  --wkpi-w-status: 240px;

  --wkpi-table-min: 2060px; /* forces horizontal overflow on most screens */
}

.kpi-tableWrap{
  /* keep horizontal scrolling, but hide the native scrollbar on desktop
     so only the floating scrollbar is visible */
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  /* do not reserve native scrollbar space (we show a floating bar instead) */
  scrollbar-gutter: auto;

  /* pull the table slightly closer to the card edge (left/right)
     so the left border/background feels aligned */
  margin-left: -14px;
  margin-right: -14px;

  border-radius: 14px;
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(255,255,255,0.72);
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.05);
}

/* hide native horizontal scrollbar (still scrollable with trackpad/touch) */
.kpi-tableWrap{ scrollbar-width: none; }
.kpi-tableWrap::-webkit-scrollbar{ height: 0; }
.kpi-tableWrap::-webkit-scrollbar-track{ background: transparent; }
.kpi-tableWrap::-webkit-scrollbar-thumb{ background: transparent; }

.kpi-table{
  min-width: max(100%, var(--wkpi-table-min));
  width: max-content;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
  line-height: 1.25;
}

/* colgroup widths */
.kpi-table col.c-no{ width: var(--wkpi-w-no); }
.kpi-table col.c-eid{ width: var(--wkpi-w-eid); }
.kpi-table col.c-phase{ width: var(--wkpi-w-phase); }
.kpi-table col.c-area{ width: var(--wkpi-w-area); }
.kpi-table col.c-supply{ width: var(--wkpi-w-supply); }
.kpi-table col.c-tagco{ width: var(--wkpi-w-tagco); }
.kpi-table col.c-date{ width: var(--wkpi-w-date); }
.kpi-table col.c-week{ width: var(--wkpi-w-week); }
.kpi-table col.c-status{ width: var(--wkpi-w-status); }
.kpi-table col.c-remark{ width: var(--wkpi-w-remark); }

/* Cells */
.kpi-table th, .kpi-table td{
  padding: 1px 1px;
  border-bottom: 1px solid rgba(15,23,42,0.08);
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-table tbody td{ white-space: nowrap; }
.kpi-table tbody tr:hover td{ background: rgba(2,6,23,0.03); }


/* Header label with small filter icon */
.th-flex{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}
.th-funnel{
  width: 14px;
  height: 14px;
  fill: rgba(15,23,42,0.55);
}
/* =========================
   Header (sticky, proportional)
   ========================= */
.kpi-table thead th{
  text-align: left;
  font-weight: 700;
  color: #0b1220;
}
.kpi-table thead tr.kpi-h1 th{
  position: sticky;
  top: 0;
  z-index: 7;
  height: var(--wkpi-h1);
  padding: 0 10px;
  background: #e2e8f0; /* base grey */
  border-bottom: 1px solid rgba(15,23,42,0.12);
}
.kpi-table thead tr.kpi-h2 th{
  position: sticky;
  top: var(--wkpi-h1);
  z-index: 6;
  height: var(--wkpi-h2);
  padding: 8px 10px;
  background: #f1f5f9; /* lighter grey */
  font-weight: 600;
  white-space: normal;   /* allow wrap */
  overflow: visible;     /* prevent clip on wrap */
  text-overflow: clip;
}
.kpi-table thead tr.kpi-h1 th[rowspan="2"]{
  height: calc(var(--wkpi-h1) + var(--wkpi-h2));
  vertical-align: middle;
}

/* Group header (pastel) — row 1 stronger, row 2 softer */
.kpi-table thead tr.kpi-h1 th.kpi-g-l1{ background: #f1d3db; }
.kpi-table thead tr.kpi-h1 th.kpi-g-l2{ background: #efe3bf; }
.kpi-table thead tr.kpi-h1 th.kpi-g-l3{ background: #cfead0; }

.kpi-table thead tr.kpi-h2 th.kpi-g-l1{ background: #f6e2e8; }
.kpi-table thead tr.kpi-h2 th.kpi-g-l2{ background: #f6efdc; }
.kpi-table thead tr.kpi-h2 th.kpi-g-l3{ background: #e9f7e9; }

/* =========================
   Frozen left columns (NO, EQUIPMENT ID, PHASE, Area, Equipment Supply by, Tag by Company)
   ========================= */
:root{
  --wkpi-sticky-shadow: 6px 0 14px rgba(2,6,23,0.08);
}

/* header row 1 holds the first 6 columns (rowspan=2) */
.kpi-table thead tr.kpi-h1 th:nth-child(1){
  position: sticky;
  left: 0;
  z-index: 12;
}
.kpi-table thead tr.kpi-h1 th:nth-child(2){
  position: sticky;
  left: var(--wkpi-w-no);
  z-index: 12;
}
.kpi-table thead tr.kpi-h1 th:nth-child(3){
  position: sticky;
  left: calc(var(--wkpi-w-no) + var(--wkpi-w-eid));
  z-index: 12;
}
.kpi-table thead tr.kpi-h1 th:nth-child(4){
  position: sticky;
  left: calc(var(--wkpi-w-no) + var(--wkpi-w-eid) + var(--wkpi-w-phase));
  z-index: 12;
}
.kpi-table thead tr.kpi-h1 th:nth-child(5){
  position: sticky;
  left: calc(var(--wkpi-w-no) + var(--wkpi-w-eid) + var(--wkpi-w-phase) + var(--wkpi-w-area));
  z-index: 12;
}
.kpi-table thead tr.kpi-h1 th:nth-child(6){
  position: sticky;
  left: calc(var(--wkpi-w-no) + var(--wkpi-w-eid) + var(--wkpi-w-phase) + var(--wkpi-w-area) + var(--wkpi-w-supply));
  z-index: 12;
  box-shadow: var(--wkpi-sticky-shadow);
  border-right: 1px solid rgba(15,23,42,0.10);
}

/* body cells */
.kpi-table tbody td:nth-child(1),
.kpi-table tbody td:nth-child(2),
.kpi-table tbody td:nth-child(3),
.kpi-table tbody td:nth-child(4),
.kpi-table tbody td:nth-child(5),
.kpi-table tbody td:nth-child(6){
  position: sticky;
  z-index: 5;
  background: rgba(255,255,255,0.96);
}
.kpi-table tbody td:nth-child(1){ left: 0; }
.kpi-table tbody td:nth-child(2){ left: var(--wkpi-w-no); }
.kpi-table tbody td:nth-child(3){ left: calc(var(--wkpi-w-no) + var(--wkpi-w-eid)); }
.kpi-table tbody td:nth-child(4){ left: calc(var(--wkpi-w-no) + var(--wkpi-w-eid) + var(--wkpi-w-phase)); }
.kpi-table tbody td:nth-child(5){ left: calc(var(--wkpi-w-no) + var(--wkpi-w-eid) + var(--wkpi-w-phase) + var(--wkpi-w-area)); }
.kpi-table tbody td:nth-child(6){
  left: calc(var(--wkpi-w-no) + var(--wkpi-w-eid) + var(--wkpi-w-phase) + var(--wkpi-w-area) + var(--wkpi-w-supply));
  box-shadow: var(--wkpi-sticky-shadow);
  border-right: 1px solid rgba(15,23,42,0.10);
}

/* keep hover highlight consistent on frozen cells */
.kpi-table tbody tr:hover td:nth-child(-n+6){ background: rgba(2,6,23,0.03); }

/* =========================
   Inputs & status controls
   ========================= */
.kpi-table .wk-edit{
  height: 34px;
  width: calc(var(--wkpi-w-date) - 16px);
  max-width: 100%;
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid rgba(15,23,42,0.14);
  background: #f8fafc;
  color: #0b1220;
  outline: none;
  font-size: 13px;
}
.kpi-table .wk-edit:focus{
  background: #ffffff;
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
}

.cell-status{
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}

/* pill */
.kpi-pill{
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(15,23,42,0.14);
  background: rgba(255,255,255,0.8);
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-pill[data-action="edit-blocker"]{ cursor: pointer; }
.kpi-pill.is-blocker{ border-color: rgba(220,38,38,0.35); background: #fff1f2; }
.kpi-pill.is-overdue{ border-color: rgba(245,158,11,0.45); background: #fff7ed; }
.kpi-pill.is-today{ border-color: rgba(34,197,94,0.40); background: #f0fdf4; }
.kpi-pill.is-look{ border-color: rgba(59,130,246,0.35); background: #eff6ff; }
.kpi-pill.is-notstart{ border-color: rgba(100,116,139,0.28); background: #f8fafc; }
.kpi-pill.is-completed{ border-color: rgba(34,197,94,0.50); background: #ecfdf5; }

/* status select */
.kpi-statusSel{
  height: 34px;
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid rgba(15,23,42,0.14);
  background: #f8fafc;
  color: #0b1220;
  font-size: 13px;
  outline: none;
  min-width: 120px;
}
.kpi-statusSel:disabled{
  opacity: 0.55;
  cursor: not-allowed;
}

/* blocker button (only shows on Overdue) */
.kpi-blocker-btn{
  height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(15,23,42,0.14);
  background: #ffffff;
  color: #0b1220;
  cursor: pointer;
  white-space: nowrap;
}
.kpi-blocker-btn.is-danger{
  border-color: rgba(220,38,38,0.28);
  background: #fff1f2;
}
.kpi-blocker-btn:hover{ filter: brightness(0.99); }

/* remarks cell */
.cell-remark{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
}
.kpi-remark-chip{
  height: 30px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(220,38,38,0.28);
  background: #fff1f2;
  color: #0b1220;
  cursor: pointer;
  white-space: nowrap;
  font-size: 13px;
}
.kpi-remark-chip:hover{ filter: brightness(0.99); }
.remark-text{
  max-width: calc(var(--wkpi-w-remark) - 90px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(15,23,42,0.78);
  font-size: 13px;
}

/* small clear btn (only on BLK) */
.kpi-clear-btn{
  height: 34px;
  width: 34px;
  border-radius: 12px;
  border: 1px solid rgba(15,23,42,0.14);
  background: #ffffff;
  cursor: pointer;
}
.kpi-clear-btn:hover{ background: rgba(2,6,23,0.03); }

/* Responsive: stack controls on narrower screens */
@media (max-width: 980px){
  :root{ --wkpi-w-status: 260px; }
  .cell-status{
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .kpi-pill{ max-width: 160px; }
}

/* =========================
   Sticky bottom scrollbar (desktop)
   ========================= */
.kpi-xscroll{
  /* floating single scrollbar (desktop) */
  position: fixed;
  left: 24px;
  right: 24px;
  bottom: 12px;
  z-index: 30;
  height: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-gutter: stable both-edges;
  border-radius: 999px;
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(255,255,255,0.85);
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.06);
  margin-top: 0;
}
.kpi-xscroll__inner{ height: 1px; } /* width is set by JS */

@media (max-width: 900px){
  .kpi-xscroll{ display:none; }
}

/* =========================
   Blocker modal (LIGHT)
   ========================= */
.kpi-modal[hidden]{ display:none; }
.kpi-modal{ position: fixed; inset: 0; z-index: 9999; }
.kpi-modal__overlay{
  position:absolute; inset:0;
  background: rgba(15,23,42,0.35);
  backdrop-filter: blur(6px);
}
.kpi-modal__card{
  position: relative;
  width: min(620px, calc(100% - 24px));
  margin: 56px auto 0 auto;
  border-radius: 18px;
  border: 1px solid rgba(15,23,42,0.14);
  background: rgba(255,255,255,0.98);
  color: rgba(10,12,16,0.92);
  box-shadow: 0 18px 70px rgba(0,0,0,0.22);
  padding: 16px;
}
.kpi-modal__head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 12px;
  padding: 2px 2px 10px 2px;
}
.kpi-modal__x{ height: 34px; width: 44px; padding: 0; border-radius: 12px; background: rgba(2,6,23,0.04); border: 1px solid rgba(15,23,42,0.10); cursor:pointer; }
.kpi-modal__x:hover{ background: rgba(2,6,23,0.06); }
.kpi-modal__body{ display:flex; flex-direction:column; gap: 10px; padding: 6px 2px 10px 2px; }
.kpi-modal__meta{ font-size: 12px; color: rgba(20,24,32,0.70); }
.kpi-textarea{
  width: 100%;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid rgba(15,23,42,0.14);
  background: rgba(248,250,252,0.98);
  color: rgba(10,12,16,0.92);
  resize: vertical;
  min-height: 160px;
}
.kpi-err{
  border: 1px solid rgba(220,38,38,0.22);
  background: #fff1f2;
  color: #991b1b;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 12px;
}
.kpi-modal__foot{ display:flex; justify-content:flex-end; gap: 10px; padding-top: 10px; }

@media (max-width: 520px){
  .kpi-modal__card{ margin-top: 18px; width: calc(100% - 16px); padding: 12px; }
  .kpi-textarea{ min-height: 140px; }
}

/* ==========================================================
   Account › MSFT Requirement (PDF Library)
   - No extra toolbar / note area (maximize PDF viewport)
   - Responsive: desktop/tablet/mobile
   ========================================================== */

html.cxMsftModalOpen{ overflow: hidden; }

.cxMsftModal{
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 18px;
}
.cxMsftOverlay{
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(2px);
}
.cxMsftCard{
  position: relative;
  width: min(1180px, calc(100vw - 20px));
  height: min(760px, calc(100vh - 20px));
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(15,23,42,0.12);
  border-radius: 22px;
  box-shadow: 0 26px 90px rgba(2, 6, 23, 0.28);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.cxMsftHead{
  display:flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(15,23,42,0.10);
}
.cxMsftCrumb{ font-size: 12px; color: rgba(15,23,42,0.60); }
.cxMsftTitle{ font-size: 18px; font-weight: 800; color: rgba(2,6,23,0.92); margin-top: 2px; }
.cxMsftHeadActions{ display:flex; gap: 10px; align-items:center; }

.cxMsftBody{
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 300px 1fr;
}
.cxMsftSide{
  border-right: 1px solid rgba(15,23,42,0.10);
  padding: 12px;
  overflow: auto;
}
.cxMsftSideTitle{ font-size: 13px; font-weight: 700; color: rgba(2,6,23,0.76); margin: 2px 0 10px; }
.cxMsftList{ display:flex; flex-direction: column; gap: 8px; }
.cxMsftItem{
  width: 100%;
  text-align: left;
  padding: 10px 10px;
  border-radius: 14px;
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(248,250,252,0.88);
  cursor: pointer;
}
.cxMsftItem:hover{ background: rgba(248,250,252,1); }
.cxMsftItem.is-active{ border-color: rgba(59,130,246,0.55); box-shadow: 0 0 0 3px rgba(59,130,246,0.12) inset; }
.cxMsftItemTitle{ font-weight: 800; font-size: 13px; line-height: 1.15; color: rgba(2,6,23,0.90); }
.cxMsftItemMeta{ font-size: 11px; line-height: 1.2; color: rgba(15,23,42,0.55); margin-top: 1px; }

.cxMsftViewer{ position: relative; min-height: 0; background: #ffffff; }
.cxMsftIframe{
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.cxMsftEmpty{
  position:absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  text-align: center;
  color: rgba(15,23,42,0.70);
}
.cxMsftEmptyTitle{ font-weight: 900; color: rgba(2,6,23,0.90); }
.cxMsftEmptySub{ margin-top: 6px; font-size: 13px; }

/* Tablet */
@media (max-width: 920px){
  .cxMsftCard{ width: calc(100vw - 18px); height: calc(100vh - 18px); border-radius: 18px; }
  .cxMsftBody{ grid-template-columns: 260px 1fr; }
}

/* Mobile: list becomes horizontal row on top to maximize viewer height */
@media (max-width: 720px){
  .cxMsftModal{ padding: 0; }
  .cxMsftCard{ width: 100vw; height: 100vh; border-radius: 0; }
  .cxMsftBody{ grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .cxMsftSide{ border-right: 0; border-bottom: 1px solid rgba(15,23,42,0.10); overflow: hidden; padding: 10px; }
  .cxMsftSideTitle{ margin-bottom: 8px; }
  .cxMsftList{ flex-direction: row; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
  .cxMsftItem{ min-width: 200px; }
}
