/**
 * KEHOACH.CSS — Giao diện mục "Kế hoạch lộ trình" (Cổng KMS). Tiền tố kh-, dùng lại biến và lớp nd- của ndtc.css.
 */
.kh-fields { display: grid; grid-template-columns: minmax(180px, 1.4fr) repeat(2, minmax(140px, 1fr)) auto; gap: 12px 14px; align-items: end; margin: 4px 0 6px; }
.kh-fields .nd-fs { flex: none; min-width: 0; }
.kh-check { display: flex; align-items: center; gap: 8px; height: 42px; font-size: .84rem; font-weight: 700; color: var(--nd-dim); cursor: pointer; white-space: nowrap; }
.kh-check input { width: 17px; height: 17px; accent-color: var(--nd-brand); }

.kh-step { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 18px 0 8px; font-size: .9rem; color: var(--nd-text); }
.kh-step b { font-weight: 800; }
.kh-pickbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.kh-pickbar .nd-input { flex: 1 1 240px; width: auto; height: 42px; }
.kh-pickbar .nd-select { flex: 0 1 210px; width: auto; height: 42px; }

.kh-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.kh-chips:empty { display: none; }
.kh-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 10px; border-radius: 999px; background: var(--nd-brand-soft); border: 1px solid rgba(185, 28, 28, .25); color: var(--nd-brand-2); font-size: .8rem; font-weight: 800; }
.kh-chip i { font-style: normal; display: inline-grid; place-items: center; min-width: 20px; height: 20px; border-radius: 50%; background: var(--nd-brand-2); color: #fff; font-size: .7rem; }
.kh-chip button { border: 0; background: transparent; color: var(--nd-brand-2); cursor: pointer; font-size: .78rem; font-weight: 800; padding: 2px 5px; border-radius: 6px; line-height: 1; }
.kh-chip button:hover:not(:disabled) { background: rgba(185, 28, 28, .12); }
.kh-chip button:disabled { opacity: .3; cursor: default; }

.kh-pick { border: 1px solid var(--nd-border); border-radius: 14px; max-height: 292px; overflow: auto; background: var(--nd-surface); }
.kh-store { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--nd-grid); cursor: pointer; }
.kh-store:last-child { border-bottom: 0; }
.kh-store:hover { background: var(--nd-surface-2); }
.kh-store.on { background: var(--nd-brand-soft); }
.kh-store input { width: 18px; height: 18px; accent-color: var(--nd-brand); margin: 0; }
.kh-store-t { min-width: 0; display: block; }
.kh-store-t b { display: block; font-size: .9rem; color: var(--nd-text); }
.kh-store-t small { display: block; font-size: .74rem; color: var(--nd-faint); margin-top: 2px; line-height: 1.4; }
.kh-store-t em { font-style: normal; color: var(--nd-serious-text); font-weight: 700; }

.kh-prev { border: 1px solid var(--nd-border); border-radius: 14px; overflow: hidden; background: var(--nd-surface); }
.kh-prow { display: grid; grid-template-columns: 84px minmax(180px, 320px) minmax(0, 1fr); gap: 12px; align-items: center; padding: 9px 14px; border-bottom: 1px solid var(--nd-grid); }
.kh-prow:last-child { border-bottom: 0; }
.kh-prow.sun { background: var(--nd-surface-2); }
.kh-pd { display: flex; align-items: baseline; gap: 7px; }
.kh-pd b { font-size: .95rem; color: var(--nd-text); }
.kh-pd span { font-size: .74rem; font-weight: 800; color: var(--nd-faint); }
.kh-prow.sun .kh-pd span { color: var(--nd-crit-text); }
.kh-prow .nd-select { height: 38px; padding-top: 0; padding-bottom: 0; }
.kh-pn { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; min-width: 0; }

