/* ══════════════════════════════════════════════════════════════════════════
   P7a — Bộ công cụ /cong-cu/
   Dựng lại theo tokens.css (xanh #1652E4 + Be Vietnam Pro). Bản kimholding là
   cam #EA580C + Playfair và nhét style thẳng vào thẻ — không tái dùng được.
   ══════════════════════════════════════════════════════════════════════════ */

.ndt { padding: 20px 0 72px; background: var(--kh-bg-alt); }

.ndt-head { margin: 14px 0 22px; max-width: 760px; }
.ndt-head h1 { margin: 0 0 8px; font-size: 30px; font-weight: 600; color: var(--kh-ink); letter-spacing: -.01em; }
.ndt-head p { margin: 0; font-size: 15px; line-height: 1.7; color: var(--kh-muted); }

/* ── Trang tổng ─────────────────────────────────────────────────────────── */
.ndt-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }

.ndt-card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 24px;
  background: var(--kh-bg);
  border: 1px solid var(--kh-line);
  border-radius: var(--kh-r-lg);
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.ndt-card:hover { border-color: var(--kh-brand); box-shadow: var(--kh-sh-hover); transform: translateY(-2px); }
.ndt-card__ic {
  width: 46px; height: 46px; display: grid; place-items: center;
  border-radius: var(--kh-r-md);
  background: var(--kh-brand-tint); color: var(--kh-brand);
  margin-bottom: 4px;
}
.ndt-card__n { font-size: 17px; font-weight: 600; color: var(--kh-ink); }
.ndt-card__d { font-size: 13.5px; line-height: 1.6; color: var(--kh-muted); }
.ndt-card__go {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 6px;
  font-size: 13.5px; font-weight: 500; color: var(--kh-brand);
}

/* ── Khung 2 cột ────────────────────────────────────────────────────────── */
.ndt-2col { display: grid; grid-template-columns: 400px 1fr; gap: 20px; align-items: start; }
.ndt-2col > * { min-width: 0; }

.ndt-panel {
  position: sticky; top: calc(var(--kh-header-h) + 16px);
  background: var(--kh-bg);
  border: 1px solid var(--kh-line);
  border-radius: var(--kh-r-lg);
  padding: 22px;
}
.ndt-panel__t { margin: 0 0 18px; font-size: 17px; font-weight: 600; color: var(--kh-ink); }

.ndt-res { display: flex; flex-direction: column; gap: 14px; }

/* ── Ô nhập ─────────────────────────────────────────────────────────────── */
.ndt-f { margin-bottom: 20px; }
.ndt-f:last-child { margin-bottom: 0; }

.ndt-lb { display: block; font-size: 13px; font-weight: 500; color: var(--kh-text); margin-bottom: 7px; }
.ndt-lbrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.ndt-lbrow .ndt-lb { margin-bottom: 0; }
.ndt-lbrow--top { margin-top: 16px; }

.ndt-pill {
  padding: 4px 11px;
  border-radius: var(--kh-r-sm);
  background: var(--kh-brand-tint);
  color: var(--kh-brand);
  font-size: 13px; font-weight: 600; white-space: nowrap;
}

.ndt-in {
  width: 100%;
  padding: 11px 13px;
  font: inherit; font-size: 15px; font-weight: 500;
  color: var(--kh-ink);
  background: var(--kh-bg);
  border: 1px solid var(--kh-line-strong);
  border-radius: var(--kh-r);
}
.ndt-in:focus { outline: none; border-color: var(--kh-brand); box-shadow: 0 0 0 3px var(--kh-brand-tint); }
select.ndt-in { cursor: pointer; }

.ndt-money { position: relative; }
.ndt-money .ndt-in { padding-right: 54px; }
.ndt-money__u {
  position: absolute; right: 13px; top: 50%; transform: translateY(-50%);
  font-size: 12.5px; font-weight: 600; color: var(--kh-muted-2); pointer-events: none;
}

.ndt-ends { display: flex; justify-content: space-between; gap: 10px; margin-top: 7px; font-size: 12px; color: var(--kh-muted-3); }
.ndt-ends strong { color: var(--kh-ink); font-weight: 600; }

.ndt-note { margin: 8px 0 0; font-size: 12.5px; line-height: 1.6; color: var(--kh-muted-3); }
.ndt-note--pad { padding: 0 20px 16px; }

