/* Bộ 6 công cụ tài chính chuyên sâu (inc/integration-tools.php).
   :is(#article-rich,body) nâng độ ưu tiên ngang CSS bảng của thân bài (.article-body #article-rich.entry-content table). */
:is(#article-rich,body) .dha-tool{container-type:inline-size;position:relative;margin:28px 0;padding:24px 22px;border:1px solid #f0d7a7;border-radius:18px;background:linear-gradient(180deg,#fffcf6 0%,#fff8ec 100%);color:#1d2433;font-size:15.5px;line-height:1.55;box-shadow:0 10px 30px -18px rgba(7,19,103,.18)}
:is(#article-rich,body) .dha-tool-head{display:flex;flex-wrap:wrap;align-items:flex-start;justify-content:space-between;gap:12px 16px;margin-bottom:14px}
:is(#article-rich,body) .dha-tool h3{margin:0;font-size:21px;line-height:1.3;color:#071367;flex:1 1 280px}
:is(#article-rich,body) .dha-tool-sub{margin:0 0 14px;color:#4a5263;font-size:14.5px}

/* Thanh nút tiện ích */
:is(#article-rich,body) .dha-tool-actions{display:flex;flex-wrap:wrap;gap:6px;align-items:center}
:is(#article-rich,body) .dha-act-btn{min-height:38px;padding:6px 12px;border:1px solid #d5dbe6;border-radius:999px;background:#fff;color:#18386c;font:600 13px/1.2 inherit;cursor:pointer;transition:background .15s ease,border-color .15s ease,transform .1s ease}
:is(#article-rich,body) .dha-act-btn:hover{background:#f1f6ff;border-color:#9eb6de}
:is(#article-rich,body) .dha-act-btn.is-primary{background:#071367;border-color:#071367;color:#fff}
:is(#article-rich,body) .dha-act-btn.is-primary:hover{background:#122596}
:is(#article-rich,body) .dha-act-btn.is-ghost{background:#fff;border-color:#d5dbe6;color:#525c70}
:is(#article-rich,body) .dha-act-btn.is-ghost:hover{color:#b42318;border-color:#f0c9c9;background:#fff5f5}

/* Nút chọn nhanh (Presets) */
:is(#article-rich,body) .dha-presets{display:flex;flex-wrap:wrap;align-items:center;gap:6px;margin:0 0 14px;font-size:13px;color:#4a5263}
:is(#article-rich,body) .dha-presets span{font-weight:600;margin-right:2px}
:is(#article-rich,body) .dha-chip-btn{min-height:36px;padding:6px 12px;border:1px solid #e6cfa4;border-radius:999px;background:#fff;color:#18386c;font:600 13px/1.2 inherit;cursor:pointer;transition:all .15s ease}
:is(#article-rich,body) .dha-chip-btn:hover{background:#ffa116;border-color:#ffa116;color:#1d2433}

/* Form */
:is(#article-rich,body) .dha-tool-form{display:grid;gap:12px 14px;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));align-items:end}
:is(#article-rich,body) .dha-tool-span2{grid-column:1 / -1}
:is(#article-rich,body) .dha-tool-form label{display:flex;flex-direction:column;gap:6px;font-weight:600;font-size:13.5px;color:#18386c}
:is(#article-rich,body) .dha-tool-form input[type=text],:is(#article-rich,body) .dha-tool-form input[type=number],:is(#article-rich,body) .dha-tool-form select{min-height:44px;padding:8px 12px;border:1px solid #d5dbe6;border-radius:10px;font:inherit;font-size:15px;font-weight:400;background:#fff;color:#1d2433;width:100%;box-sizing:border-box}
:is(#article-rich,body) .dha-tool-form input:focus,:is(#article-rich,body) .dha-tool-form select:focus,:is(#article-rich,body) .dha-debt-row input:focus{outline:2px solid #ffa116;outline-offset:1px;border-color:#ffa116}
:is(#article-rich,body) .dha-tool fieldset{border:0;margin:0;padding:0;display:flex;flex-direction:column;gap:6px}
:is(#article-rich,body) .dha-tool legend{font-weight:600;font-size:13.5px;color:#18386c;margin-bottom:6px}
:is(#article-rich,body) .dha-radio-grid{display:grid;gap:8px 14px;grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}
:is(#article-rich,body) .dha-tool .dha-tool-radio{flex-direction:row;align-items:center;gap:8px;font-weight:400;color:#1d2433;min-height:36px;padding:6px 10px;border:1px solid #ece3cf;border-radius:10px;background:#fff;cursor:pointer}
:is(#article-rich,body) .dha-tool .dha-tool-radio:has(input:checked){border-color:#ffa116;background:#fff7e6;font-weight:600}

/* Tự chỉnh tỷ lệ 6 hũ */
:is(#article-rich,body) .dha-tool-custom{margin-top:14px;padding:14px;border:1px dashed #e2c792;border-radius:12px;background:#fff}
:is(#article-rich,body) .dha-tool-custom-grid{display:grid;gap:8px;grid-template-columns:repeat(auto-fit,minmax(135px,1fr))}
:is(#article-rich,body) .dha-tool-custom-grid label{display:flex;flex-direction:column;gap:4px;font-size:13px;font-weight:600;color:#18386c}
:is(#article-rich,body) .dha-tool-custom-grid input{min-height:40px;padding:6px 10px;border:1px solid #d5dbe6;border-radius:10px;font:inherit;background:#fff;color:#1d2433}
:is(#article-rich,body) .dha-tool-custom-foot{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px;margin-top:10px}
:is(#article-rich,body) .dha-tool-sum{font-size:14px;font-weight:600;color:#1b7a4b;margin:0}
:is(#article-rich,body) .dha-tool-sum.is-bad{color:#b42318}

/* Danh sách khoản nợ */
:is(#article-rich,body) .dha-debt-head,:is(#article-rich,body) .dha-debt-row{display:grid;gap:8px;grid-template-columns:1.5fr 1.15fr .7fr 1.1fr 40px;align-items:center}
:is(#article-rich,body) .dha-debt-head{font-size:12.5px;font-weight:600;color:#4a5263;margin-bottom:6px;padding:0 2px}
:is(#article-rich,body) .dha-debt-list{display:flex;flex-direction:column;gap:8px;margin-bottom:12px}
:is(#article-rich,body) .dha-debt-row input{min-height:42px;padding:7px 10px;border:1px solid #d5dbe6;border-radius:10px;font:inherit;font-size:14.5px;background:#fff;color:#1d2433;width:100%;box-sizing:border-box}
:is(#article-rich,body) .dha-debt-del{min-height:42px;width:40px;border:1px solid #f0c9c9;border-radius:10px;background:#fff5f5;color:#b42318;font-size:20px;line-height:1;cursor:pointer}
:is(#article-rich,body) .dha-debt-del:hover{background:#fee4e2}
:is(#article-rich,body) .dha-debt-controls{display:flex;flex-wrap:wrap;gap:12px 16px;align-items:flex-end;justify-content:space-between}
:is(#article-rich,body) .dha-debt-extra{flex:1 1 260px;display:flex;flex-direction:column;gap:6px;font-size:13.5px;font-weight:600;color:#18386c}
:is(#article-rich,body) .dha-debt-extra input{min-height:44px;padding:8px 12px;border:1px solid #d5dbe6;border-radius:10px;font:inherit;background:#fff;color:#1d2433}

/* Kết quả & KPI */
:is(#article-rich,body) .dha-tool-result{margin-top:18px}
:is(#article-rich,body) .dha-tool-empty{color:#6b7385;margin:0;padding:14px;border-radius:12px;background:#fff;border:1px dashed #e2d5bc}
:is(#article-rich,body) .dha-kpi-grid{display:grid;gap:10px;grid-template-columns:repeat(auto-fit,minmax(175px,1fr));margin-bottom:16px}
:is(#article-rich,body) .dha-kpi{padding:13px 14px;border-radius:14px;background:#fff;border:1px solid #ebe0ca;display:flex;flex-direction:column;gap:3px}
:is(#article-rich,body) .dha-kpi.is-accent{background:#071367;border-color:#071367;color:#fff}
:is(#article-rich,body) .dha-kpi span{font-size:12.5px;color:#5c667a}
:is(#article-rich,body) .dha-kpi.is-accent span{color:#cdd8ff}
:is(#article-rich,body) .dha-kpi strong{font-size:20px;line-height:1.25;color:#071367}
:is(#article-rich,body) .dha-kpi.is-accent strong{color:#ffb340}
:is(#article-rich,body) .dha-kpi small{font-size:12px;color:#6b7385}
:is(#article-rich,body) .dha-kpi.is-accent small{color:#dce4ff}
:is(#article-rich,body) .dha-pos{color:#15803d!important;font-weight:600}
:is(#article-rich,body) .dha-neg{color:#b42318!important;font-weight:600}

/* Cảnh báo / Chẩn đoán */
:is(#article-rich,body) .dha-tool-alert{margin:14px 0;padding:13px 15px;border-radius:12px;border-left:4px solid #18386c;background:#f4f8ff;font-size:14.5px}
:is(#article-rich,body) .dha-tool-alert strong{display:block;margin-bottom:4px;color:#071367}
:is(#article-rich,body) .dha-tool-alert p{margin:0}
:is(#article-rich,body) .dha-tool-alert.is-good{border-left-color:#16a34a;background:#f0fdf4}
:is(#article-rich,body) .dha-tool-alert.is-good strong{color:#14532d}
:is(#article-rich,body) .dha-tool-alert.is-warn{border-left-color:#d97706;background:#fffbeb}
:is(#article-rich,body) .dha-tool-alert.is-warn strong{color:#92400e}
:is(#article-rich,body) .dha-tool-alert.is-danger{border-left-color:#dc2626;background:#fef2f2}
:is(#article-rich,body) .dha-tool-alert.is-danger strong{color:#991b1b}

/* Biểu đồ Donut & Stacked Bar */
:is(#article-rich,body) .dha-visual-split{display:grid;gap:16px;grid-template-columns:210px 1fr;align-items:start;margin:14px 0}
:is(#article-rich,body) .dha-donut-box{background:#fff;border:1px solid #ebe0ca;border-radius:14px;padding:14px;text-align:center}
:is(#article-rich,body) .dha-donut-svg{width:154px;height:154px;display:block;margin:0 auto 10px}
:is(#article-rich,body) .dha-donut-val{font-size:17px;font-weight:700;fill:#071367}
:is(#article-rich,body) .dha-donut-sub{font-size:11px;fill:#6b7385}
:is(#article-rich,body) .dha-donut-legend{list-style:none;margin:0;padding:0;display:grid;gap:5px;text-align:left;font-size:12.5px}
:is(#article-rich,body) .dha-donut-legend li{display:flex;align-items:center;gap:6px}
:is(#article-rich,body) .dha-donut-legend b{margin-left:auto;color:#071367}
:is(#article-rich,body) .dha-swatch{display:inline-block;width:10px;height:10px;border-radius:3px;background:var(--swatch,#ffa116);flex-shrink:0;margin-right:6px;vertical-align:middle}
:is(#article-rich,body) .dha-chart-wrap{background:#fff;border:1px solid #ebe0ca;border-radius:14px;padding:14px 14px 10px;margin:14px 0}
:is(#article-rich,body) .dha-chart-legend{display:flex;flex-wrap:wrap;gap:14px;font-size:13px;font-weight:600;color:#18386c;margin-bottom:8px}
:is(#article-rich,body) .dha-dot{display:inline-block;width:10px;height:10px;border-radius:3px;margin-right:6px;vertical-align:middle}
:is(#article-rich,body) .dha-dot-navy{background:#18386c}
:is(#article-rich,body) .dha-dot-orange{background:#ffa116}
:is(#article-rich,body) .dha-bar-svg{width:100%;height:auto;display:block}
:is(#article-rich,body) .dha-chart-axis{font-size:11px;fill:#6b7385}

/* Cột mốc tiến độ quỹ dự phòng */
:is(#article-rich,body) .dha-milestones{display:grid;gap:10px;margin:14px 0}
:is(#article-rich,body) .dha-ms{background:#fff;border:1px solid #ebe0ca;border-radius:12px;padding:11px 14px}
:is(#article-rich,body) .dha-ms-head{display:flex;flex-wrap:wrap;justify-content:space-between;gap:6px;font-size:14px;margin-bottom:6px}
:is(#article-rich,body) .dha-prog{height:10px;border-radius:999px;background:#f0e6d2;overflow:hidden;margin-bottom:5px}
:is(#article-rich,body) .dha-prog span{display:block;height:100%;width:var(--w,0%);background:linear-gradient(90deg,#ff9908,#16a34a);border-radius:999px;transition:width .25s ease}
:is(#article-rich,body) .dha-ms small{font-size:12.5px;color:#5c667a}

/* Subcard, 2 cột, Details & Bảng */
:is(#article-rich,body) .dha-two-col{display:grid;gap:14px;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));margin:14px 0}
:is(#article-rich,body) .dha-subcard{background:#fff;border:1px solid #ebe0ca;border-radius:14px;padding:14px;margin:14px 0}
:is(#article-rich,body) .dha-two-col .dha-subcard{margin:0}
:is(#article-rich,body) .dha-subcard h4{margin:0 0 10px;font-size:15.5px;color:#071367}
:is(#article-rich,body) .dha-details{margin:14px 0;background:#fff;border:1px solid #ebe0ca;border-radius:12px;padding:10px 14px}
:is(#article-rich,body) .dha-details.dha-adv{background:#fffdf8}
:is(#article-rich,body) .dha-details summary{cursor:pointer;font-weight:600;color:#18386c;font-size:14px;list-style:none;display:flex;align-items:center;justify-content:space-between;min-height:32px}
:is(#article-rich,body) .dha-details summary::after{content:"▾";font-size:14px;transition:transform .2s ease}
:is(#article-rich,body) .dha-details[open] summary::after{transform:rotate(180deg)}
:is(#article-rich,body) .dha-details[open] summary{margin-bottom:10px}
:is(#article-rich,body) .dha-table-scroll{width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
:is(#article-rich,body) .dha-tool table.dha-tool-table{display:table;width:100%;max-width:100%;margin:0;border-collapse:collapse;font-size:14.5px;overflow:visible;background:#fff;border-radius:12px}
:is(#article-rich,body) .dha-tool-table caption{text-align:left;font-weight:700;margin-bottom:8px;color:#071367;padding:2px 0}
:is(#article-rich,body) .dha-tool .dha-tool-table th,:is(#article-rich,body) .dha-tool .dha-tool-table td{background:none;color:#1d2433;white-space:normal;border:0;padding:8px 8px;border-top:1px solid #f0e3c8;text-align:left;vertical-align:middle}
:is(#article-rich,body) .dha-tool .dha-tool-table thead th{border-top:0;font-size:12.5px;text-transform:uppercase;letter-spacing:.02em;color:#5c667a;font-weight:700;background:#fbf7ee}
:is(#article-rich,body) .dha-tool-table th{font-weight:600}
:is(#article-rich,body) .dha-tool-table th small,:is(#article-rich,body) .dha-tool-table td small{display:block;font-weight:400;color:#6b7385;font-size:12.5px}
:is(#article-rich,body) .dha-tool-table td:last-child{text-align:right;white-space:nowrap}
:is(#article-rich,body) .dha-tool-table tr.is-hit td,:is(#article-rich,body) .dha-tool-table tr.is-hit th{background:#fff8eb}
:is(#article-rich,body) .dha-tool-bar{display:inline-block;vertical-align:middle;width:calc(var(--w) * .85);max-width:56px;height:8px;margin-right:8px;border-radius:4px;background:var(--swatch,#ffa116)}
:is(#article-rich,body) .dha-tool-table td.dha-nowrap{white-space:nowrap}

/* Liên kết chuyển dữ liệu giữa các công cụ */
:is(#article-rich,body) .dha-handoff-row{display:flex;flex-wrap:wrap;gap:8px;margin:14px 0 4px}
:is(#article-rich,body) .dha-handoff-btn{min-height:42px;padding:8px 14px;border:1px solid #bdd0f0;border-radius:10px;background:#f2f6ff;color:#071367;font:600 13.5px/1.25 inherit;cursor:pointer;transition:all .15s ease}
:is(#article-rich,body) .dha-handoff-btn:hover{background:#071367;border-color:#071367;color:#fff}

/* Footer CTA & Toast */
:is(#article-rich,body) .dha-tool-goal{font-size:16.5px;margin:12px 0 6px;color:#071367}
:is(#article-rich,body) .dha-tool-tip{color:#4a5263;font-size:14px;margin:8px 0}
:is(#article-rich,body) .dha-tool-note{color:#6b7385;font-size:13px;margin:16px 0 10px;padding-top:12px;border-top:1px solid #f0e3c8}
:is(#article-rich,body) .dha-tool-cta{display:flex;flex-wrap:wrap;gap:10px 16px;align-items:center;margin:0}
:is(#article-rich,body) .dha-tool-btn{display:inline-flex;align-items:center;min-height:44px;padding:10px 18px;border-radius:999px;background:#ffa116;color:#1d2433!important;font-weight:700;text-decoration:none!important}
:is(#article-rich,body) .dha-tool-btn:hover{background:#ff9100}
:is(#article-rich,body) .dha-tool-link{font-weight:600;color:#071367}
:is(#article-rich,body) .dha-tool-toast{position:fixed;top:84px;left:50%;z-index:9999;padding:11px 18px;border-radius:999px;background:#071367;color:#fff;font-size:14px;font-weight:600;box-shadow:0 12px 30px rgba(7,19,103,.32);opacity:0;transform:translate(-50%,-10px);pointer-events:none;transition:opacity .2s ease,transform .2s ease;max-width:92vw;text-align:center}
:is(#article-rich,body) .dha-tool-toast.is-show{opacity:1;transform:translate(-50%,0)}
.dha-sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}

/* Responsive qua container query & media query */
@container (max-width:680px){
  :is(#article-rich,body) .dha-visual-split{grid-template-columns:1fr}
  :is(#article-rich,body) .dha-debt-head{display:none}
  :is(#article-rich,body) .dha-debt-row{grid-template-columns:1fr 1fr;padding:10px;border:1px solid #ebe0ca;border-radius:12px;background:#fff}
  :is(#article-rich,body) .dha-debt-row input:first-child{grid-column:1 / -1}
  :is(#article-rich,body) .dha-debt-del{grid-column:1 / -1;width:100%}
}
@container (max-width:460px){
  :is(#article-rich,body) .dha-tool-bar{display:none}
  :is(#article-rich,body) .dha-tool-table th small{font-size:12px}
  :is(#article-rich,body) .dha-kpi strong{font-size:18px}
}
@media (max-width:480px){
  :is(#article-rich,body) .dha-tool{padding:18px 14px}
  :is(#article-rich,body) .dha-tool h3{font-size:18.5px}
}
@media print{
  :is(#article-rich,body) .dha-tool-actions,:is(#article-rich,body) .dha-presets,:is(#article-rich,body) .dha-handoff-row,:is(#article-rich,body) .dha-tool-cta,:is(#article-rich,body) .dha-tool-toast{display:none!important}
  :is(#article-rich,body) .dha-tool{border:1px solid #ccc;box-shadow:none;background:#fff}
}
:is(#article-rich,body) .dha-tool [hidden]{display:none!important}

:is(#article-rich,body) .dha-tool :is(.dha-tool-form,.dha-radio-grid){grid-template-columns:repeat(auto-fit,minmax(min(220px,100%),1fr))}
:is(#article-rich,body) .dha-two-col{grid-template-columns:repeat(auto-fit,minmax(min(280px,100%),1fr))}
:is(#article-rich,body) .dha-tool :is(.dha-subcard,.dha-details,.dha-kpi){min-width:0}
:is(#article-rich,body) .dha-tool :is(.dha-kpi strong,.dha-kpi small,.dha-tool-table th){overflow-wrap:anywhere}
:is(#article-rich,body) .dha-tool :is(.dha-act-btn,.dha-chip-btn,.dha-details summary),
.dha-tool-hub .dha-tool-tab{min-height:44px}
[data-tool-panel][hidden]{display:none!important}
@media print{
  body:has(.dha-tool-printing) :not(.dha-tool-printing,.dha-tool-printing *,:has(.dha-tool-printing)){display:none!important}
  :is(#article-rich,body) .dha-tool-printing{margin:0;padding:12px}
  .dha-tool-printing tr,.dha-tool-printing .dha-kpi{break-inside:avoid}
}

:is(#article-rich,body) .dha-scenarios{background:#f6f8fd;border-color:#d5deee}
:is(#article-rich,body) .dha-scenario-actions{display:flex;flex-wrap:wrap;gap:6px;margin-top:10px}
:is(#article-rich,body) .dha-scenario-actions button:disabled{opacity:.55;cursor:default}
:is(#article-rich,body) .dha-scenario-feedback{color:#18386c;font-size:14px;margin:8px 0}
:is(#article-rich,body) .dha-scenario-feedback:empty{display:none}
:is(#article-rich,body) .dha-scenarios table{min-width:620px}
:is(#article-rich,body) .dha-scenarios table th:first-child{min-width:110px}
:is(#article-rich,body) .dha-scenarios table td{min-width:90px}
:is(#article-rich,body) .dha-scenario-scroll-hint{display:none}
@container (max-width:650px){
  :is(#article-rich,body) .dha-scenario-scroll-hint{display:block}
}
@media print{
  :is(#article-rich,body) .dha-scenarios{display:none!important}
}

/* 8-tab hub grid: 4x2 đều trên desktop, gọn trên mobile */
.dha-tool-hub .dha-tool-tabs{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;margin-bottom:14px}
.dha-tool-hub .dha-tool-tab{padding:10px 12px;border:1px solid #e6cfa4;border-radius:12px;background:#fff;color:#18386c;font:600 13.5px/1.3 inherit;text-align:left;cursor:pointer;transition:all .15s ease}
.dha-tool-hub .dha-tool-tab:hover{background:#fff7e6;border-color:#ffa116}
.dha-tool-hub .dha-tool-tab[aria-selected="true"]{background:#071367;border-color:#071367;color:#fff;box-shadow:0 6px 16px -8px rgba(7,19,103,.45)}
@media (max-width:900px){
  .dha-tool-hub .dha-tool-tabs{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media (max-width:520px){
  .dha-tool-hub .dha-tool-tabs{display:flex;overflow-x:auto;scroll-snap-type:x proximity;padding-bottom:6px;-webkit-overflow-scrolling:touch}
  .dha-tool-hub .dha-tool-tab{flex:0 0 auto;white-space:nowrap;scroll-snap-align:start}
}

/* Điểm Sức khỏe Tài chính & biểu đồ đường */
:is(#article-rich,body) .dha-dot-green{background:#16a34a}
:is(#article-rich,body) .dha-dot-red{background:#dc2626}
:is(#article-rich,body) .dha-dot-blue{background:#2563eb}
:is(#article-rich,body) .dha-score-hero{display:grid;grid-template-columns:190px 1fr;gap:18px;align-items:center;background:#fff;border:1px solid #ebe0ca;border-radius:16px;padding:18px;margin:14px 0}
:is(#article-rich,body) .dha-score-ring{text-align:center}
:is(#article-rich,body) .dha-score-badge{display:inline-block;margin-top:6px;padding:4px 12px;border-radius:999px;font-size:12.5px;font-weight:700;background:#f0fdf4;color:#15803d}
:is(#article-rich,body) .dha-score-badge.is-warn{background:#fffbeb;color:#b45309}
:is(#article-rich,body) .dha-score-badge.is-danger{background:#fef2f2;color:#b42318}
:is(#article-rich,body) .dha-pillar-list{display:grid;gap:10px}
:is(#article-rich,body) .dha-pillar-item{display:grid;gap:4px}
:is(#article-rich,body) .dha-pillar-head{display:flex;justify-content:space-between;gap:8px;font-size:13.5px}
:is(#article-rich,body) .dha-pillar-head b{color:#071367}
:is(#article-rich,body) .dha-action-steps{margin:0;padding-left:20px;display:grid;gap:8px;font-size:14.5px}
@container (max-width:620px){
  :is(#article-rich,body) .dha-score-hero{grid-template-columns:1fr}
}