.kh-foot { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.kh-foot .nd-btn { height: 42px; border-radius: 12px; }
.kh-warn { margin: 10px 0 0; background: rgba(250, 178, 25, .14); color: var(--nd-warn-text); }
.kh-err { background: rgba(208, 59, 59, .1); color: var(--nd-crit-text); }
.kh-ok { background: rgba(12, 163, 12, .1); color: var(--nd-good-text); }
#khMsg .nd-note { margin: 12px 0 0; }

.kh-viewbar { margin: 0 0 12px; }
.kh-viewbar .nd-select { width: auto; min-width: 200px; height: 40px; }
.kh-plans { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; align-items: start; }
.kh-pc { padding: 14px 16px 10px; }
.kh-pc-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.kh-pc-h b { display: block; font-size: .96rem; color: var(--nd-text); }
.kh-rg { display: grid; grid-template-columns: 78px minmax(0, 1fr); gap: 6px 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--nd-grid); }
.kh-rg-d b { display: block; font-size: .88rem; color: var(--nd-text); }
.kh-rg-d span { font-size: .72rem; font-weight: 800; color: var(--nd-faint); }
.kh-rg-s { font-weight: 800; font-size: .9rem; color: var(--nd-text); min-width: 0; }
.kh-rg-s small { display: block; font-size: .72rem; font-weight: 600; color: var(--nd-faint); margin-top: 1px; }
.kh-rg-a { display: flex; gap: 6px; flex-wrap: wrap; grid-column: 2; }
.kh-rg.past .kh-rg-s, .kh-rg.past .kh-rg-d b { color: var(--nd-faint); }
.kh-rg.now { background: linear-gradient(90deg, rgba(42, 120, 214, .09), transparent); margin: 0 -16px; padding-left: 16px; padding-right: 16px; border-top-color: rgba(42, 120, 214, .25); }
.kh-rg.now .kh-rg-d b { color: var(--nd-blue); }

@media (max-width: 820px) {
  .kh-fields { grid-template-columns: 1fr 1fr; }
  .kh-fields .nd-fs:first-child { grid-column: 1 / -1; }
  .kh-check { grid-column: 1 / -1; height: auto; }
}
@media (max-width: 640px) {
  .kh-form { padding: 14px 14px 12px; }
  .kh-store { grid-template-columns: 22px minmax(0, 1fr); }
  .kh-store .nd-pill { grid-column: 2; justify-self: start; }
  .kh-prow { grid-template-columns: 70px minmax(0, 1fr); }
  .kh-pn { grid-column: 1 / -1; }
  .kh-plans { grid-template-columns: 1fr; }
  .kh-rg { grid-template-columns: 70px minmax(0, 1fr); }
  .kh-rg-a { grid-column: 1 / -1; }
  .kh-foot .nd-btn { flex: 1 1 100%; }
  .kh-pickbar .nd-select { flex: 1 1 100%; }
}

/* ---------- Popup lập kế hoạch ---------- */
.kh-modal { position: fixed; inset: 0; z-index: 1000020; background: rgba(15, 23, 42, .55); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 18px; }
.kh-modal-card { width: min(900px, 100%); max-height: calc(100vh - 36px); background: var(--nd-surface); color: var(--nd-text); border-radius: 20px; box-shadow: 0 24px 60px rgba(15, 23, 42, .35); display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--nd-border); }
.kh-modal-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 22px 14px; border-bottom: 1px solid var(--nd-grid); background: linear-gradient(180deg, var(--nd-brand-soft), transparent); }
.kh-modal-h h3 { margin: 0; font-size: 1.12rem; font-weight: 800; color: var(--nd-brand-2); }
.kh-modal-h p { margin: 3px 0 0; font-size: .8rem; color: var(--nd-faint); }
.kh-x { border: 0; background: var(--nd-surface-2); color: var(--nd-dim); width: 36px; height: 36px; border-radius: 50%; font-size: 1.4rem; line-height: 1; cursor: pointer; flex: none; }
.kh-x:hover { background: var(--nd-brand-soft); color: var(--nd-brand); }
.kh-modal-b { padding: 16px 22px 0; overflow: auto; flex: 1; min-height: 0; }
.kh-modal-b .kh-foot { position: sticky; bottom: 0; background: var(--nd-surface); margin: 16px -22px 0; padding: 12px 22px 14px; border-top: 1px solid var(--nd-grid); }
.kh-target { margin: 10px 0 0; }
.kh-target b { color: var(--nd-serious-text); }
.kh-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.kh-detail .kh-wide { grid-column: 1 / -1; }
.kh-detail .nd-fs { flex: none; min-width: 0; }
.kh-detail .nd-textarea { min-height: 62px; }
.kh-detail input[readonly] { background: var(--nd-surface-2); color: var(--nd-dim); }