/* ── Thanh trượt ────────────────────────────────────────────────────────── */
/* Vùng chạm cao 28px cho ngón tay, nhưng dải màu chỉ dày 6px (vẽ ở track). */
.ndt-range {
  --ndt-p: 50%;
  width: 100%; height: 28px;
  margin: 10px 0 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
.ndt-range::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, var(--kh-brand) 0 var(--ndt-p), var(--kh-line-strong) var(--ndt-p) 100%);
}
.ndt-range::-moz-range-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, var(--kh-brand) 0 var(--ndt-p), var(--kh-line-strong) var(--ndt-p) 100%);
}
.ndt-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; margin-top: -7px;
  border-radius: 50%; background: var(--kh-bg);
  border: 2px solid var(--kh-brand);
  box-shadow: 0 2px 6px rgba(16, 34, 78, .2);
}
.ndt-range::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%; background: var(--kh-bg);
  border: 2px solid var(--kh-brand);
}
.ndt-range:focus-visible { outline: 2px solid var(--kh-brand); outline-offset: 4px; }

/* ── Nút phân đoạn ──────────────────────────────────────────────────────── */
.ndt-seg {
  display: grid; grid-template-columns: 1fr 1fr; gap: 5px;
  padding: 5px; background: var(--kh-bg-alt); border-radius: var(--kh-r-md);
}
.ndt-seg--3 { grid-template-columns: repeat(3, 1fr); }
.ndt-segb {
  padding: 9px 6px;
  font: inherit; font-size: 13px; font-weight: 500;
  color: var(--kh-text-2); background: transparent;
  border: 0; border-radius: var(--kh-r-sm); cursor: pointer;
  transition: background .14s ease, color .14s ease;
}
.ndt-segb:hover { color: var(--kh-brand); }
.ndt-segb.is-on { background: var(--kh-bg); color: var(--kh-brand); box-shadow: var(--kh-sh); font-weight: 600; }

/* ── Công tắc ───────────────────────────────────────────────────────────── */
.ndt-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  width: 100%; margin-bottom: 20px; padding: 13px 15px;
  text-align: left; font: inherit;
  background: var(--kh-bg);
  border: 1px solid var(--kh-line-strong);
  border-radius: var(--kh-r); cursor: pointer;
}
.ndt-toggle.is-on { border-color: var(--kh-brand); background: var(--kh-brand-tint-2); }
.ndt-toggle strong { display: block; font-size: 13.5px; font-weight: 500; color: var(--kh-ink); }
.ndt-toggle small { display: block; font-size: 12px; color: var(--kh-muted-2); margin-top: 2px; }
.ndt-sw {
  flex: none; position: relative;
  width: 38px; height: 22px; border-radius: var(--kh-r-full);
  background: var(--kh-line-strong); transition: background .16s ease;
}
.ndt-toggle.is-on .ndt-sw { background: var(--kh-brand); }
.ndt-knob {
  position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  transition: left .16s ease;
}
.ndt-toggle.is-on .ndt-knob { left: 19px; }

/* ── Gói hoàn thiện ─────────────────────────────────────────────────────── */
.ndt-pkgs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ndt-pkg {
  display: flex; flex-direction: column; gap: 3px;
  padding: 12px 8px; font: inherit; text-align: center;
  background: var(--kh-bg);
  border: 1px solid var(--kh-line-strong);
  border-radius: var(--kh-r); cursor: pointer;
}
.ndt-pkg.is-on { border-color: var(--kh-brand); background: var(--kh-brand-tint-2); }
.ndt-pkg__n { font-size: 13.5px; font-weight: 600; color: var(--kh-ink); }
.ndt-pkg.is-on .ndt-pkg__n { color: var(--kh-brand); }
.ndt-pkg__u { font-size: 11.5px; color: var(--kh-muted-2); }

