/* Kế hoạch chi lương (13/11/2026) — tab đầu của ?module=payroll, do ke-hoach-chi.js vẽ. Tiền tố kcl- (không dùng bl-* / lkw-* để khỏi kích hoạt
   bộ nghe của Bảng lương). Màu theo token theme (themes.css / app-shell.css: --bg-card, --border-color, --text-main, --text-muted, --txt-ok/warn/bad,
   --theme-accent-strong). Cam iTN (#e8651f, anh Nghĩa: «màu cam iTN làm điểm nhấn») chỉ dùng cho thanh và nền nhạt, không dùng làm màu chữ. */
.kcl-trang { --kcl-cam: #e8651f; max-width: 1180px; margin: 0 auto; padding: 4px 0 24px; color: var(--text-main); min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.kcl-trang :focus-visible, .kcl-ngan :focus-visible { outline: 2px solid var(--theme-accent-strong); outline-offset: 2px; }
.kcl-trang [hidden], .kcl-ngan [hidden] { display: none !important; }
.kcl-an { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.kcl-mo { color: var(--text-muted); }
.kcl-nho { font-size: 12.5px; line-height: 1.45; margin: 0; }
.kcl-so { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.kcl-dau { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.kcl-dau h1 { margin: 0; font-size: 26px; line-height: 1.2; letter-spacing: -.01em; }
.kcl-phu { display: flex; flex-wrap: wrap; gap: 2px 14px; margin: 4px 0 0; font-size: 13.5px; color: var(--text-muted); }
.kcl-phu strong { color: var(--text-main); }
.kcl-nut { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; min-width: 44px; padding: 0 14px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-card); color: var(--text-main); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.kcl-nut:hover:not(:disabled) { background: var(--bg-card-hover, var(--bg-card)); }
.kcl-nut:disabled { opacity: .45; cursor: not-allowed; }
.kcl-vuong { padding: 0; width: 44px; font-size: 20px; border: 0; border-radius: 0; background: transparent; }
.kcl-link { border: 0; background: none; padding: 0; min-height: 32px; color: var(--theme-accent-strong); font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; text-align: left; cursor: pointer; }

/* Bộ lọc: một hàng gọn */
.kcl-loc { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.kcl-thang { display: inline-flex; align-items: stretch; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-card); overflow: hidden; }
.kcl-thang > div { display: flex; flex-direction: column; justify-content: center; padding: 0 10px; min-width: 112px; text-align: center; border-inline: 1px solid var(--border-color); }
.kcl-thang small { font-size: 10.5px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; line-height: 1.2; }
.kcl-thang strong { font-size: 15px; line-height: 1.25; font-variant-numeric: tabular-nums; }
.kcl-seg { display: inline-flex; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-card); overflow: hidden; }
.kcl-seg button { min-height: 44px; padding: 0 12px; border: 0; border-left: 1px solid var(--border-color); background: transparent; color: var(--text-main); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.kcl-seg button:first-child { border-left: 0; }
.kcl-seg button[aria-pressed="true"] { background: var(--text-main); color: var(--bg-card); }
.kcl-o select, .kcl-o input { min-height: 44px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-card); color: var(--text-main); padding: 0 10px; font: inherit; font-size: 14px; max-width: 100%; }
.kcl-tim input { width: 220px; }
.kcl-dangxem { margin: -4px 0 0; font-size: 12.5px; color: var(--text-muted); }
.kcl-dangxem strong { color: var(--text-main); font-weight: 600; }

/* Thẻ chung */
.kcl-tq, .kcl-phan { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 8px; min-width: 0; }
.kcl-phan { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.kcl-phan-dau { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: space-between; }
.kcl-phan-dau h2 { margin: 0; font-size: 18px; }
.kcl-tag { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 700; line-height: 1.6; white-space: nowrap; background: color-mix(in srgb, var(--text-muted) 12%, transparent); color: var(--text-main); }
.kcl-tag.is-ok { background: color-mix(in srgb, var(--txt-ok) 14%, transparent); color: var(--txt-ok); }
.kcl-tag.is-warn { background: color-mix(in srgb, var(--txt-warn) 14%, transparent); color: var(--txt-warn); }
.kcl-tag.is-bad { background: color-mix(in srgb, var(--txt-bad) 12%, transparent); color: var(--txt-bad); }
.kcl-tag.is-cam { background: color-mix(in srgb, var(--kcl-cam) 16%, transparent); color: var(--text-main); }

/* Tổng quan */
.kcl-tq-luoi { display: grid; grid-template-columns: 1.45fr 1.25fr 1.25fr; }
.kcl-tq-luoi > div { padding: 14px 16px; min-width: 0; display: flex; flex-direction: column; gap: 6px; border-left: 1px solid var(--border-color); }
.kcl-tq-luoi > div:first-child { border-left: 0; }
.kcl-nhan { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.kcl-so-lon { font-size: 30px; font-weight: 800; line-height: 1.15; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kcl-so-vua { font-size: 22px; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kcl-chua { font-size: 15px; font-weight: 700; }
.kcl-ngay-lon { font-size: 20px; font-weight: 800; line-height: 1.2; }
.kcl-con { font-weight: 700; color: var(--txt-warn); }
.kcl-tach { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: color-mix(in srgb, var(--text-muted) 14%, transparent); }
.kcl-tach i { display: block; height: 100%; }
.kcl-tach .is-cb, .kcl-cham.is-cb { background: var(--kcl-cam); }
.kcl-tach .is-kpi, .kcl-cham.is-kpi { background: color-mix(in srgb, var(--kcl-cam) 45%, var(--bg-card)); }
.kcl-chuthich { display: flex; flex-wrap: wrap; gap: 2px 16px; font-size: 13.5px; }
.kcl-chuthich span { display: inline-flex; align-items: center; gap: 6px; }
.kcl-chuthich strong { font-variant-numeric: tabular-nums; }
.kcl-cham { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }
.kcl-phong-gon { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 12.5px; border-top: 1px solid var(--border-color); padding-top: 6px; }
.kcl-phong-gon span { white-space: nowrap; }
.kcl-phong-gon strong { font-variant-numeric: tabular-nums; }
.kcl-o3-kpi { border-top: 1px solid var(--border-color); padding-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.kcl-bao { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; padding: 10px 16px; border-top: 1px solid var(--border-color); font-size: 13.5px; }
.kcl-bao.is-canh { background: color-mix(in srgb, var(--txt-warn) 9%, transparent); }

/* Bảng phòng */
.kcl-cuon { overflow-x: auto; }
.kcl-bang { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.kcl-bang th, .kcl-bang td { padding: 10px 12px; border-bottom: 1px solid var(--border-color); text-align: left; vertical-align: middle; }
.kcl-bang thead th { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); white-space: nowrap; }
.kcl-bang .kcl-so { text-align: right; }
.kcl-bang tfoot th, .kcl-bang tfoot td { font-weight: 800; border-bottom: 0; border-top: 2px solid var(--border-color); }
.kcl-mo-phong { border: 0; background: none; padding: 6px 0; min-height: 44px; color: var(--text-main); font: inherit; font-weight: 700; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.kcl-mo-phong::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted); transform: rotate(-45deg); transition: transform .15s; }
.kcl-mo-phong[aria-expanded="true"]::before { transform: rotate(45deg); }
.kcl-thanh { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.kcl-thanh .kcl-mo { min-width: 34px; text-align: right; font-size: 12.5px; }
.kcl-ray { width: 72px; height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--text-muted) 14%, transparent); display: flex; flex: none; }
.kcl-ray i { display: block; height: 100%; border-radius: 3px; background: var(--kcl-cam); }
.kcl-nv-hang > td { padding: 0 12px 8px 30px; }
.kcl-nv-hang ul { list-style: none; margin: 0; padding: 0; }
.kcl-nv-hang li { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.2fr) repeat(3, minmax(0, .9fr)); gap: 4px 12px; align-items: center; padding: 6px 0; border-top: 1px dashed var(--border-color); font-size: 13px; }
.kcl-nv-hang li > span:nth-child(n+3), .kcl-nv-hang li > strong { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Lịch dự chi */
.kcl-lich { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.kcl-lich li { border-top: 1px solid var(--border-color); }
.kcl-lich li:first-child { border-top: 0; }
.kcl-dot { width: 100%; display: grid; grid-template-columns: 170px minmax(0, 1fr) auto; gap: 4px 16px; align-items: center; padding: 10px 4px; border: 0; background: none; color: var(--text-main); font: inherit; text-align: left; cursor: pointer; min-height: 56px; }
.kcl-dot:hover { background: var(--bg-card-hover, transparent); }
.kcl-dot.is-kpi { background: color-mix(in srgb, var(--kcl-cam) 8%, transparent); }
.kcl-dot-ngay, .kcl-dot-giua { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 13px; }
.kcl-dot-ngay strong { font-size: 14.5px; }
.kcl-dot-tien { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.kcl-dot-tien .kcl-so { font-size: 15px; }
.kcl-dot-nhan { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.kcl-trong-nho { margin: 0; padding: 12px 0; color: var(--text-muted); }

/* Trạng thái màn */
.kcl-trong { display: grid; justify-items: center; gap: 8px; padding: 40px 16px; text-align: center; color: var(--text-muted); background: var(--bg-card); border: 1px dashed var(--border-color); border-radius: 8px; }
.kcl-trong strong { color: var(--text-main); font-size: 16px; }
.kcl-trong.is-loi strong { color: var(--txt-bad); }
.kcl-sk { display: flex; flex-direction: column; gap: 12px; padding: 16px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 8px; }
.kcl-sk span { display: block; height: 14px; border-radius: 6px; background: var(--bg-input, rgba(127, 127, 127, .15)); animation: kcl-nhip 1.2s ease-in-out infinite alternate; }
.kcl-sk span:nth-child(2) { width: 70%; } .kcl-sk span:nth-child(3) { width: 45%; } .kcl-sk span:nth-child(4) { width: 85%; }
.kcl-quay { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--border-color); border-top-color: var(--kcl-cam); animation: kcl-xoay .9s linear infinite; }
@keyframes kcl-nhip { from { opacity: .5; } to { opacity: 1; } }
@keyframes kcl-xoay { to { transform: rotate(360deg); } }

/* Ngăn chi tiết */
.kcl-nen { position: fixed; inset: 0; background: rgba(0, 0, 0, .42); z-index: 10040; }
.kcl-ngan { --kcl-cam: #e8651f; position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); z-index: 10050; background: var(--bg-card); color: var(--text-main); border-left: 1px solid var(--border-color); display: flex; flex-direction: column; padding-top: env(safe-area-inset-top, 0px); }
.kcl-ngan > header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border-color); }
.kcl-ngan h2 { margin: 0; font-size: 18px; line-height: 1.25; }
.kcl-ngan-than { overflow-y: auto; padding: 14px 16px calc(20px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 12px; }
.kcl-dl { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; margin: 0; font-size: 13.5px; }
.kcl-dl dt { color: var(--text-muted); } .kcl-dl dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.kcl-n-ds { list-style: none; margin: 0; padding: 0; }
.kcl-n-ds li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 9px 0; border-top: 1px solid var(--border-color); font-size: 13.5px; }
.kcl-n-ds li:first-child { border-top: 0; }
.kcl-n-phu { grid-column: 1 / -1; color: var(--text-muted); font-size: 12.5px; }
body.kcl-mo-ngan { overflow: hidden; }

@media (prefers-reduced-motion: reduce) { .kcl-sk span, .kcl-quay { animation: none; } .kcl-mo-phong::before { transition: none; } }

/* Khổ hẹp: thẻ dọc, không kéo ngang dữ liệu quan trọng */
@media (max-width: 760px) {
  .kcl-dau h1 { font-size: 22px; }
  .kcl-loc > .kcl-thang { flex: 1 1 100%; }
  .kcl-loc > .kcl-thang > div { flex: 1; }
  .kcl-loc > .kcl-seg { flex: 1 1 100%; }
  .kcl-loc > .kcl-seg button { flex: 1; padding: 0 6px; }
  .kcl-loc > .kcl-o { flex: 1 1 100%; min-width: 0; }
  .kcl-loc > .kcl-nut { flex: 1 1 100%; }
  .kcl-loc > .kcl-o select, .kcl-tim input { width: 100%; }
  .kcl-link { min-height: 44px; display: inline-flex; align-items: center; }
  .kcl-tq-luoi { grid-template-columns: 1fr; }
  .kcl-tq-luoi > div { border-left: 0; border-top: 1px solid var(--border-color); }
  .kcl-tq-luoi > div:first-child { border-top: 0; }
  .kcl-so-lon { font-size: 27px; }
  .kcl-so-vua { font-size: 19px; }
  .kcl-phan { padding: 12px; }
  .kcl-bang thead, .kcl-bang tfoot td:nth-child(2) { display: none; }
  .kcl-bang, .kcl-bang tbody, .kcl-bang tfoot { display: block; }
  .kcl-bang tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 10px 0; border-bottom: 1px solid var(--border-color); }
  .kcl-bang th, .kcl-bang td { padding: 0; border: 0; }
  .kcl-bang tr > td:nth-child(2) { display: none; }
  .kcl-bang tr > td:nth-child(3)::before { content: "Lương cơ bản "; color: var(--text-muted); font-weight: 400; }
  .kcl-bang tr > td:nth-child(4)::before { content: "KPI "; color: var(--text-muted); font-weight: 400; }
  .kcl-bang tr > td:nth-child(3), .kcl-bang tr > td:nth-child(4) { grid-column: 1 / -1; text-align: left; font-size: 12.5px; }
  .kcl-bang tr > td:nth-child(5) { grid-column: 2; grid-row: 1; }
  .kcl-bang tr > td:nth-child(6) { grid-column: 1 / -1; }
  .kcl-ray { width: 48px; }
  .kcl-bang tr.kcl-nv-hang { display: block; padding: 0 0 8px; }
  .kcl-nv-hang > td { padding: 0; }
  .kcl-nv-hang li { grid-template-columns: minmax(0, 1fr) auto; }
  .kcl-nv-hang li > span:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .kcl-nv-hang li > .kcl-nv-cb, .kcl-nv-hang li > .kcl-nv-kpi { display: none; }
  .kcl-dot { grid-template-columns: minmax(0, 1fr) auto; }
  .kcl-dot-giua { grid-column: 1 / -1; grid-row: 2; }
  .kcl-dot-tien { grid-column: 2; grid-row: 1; }
  .kcl-ngan { top: auto; width: 100%; height: 88%; border-left: 0; border-top: 1px solid var(--border-color); border-radius: 8px 8px 0 0; padding-top: 0; }
}
.kcl-bao-dong { margin: 0; padding: 8px 12px; border-radius: 8px; font-size: 13px; background: color-mix(in srgb, var(--txt-warn) 10%, transparent); color: var(--text-main); }