/* ---------- Lộ trình trong sheet cá nhân ---------- */
.kh-ws { margin-top: 8px; border-top: 1px dashed var(--nd-border); padding-top: 8px; }
.kh-ws-h { font-size: .68rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--nd-faint); margin-bottom: 4px; }
.kh-w { display: grid; grid-template-columns: 138px minmax(0, 1fr); gap: 10px; padding: 6px 0; border-top: 1px solid var(--nd-grid); font-size: .82rem; }
.kh-w:first-of-type { border-top: 0; }
.kh-w-t { color: var(--nd-faint); font-weight: 700; font-size: .74rem; }
.kh-w-b b { display: block; color: var(--nd-text); font-weight: 800; }
.kh-w-b small { display: block; color: var(--nd-serious-text); font-weight: 700; margin-top: 2px; }
.kh-w-b span { display: inline-block; margin-top: 3px; }

@media (max-width: 640px) {
  .kh-modal { padding: 0; align-items: stretch; }
  .kh-modal-card { max-height: none; height: 100%; border-radius: 0; border: 0; }
  .kh-modal-h { padding: 14px 16px 12px; }
  .kh-modal-b { padding: 12px 16px 0; }
  .kh-modal-b .kh-foot { margin: 14px -16px 0; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); }
  .kh-modal-b .kh-foot .nd-btn { flex: 1 1 auto; }
  .kh-detail { grid-template-columns: 1fr; }
  .kh-w { grid-template-columns: 1fr; gap: 2px; }
}

/* Hộp "Xác nhận gửi" dùng chung của KMS (z-index 1000000) phải nằm TRÊN popup lập kế hoạch, nếu không bấm Lưu sẽ như không có phản ứng */
#kmsConfirmSubmitModal { z-index: 1000030; }

/* KMS không còn footer: bỏ khoảng đệm 60px dưới cùng, nếu không thanh bên (sticky) bị đẩy trượt lên khi cuộn tới cuối trang */
#kmsApp .dms-main { padding-bottom: 0 !important; }
#kmsApp .nd-main { padding-bottom: 24px; }