/* ── Khối kết quả lớn ───────────────────────────────────────────────────── */
.ndt-hero {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 6px;
  padding: 26px 28px;
  border-radius: var(--kh-r-lg);
  background: linear-gradient(120deg, var(--kh-brand), var(--kh-brand-hover));
  color: #fff;
}
.ndt-hero::after {
  content: ""; position: absolute; top: -90px; right: -60px;
  width: 280px; height: 280px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .16), transparent 65%);
  pointer-events: none;
}
.ndt-hero.is-bad { background: linear-gradient(120deg, #3B4763, var(--kh-ink)); }
.ndt-hero__l { font-size: 12px; font-weight: 600; letter-spacing: .1em; opacity: .85; }
.ndt-hero__n { font-size: 38px; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; }
.ndt-hero__n--sm { font-size: 26px; }
.ndt-hero__s { font-size: 13.5px; opacity: .9; line-height: 1.6; }
.ndt-hero__s strong { font-weight: 600; }
.ndt-hero__ic { width: 30px; height: 30px; margin-bottom: 2px; }

.ndt-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.ndt-stat {
  display: flex; flex-direction: column; gap: 5px;
  padding: 16px 18px;
  background: var(--kh-bg); border: 1px solid var(--kh-line); border-radius: var(--kh-r-md);
}
.ndt-stat__l { font-size: 12.5px; color: var(--kh-muted-2); }
.ndt-stat__v { font-size: 19px; font-weight: 600; color: var(--kh-ink); }
.ndt-stat__v.is-warn { color: var(--kh-warning); }

/* ── Hộp ────────────────────────────────────────────────────────────────── */
.ndt-box { background: var(--kh-bg); border: 1px solid var(--kh-line); border-radius: var(--kh-r-lg); overflow: hidden; }
.ndt-box--pad { padding: 20px; }
.ndt-box__t {
  margin: 0; padding: 16px 20px;
  font-size: 14.5px; font-weight: 600; color: var(--kh-ink);
  border-bottom: 1px solid var(--kh-line);
}
.ndt-box--pad .ndt-box__t { padding: 0 0 10px; }
.ndt-box__t small { font-weight: 400; color: var(--kh-muted-3); font-size: 12.5px; }

.ndt-split { display: grid; grid-template-columns: 150px 1fr; gap: 22px; align-items: center; padding: 22px; }

.ndt-donut {
  position: relative; width: 150px; height: 150px; border-radius: 50%;
  background: var(--kh-line);
}
.ndt-donut__hole {
  position: absolute; inset: 26px;
  border-radius: 50%; background: var(--kh-bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
}
.ndt-donut__hole span { font-size: 22px; font-weight: 600; color: var(--kh-ink); }
.ndt-donut__hole small { font-size: 11px; color: var(--kh-muted-2); }

.ndt-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.ndt-legend li { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--kh-text-2); }
.ndt-legend strong { margin-left: auto; font-weight: 600; color: var(--kh-ink); }
.ndt-dot { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.ndt-dot--down { background: var(--kh-brand-pale); }
.ndt-dot--loan { background: var(--kh-ink); }
.ndt-dot--int { background: var(--kh-brand); }

.ndt-tip {
  margin: 0; padding: 14px 16px;
  background: var(--kh-brand-tint-2);
  border: 1px solid var(--kh-brand-line);
  border-radius: var(--kh-r);
  font-size: 13.5px; line-height: 1.65; color: var(--kh-text);
}
.ndt-tip strong { color: var(--kh-ink); font-weight: 600; }

.ndt-warnbox {
  margin-top: 18px; padding: 13px 15px;
  background: #FFFBEB; border: 1px solid #FDE68A; border-radius: var(--kh-r);
  font-size: 12.5px; line-height: 1.65; color: var(--kh-text-2);
}
.ndt-warnbox strong { display: block; color: var(--kh-ink); margin-bottom: 3px; }

.ndt-ul { margin: 0; padding-left: 18px; font-size: 13.5px; line-height: 1.75; color: var(--kh-muted); }
.ndt-ul strong { color: var(--kh-ink); font-weight: 600; }

/* ── Dòng liệt kê ───────────────────────────────────────────────────────── */
.ndt-line {
  display: grid; grid-template-columns: 1fr 110px 120px; align-items: center; gap: 10px;
  padding: 13px 20px; border-bottom: 1px solid var(--kh-line);
}
.ndt-line:last-child { border-bottom: 0; }
.ndt-line__n { font-size: 14px; font-weight: 500; color: var(--kh-ink); }
.ndt-line__n small { display: block; font-size: 12px; font-weight: 400; color: var(--kh-muted-3); margin-top: 2px; }
.ndt-line__c { text-align: right; font-size: 13px; color: var(--kh-muted-2); }
.ndt-line__v { text-align: right; font-size: 15px; font-weight: 600; color: var(--kh-ink); }
/* Bảng quy đổi chỉ có 2 cột */
#qd-rows .ndt-line,
#qd-pricerows .ndt-line { grid-template-columns: 1fr auto; }

.ndt-sum {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; background: var(--kh-bg-alt);
  font-size: 14px; color: var(--kh-text-2);
}
.ndt-sum strong { font-size: 17px; font-weight: 600; color: var(--kh-ink); }

/* ── Bảng lịch trả nợ ───────────────────────────────────────────────────── */
.ndt-tblwrap { overflow-x: auto; }
.ndt-tbl { min-width: 460px; }
.ndt-tbl__h,
.ndt-tbl__r { display: grid; grid-template-columns: 56px repeat(4, 1fr); gap: 8px; padding: 10px 20px; }
.ndt-tbl__h {
  font-size: 12px; font-weight: 600; color: var(--kh-muted-2);
  background: var(--kh-bg-alt); border-bottom: 1px solid var(--kh-line);
}
.ndt-tbl__h span + span,
.ndt-tbl__r span + span { text-align: right; }
.ndt-tbl__r { font-size: 13.5px; color: var(--kh-text-2); border-bottom: 1px solid var(--kh-line); }
.ndt-tbl__r:nth-child(even) { background: var(--kh-bg-footer); }
.ndt-tbl__r span:first-child { font-weight: 600; color: var(--kh-ink); }
.ndt-tbl__r .is-warn { color: var(--kh-warning); }
.ndt-tbl__r .is-b { font-weight: 600; color: var(--kh-ink); }

/* ── Tuổi xây nhà ───────────────────────────────────────────────────────── */
.ndt-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.ndt-facts > div {
  display: flex; flex-direction: column; gap: 3px;
  padding: 12px 14px; background: var(--kh-bg-alt); border-radius: var(--kh-r);
}
.ndt-facts span { font-size: 12px; color: var(--kh-muted-2); }
.ndt-facts strong { font-size: 15px; font-weight: 600; color: var(--kh-ink); }

.ndt-checks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.ndt-check {
  padding: 16px 18px;
  background: var(--kh-bg); border: 1px solid var(--kh-line); border-radius: var(--kh-r-md);
}
.ndt-check.is-bad { border-color: rgba(229, 72, 77, .38); }
.ndt-check__h { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ndt-check__h span:first-child { font-size: 14.5px; font-weight: 600; color: var(--kh-ink); }
.ndt-tag { padding: 4px 9px; border-radius: var(--kh-r-full); font-size: 10.5px; font-weight: 600; white-space: nowrap; }
.ndt-tag.is-ok { background: #E7F6EE; color: var(--kh-success); }
.ndt-tag.is-bad { background: #FEE2E2; color: var(--kh-danger); }
.ndt-check__s { margin-top: 11px; font-size: 13px; font-weight: 600; color: var(--kh-success); }
.ndt-check__s.is-bad { color: var(--kh-danger); }
.ndt-check__d { margin: 4px 0 0; font-size: 12.5px; line-height: 1.6; color: var(--kh-muted-2); }

.ndt-years { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; padding: 16px 20px; }
.ndt-year {
  display: flex; flex-direction: column; gap: 2px; align-items: center;
  padding: 10px 4px; font: inherit;
  background: var(--kh-bg); border: 1px solid var(--kh-line-strong);
  border-radius: var(--kh-r); cursor: pointer;
}
.ndt-year b { font-size: 14px; font-weight: 600; color: var(--kh-muted-2); }
.ndt-year small { font-size: 11px; color: var(--kh-muted-3); }
.ndt-year.is-good { border-color: rgba(14, 143, 70, .4); background: #F2FBF6; }
.ndt-year.is-good b { color: var(--kh-success); }
.ndt-year.is-good small { color: var(--kh-success); }
.ndt-year.is-cur { border-color: var(--kh-brand); box-shadow: 0 0 0 2px var(--kh-brand-tint); }

/* ── Chân trang công cụ ─────────────────────────────────────────────────── */
.ndt-more { margin-top: 28px; }
.ndt-more h2 { margin: 0 0 12px; font-size: 16px; font-weight: 600; color: var(--kh-ink); }
.ndt-morelist { display: flex; flex-wrap: wrap; gap: 10px; }
.ndt-morelist a {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  background: var(--kh-bg); border: 1px solid var(--kh-line-strong);
  border-radius: var(--kh-r-full);
  font-size: 13.5px; color: var(--kh-text-2);
}
.ndt-morelist a:hover { border-color: var(--kh-brand); color: var(--kh-brand); }

.ndt-disclaimer {
  margin: 22px 0 0; padding: 14px 16px;
  background: var(--kh-bg); border: 1px dashed var(--kh-line-strong);
  border-radius: var(--kh-r);
  font-size: 12.5px; line-height: 1.7; color: var(--kh-muted-2);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1023px) {
  .ndt-2col { grid-template-columns: 1fr; }
  .ndt-panel { position: static; }
  .ndt-checks { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .ndt { padding: 14px 0 56px; }
  .ndt-head h1 { font-size: 22px; }
  .ndt-grid { grid-template-columns: 1fr; }
  .ndt-panel,
  .ndt-box--pad { padding: 16px; }
  .ndt-hero { padding: 20px; }
  .ndt-hero__n { font-size: 28px; }
  .ndt-hero__n--sm { font-size: 21px; }
  .ndt-stats { grid-template-columns: 1fr; }
  .ndt-split { grid-template-columns: 1fr; justify-items: center; text-align: left; }
  .ndt-legend { width: 100%; }
  .ndt-line { grid-template-columns: 1fr auto; gap: 6px 10px; }
  .ndt-line__c { grid-column: 2; font-size: 12px; }
  .ndt-years { grid-template-columns: repeat(3, 1fr); }
  .ndt-pkgs { grid-template-columns: 1fr; }
  .ndt-seg--3 { grid-template-columns: 1fr; }
  /* iOS phóng to trang khi ô nhập < 16px */
  .ndt-in { font-size: 16px; }
}
