/* Tab "Tiến độ" KPI (120, anh Nghĩa duyệt demo 19/10/2026) — khung ns-* (nhan-su.css) + lkw-seg (luong-kpi.css). Màu lấy từ biến chủ đề của app
   (xanh đạt / vàng cam chậm / đỏ khó / xanh dương thời gian / vàng kim "chỉ số tiên tri"); bo ≤ 8px, ô bấm ≥ 44px; ≤ 760px: thẻ một cột, bảng thành thẻ. */
.ktd {
  --td-ok: var(--color-green, #34c759); --td-ok-soft: var(--color-green-soft, rgba(52, 199, 89, .14));
  --td-warn: var(--color-amber, #ff9f0a); --td-warn-soft: var(--color-amber-soft, rgba(255, 159, 10, .16));
  --td-bad: var(--color-red, #ff3b30); --td-bad-soft: var(--color-red-soft, rgba(255, 59, 48, .12));
  --td-accent: var(--theme-accent-strong, var(--color-blue, #0071e3)); --td-gold: var(--color-gold, #b8892b);
  --td-track: color-mix(in srgb, var(--text-muted, #8e8e93) 22%, transparent);
  display: grid; gap: 0; min-width: 0;
}
.ktd .ns-ic { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ktd .td-thanh { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin: 0 0 14px; }
.ktd .td-thanh .ns-btn .ns-ic { width: 16px; height: 16px; }
.ktd .ns-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Dải thời gian của tháng */
.ktd .td-ky { display: grid; gap: 10px; padding: 14px 16px; margin: 0 0 18px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 8px; }
.ktd .td-ky-1 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; font-size: 14px; }
.ktd .td-ky-1 strong { font-size: 16px; }
.ktd .td-cap { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 13px; margin-left: auto; }
.ktd .td-cap .ns-ic { width: 14px; height: 14px; }
.ktd .td-tl { position: relative; height: 10px; border-radius: 5px; background: var(--td-track); margin: 24px 0 6px; }
.ktd .td-tl > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 5px; background: var(--td-accent); }
.ktd .td-tl > b { position: absolute; top: -8px; width: 2px; height: 26px; background: var(--text-main); transform: translateX(-1px); border-radius: 1px; }
.ktd .td-tl > b::after { content: attr(data-nhan); position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 12px; font-weight: 700; color: var(--text-main); white-space: nowrap; }
.ktd .td-tl-ct { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); }

/* Khối chi nhánh + thẻ từng mục */
.ktd .td-cn { margin: 0 0 24px; min-width: 0; }
.ktd .td-cn-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; margin: 4px 0 10px; }
.ktd .td-cn-h h2 { margin: 0; font-size: 18px; font-weight: 700; }
.ktd .td-cn > .ns-alert { margin: 0 0 10px; display: flex; gap: 8px; align-items: flex-start; }
.ktd .td-cn > .ns-alert .ns-ic { color: var(--td-warn); margin-top: 2px; }
.ktd .td-ds { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 0 0 16px; }
.ktd .td-the { display: grid; gap: 12px; align-content: start; padding: 16px 18px 14px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 8px; min-width: 0; }
.ktd .td-the-1 { display: flex; align-items: flex-start; gap: 12px; }
.ktd .td-the-1 h3 { margin: 0; font-size: 17px; font-weight: 700; line-height: 1.25; }
.ktd .td-the-1 .ns-hint { margin: 2px 0 0; }
.ktd .td-pt { margin-left: auto; text-align: right; line-height: 1; }
.ktd .td-pt b { display: block; font-size: 36px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.ktd .td-pt span { display: block; margin-top: 4px; font-size: 12px; color: var(--text-muted); font-weight: 600; }
.ktd .td-so { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; }
.ktd .td-so > div { padding: 8px 10px; border-radius: 8px; background: var(--bg-card-hover); min-width: 0; }
.ktd .td-so dt { font-size: 12px; font-weight: 600; color: var(--text-muted); margin: 0; }
.ktd .td-so dd { margin: 2px 0 0; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ktd .td-so dd.is-thieu { color: var(--td-warn); }
.ktd .td-so dd.is-du { color: var(--td-ok); }
.ktd .td-bar { position: relative; padding: 20px 0 18px; }
.ktd .td-bar-t { position: relative; height: 12px; border-radius: 6px; background: var(--td-track); }
.ktd .td-bar-t > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; background: var(--td-ok); max-width: 100%; }
.ktd .td-bar-t > i.is-cham { background: var(--td-warn); }
.ktd .td-bar-t > i.is-du { background: color-mix(in srgb, var(--td-ok) 75%, #000); }
.ktd .td-bar-t > b { position: absolute; top: -4px; width: 2px; height: 20px; background: var(--text-main); opacity: .85; transform: translateX(-1px); border-radius: 1px; }
.ktd .td-bar-t > b.is-tg { background: var(--td-accent); opacity: 1; }
.ktd .td-bar-t > b.is-tg::before { content: attr(data-nhan); position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 700; color: var(--td-accent); white-space: nowrap; }
.ktd .td-bar-t > b.is-moc::after { content: attr(data-nhan); position: absolute; top: 22px; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 700; color: var(--text-muted); white-space: nowrap; }
.ktd .td-bar-t > b.is-moc.is-100::after { transform: translateX(-100%); left: 2px; }
.ktd .td-nhip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 8px; width: fit-content; }
.ktd .td-nhip.is-nhanh { background: var(--td-ok-soft); color: var(--text-main); } .ktd .td-nhip.is-nhanh .ns-ic { color: var(--td-ok); }
.ktd .td-nhip.is-cham { background: var(--td-warn-soft); color: var(--text-main); } .ktd .td-nhip.is-cham .ns-ic { color: var(--td-warn); }
.ktd .td-nhip.is-dung { background: var(--bg-card-hover); color: var(--text-muted); }
.ktd .td-nhip .ns-ic { width: 14px; height: 14px; stroke-width: 2.5; }
.ktd .td-tt { display: grid; gap: 8px; padding: 12px 12px 10px; border-radius: 8px; border: 1px solid var(--border-color); background: linear-gradient(180deg, color-mix(in srgb, var(--td-gold) 12%, transparent), transparent 70%); }
.ktd .td-tt-h { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--td-gold); }
.ktd .td-tt-h .ns-ic { width: 15px; height: 15px; }
.ktd .td-db { font-size: 15px; }
.ktd .td-db b { font-size: 17px; font-variant-numeric: tabular-nums; }
.ktd .td-db .ns-hint { display: block; margin-top: 1px; }
.ktd .td-moc { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.ktd .td-moc li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 8px 0 0; border-top: 1px dashed var(--border-color); font-size: 14px; }
.ktd .td-moc-t { flex: 1 1 220px; min-width: 0; }
.ktd .td-moc-t strong { font-variant-numeric: tabular-nums; }
.ktd .td-moc-t .ns-hint { display: block; }
.ktd .td-kn { display: inline-flex; align-items: center; gap: 5px; min-height: 28px; padding: 2px 10px; border-radius: 8px; font-size: 13px; font-weight: 700; white-space: nowrap; margin-left: auto; color: var(--text-main); }
.ktd .td-kn .ns-ic { width: 14px; height: 14px; stroke-width: 3; }
.ktd .td-kn.is-dat { background: color-mix(in srgb, var(--td-ok) 78%, #000); color: #fff; }
.ktd .td-kn.is-gan { background: var(--td-ok-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--td-ok) 45%, transparent); }
.ktd .td-kn.is-cao { background: color-mix(in srgb, var(--td-ok) 8%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--td-ok) 30%, transparent); }
.ktd .td-kn.is-tang { background: var(--td-warn-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--td-warn) 45%, transparent); }
.ktd .td-kn.is-kho { background: var(--td-bad-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--td-bad) 45%, transparent); }
.ktd .td-kn.is-thieu { background: var(--bg-card-hover); color: var(--text-muted); }

/* Bảng từng người */
.ktd .td-tool { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; margin: 0 0 10px; }
.ktd .td-tool h3 { margin: 0 auto 0 0; font-size: 16px; font-weight: 700; align-self: center; }
.ktd .td-tool .ns-sel { flex: 0 1 220px; }
.ktd .td-bang th:first-child, .ktd .td-bang td:first-child { min-width: 180px; }
.ktd .td-bang td { vertical-align: middle; }
.ktd .td-bang td.ns-num { white-space: nowrap; }
.ktd .td-ten { font-weight: 600; display: block; }
.ktd .td-ten + .ns-hint { display: block; margin-top: 1px; }
.ktd .td-mini { display: block; height: 5px; width: 120px; max-width: 100%; margin-top: 6px; border-radius: 3px; background: var(--td-track); position: relative; }
.ktd .td-mini > i { display: block; height: 100%; border-radius: 3px; background: var(--td-ok); max-width: 100%; }
.ktd .td-mini > i.is-cham { background: var(--td-warn); }
.ktd .td-mini > b { position: absolute; top: -3px; width: 2px; height: 11px; background: var(--td-accent); transform: translateX(-1px); }
.ktd .td-dl { font-weight: 700; white-space: nowrap; }
.ktd .td-dl.is-nhanh { color: var(--td-ok); } .ktd .td-dl.is-cham { color: var(--td-warn); } .ktd .td-dl.is-dung { color: var(--text-muted); }
.ktd .td-doi td { color: var(--text-muted); }
.ktd td .td-kn { margin: 0; min-height: 26px; font-size: 12px; }
.ktd .td-thieu-ngay { display: inline-flex; align-items: center; gap: 4px; }
.ktd .td-thieu-ngay .ns-ic { width: 12px; height: 12px; }

/* Đang tải */
.ktd .td-tai { display: grid; justify-items: center; gap: 12px; padding: 40px 16px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 8px; color: var(--text-muted); text-align: center; }
.ktd .td-quay { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--td-track); border-top-color: var(--td-accent); animation: td-xoay .9s linear infinite; }
@keyframes td-xoay { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ktd .td-quay { animation: none; } }

/* Điện thoại / khung hẹp — cùng mốc 760px với nhan-su.css (ở đó bảng ns-table bị ẩn để thay bằng thẻ: bảng này tự thành thẻ nên hiện lại) */
@media (max-width: 760px) {
  #lkw-pn .ktd .ns-table-wrap.td-wrap { display: block; overflow-x: visible; }
  .ktd .td-ky { padding: 12px 14px; }
  .ktd .td-cap { margin-left: 0; flex-basis: 100%; }
  .ktd .td-ds { grid-template-columns: 1fr; }
  .ktd .td-the { padding: 14px 14px 12px; }
  .ktd .td-pt b { font-size: 30px; }
  .ktd .td-so { gap: 6px; }
  .ktd .td-so > div { padding: 6px 8px; }
  .ktd .td-so dd { font-size: 14px; }
  .ktd .td-kn { margin-left: 0; }
  .ktd .td-thanh .ns-sel { flex: 1 1 auto; }
  .ktd .td-tool .ns-sel { flex: 1 1 100%; }
  .ktd .td-tool .lkw-seg { flex: 1 1 100%; display: flex; } .ktd .td-tool .lkw-seg button { flex: 1 1 0; }
  .ktd .td-bang thead { display: none; }
  .ktd .td-bang, .ktd .td-bang tbody { display: block; }
  .ktd .td-bang tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 10px; padding: 12px 14px; border-bottom: 1px solid var(--border-color); }
  .ktd .td-bang tbody tr:last-child { border-bottom: 0; }
  .ktd .td-bang td { display: block; padding: 0; border: 0; min-width: 0 !important; }
  .ktd .td-bang td:first-child, .ktd .td-bang td[colspan], .ktd .td-bang td:nth-child(4) { grid-column: 1 / -1; }
  .ktd .td-bang td[colspan]:empty { display: none; }
  /* ghép "mỗi ngày cần mốc dưới" cạnh "khả năng mốc dưới", tương tự mốc 100% */
  .ktd .td-bang td:nth-child(1) { order: 1; } .ktd .td-bang td:nth-child(2) { order: 2; } .ktd .td-bang td:nth-child(3) { order: 3; } .ktd .td-bang td:nth-child(4) { order: 4; }
  .ktd .td-bang td:nth-child(5) { order: 5; } .ktd .td-bang td:nth-child(7) { order: 6; } .ktd .td-bang td:nth-child(6) { order: 7; } .ktd .td-bang td:nth-child(8) { order: 8; }
  #lkw-pn .ktd .td-bang td.ns-num { text-align: left; white-space: normal; }
  .ktd .td-bang td[data-nhan]::before { content: attr(data-nhan); display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 2px; }
  .ktd .td-mini { width: 100%; }
}