/* ---------- v2.2: nhân sự dạng ô chữ nhật + khung chi tiết bên phải ---------- */
.kh-viewbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 18px; }
.kh-legend { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 700; color: var(--nd-faint); }
.kh-legend .kh-cell { flex: none; width: 12px; height: 12px; margin-left: 8px; }
.kh-legend .kh-cell:first-child { margin-left: 0; }
.kh-hint { font-size: .78rem; color: var(--nd-faint); margin-left: auto; }
.kh-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; align-items: stretch; }
.kh-tile {
  display: flex; flex-direction: column; gap: 12px; text-align: left; width: 100%; min-width: 0; padding: 16px;
  background: var(--nd-surface); color: var(--nd-text); border: 1px solid var(--nd-border); border-radius: 16px; box-shadow: var(--nd-shadow);
  font-family: inherit; cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s;
}
.kh-tile:hover { transform: translateY(-2px); border-color: var(--nd-neutral); box-shadow: 0 10px 26px rgba(15, 23, 42, .12); }
.kh-tile:focus-visible { outline: 2px solid var(--nd-brand); outline-offset: 2px; }
.kh-tile.is-now { border-color: rgba(42, 120, 214, .45); }
.kh-t-h { display: flex; align-items: center; gap: 12px; min-width: 0; }
.kh-av { width: 42px; height: 42px; flex: none; border-radius: 50%; display: grid; place-items: center; background: #0f172a; color: #fff; font-size: .78rem; font-weight: 800; letter-spacing: .03em; }
[data-theme="dark"] .kh-av { background: #334155; }
.kh-av.lg { width: 48px; height: 48px; font-size: .88rem; }
.kh-t-n { min-width: 0; flex: 1; }
.kh-t-n b { display: block; font-size: .98rem; font-weight: 800; color: var(--nd-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kh-t-n span { display: block; font-size: .75rem; color: var(--nd-faint); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kh-t-h .nd-pill { flex: none; }
.kh-strip { display: flex; gap: 2px; }
.kh-cell { display: block; flex: 1 1 0; min-width: 0; height: 16px; border-radius: 3px; background: var(--nd-grid); }
.kh-cell.sun { background: var(--nd-surface-2); box-shadow: inset 0 0 0 1px var(--nd-grid); }
.kh-cell.plan { background: var(--nd-blue); }
.kh-cell.past { background: var(--nd-neutral); }
.kh-cell.today { box-shadow: 0 0 0 2px var(--nd-brand); position: relative; z-index: 1; }
.kh-t-stats { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.kh-t-stats div { background: var(--nd-surface-2); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.kh-t-stats b { display: block; font-size: 1.2rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--nd-text); }
.kh-t-stats span { display: block; margin-top: 3px; font-size: .7rem; font-weight: 600; color: var(--nd-faint); line-height: 1.25; }
.kh-t-focus { border: 1px dashed var(--nd-border); border-radius: 10px; padding: 9px 12px; min-width: 0; flex: 1; }
.kh-t-l { display: block; font-size: .66rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--nd-faint); }
.kh-t-l.is-now { color: var(--nd-blue); }
.kh-t-focus b { display: block; margin-top: 2px; font-size: .88rem; font-weight: 800; color: var(--nd-text); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.kh-t-focus b.kh-t-none { color: var(--nd-faint); font-weight: 600; }
.kh-t-focus small { display: block; margin-top: 2px; font-size: .74rem; color: var(--nd-faint); font-variant-numeric: tabular-nums; }
.kh-t-more { display: flex; align-items: center; justify-content: flex-end; gap: 2px; font-size: .8rem; font-weight: 700; color: var(--nd-faint); transition: color .15s; }
.kh-t-more svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.kh-tile:hover .kh-t-more { color: var(--nd-brand); }

.kh-scrim { position: fixed; inset: 0; z-index: 1000010; background: rgba(15, 23, 42, .5); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .2s; }
.kh-scrim.open { opacity: 1; pointer-events: auto; }
.kh-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 520px; max-width: 100vw; z-index: 1000011; display: flex; flex-direction: column;
  background: var(--nd-surface); color: var(--nd-text); border-left: 1px solid var(--nd-border); box-shadow: -20px 0 50px rgba(0, 0, 0, .25);
  transform: translateX(104%); transition: transform .25s ease; visibility: hidden;
}
.kh-drawer.open { transform: none; visibility: visible; }
.kh-dr-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--nd-border); padding-top: max(18px, env(safe-area-inset-top, 0px)); }
.kh-dr-act { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 20px; border-bottom: 1px solid var(--nd-grid); }
.kh-dr-body { flex: 1; overflow-y: auto; padding: 16px 20px max(24px, env(safe-area-inset-bottom, 0px)); }
.kh-dr-sec { margin-bottom: 18px; }
.kh-dr-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--nd-faint); }
.kh-dr-h span { text-transform: none; letter-spacing: 0; font-weight: 700; }
.kh-dr-body .kh-strip { margin-bottom: 6px; }
@media (max-width: 640px) {
  .kh-tiles { grid-template-columns: 1fr; }
  .kh-hint { margin-left: 0; flex-basis: 100%; }
  .kh-drawer { width: 100vw; }
}
@media (prefers-reduced-motion: reduce) { .kh-tile, .kh-drawer, .kh-scrim { transition: none; } .kh-tile:hover { transform: none; } }
