/* =============================================================================
   STYLE.CSS — Giao diện chung
   Thiết kế: hiện đại, sạch sẽ, mobile-first, chữ to dễ đọc cho mọi lứa tuổi.
   ============================================================================= */

:root {
  --primary: #1d4ed8;
  --primary-dark: #1e3a8a;
  --primary-700: #1d4ed8;
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --accent: #059669;        /* màu tiền/kết quả tích cực */
  --accent-50: #ecfdf5;
  --danger: #dc2626;        /* màu cho khoản trừ/thuế */
  --danger-50: #fef2f2;
  --warn: #b45309;
  --warn-50: #fffbeb;

  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #5b6b7f;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .06);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, .12);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ----------------------------------------------------------------------------
   HEADER / ĐIỀU HƯỚNG
   ---------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 19px;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #3b82f6);
  color: #fff; font-weight: 800; font-size: 20px;
}
.brand span.dot { color: var(--accent); }

.nav-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary-50);
  color: var(--primary-dark);
  border: 1px solid var(--primary-100);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.nav-links {
  display: none;
  list-style: none;
  margin: 0; padding: 0;
}
.nav-links.open {
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 64px; left: 0; right: 0;
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 8px;
  gap: 2px;
}
.nav-links a {
  display: block;
  padding: 14px 16px;
  border-radius: 10px;
  color: var(--text);
  font-weight: 600;
  font-size: 16px;
}
.nav-links a:hover { background: var(--primary-50); text-decoration: none; }
.nav-links a.active {
  background: var(--primary);
  color: #fff;
}

@media (min-width: 900px) {
  .nav-toggle { display: none; }
  .nav-links {
    display: flex !important;
    flex-direction: row;
    position: static;
    box-shadow: none;
    border: 0;
    padding: 0;
    gap: 4px;
  }
  .nav-links a { padding: 9px 14px; font-size: 15.5px; }
}

/* ----------------------------------------------------------------------------
   HERO
   ---------------------------------------------------------------------------- */
.hero {
  background: linear-gradient(160deg, #1e3a8a 0%, #1d4ed8 55%, #2563eb 100%);
  color: #fff;
  padding: 48px 0 56px;
}
.hero h1 {
  font-size: 30px;
  line-height: 1.25;
  margin: 0 0 12px;
  font-weight: 800;
}
.hero p { font-size: 18px; opacity: .95; margin: 0 auto; max-width: 640px; }
.hero .badge {
  display: inline-block;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
}
@media (min-width: 720px) {
  .hero { padding: 64px 0 72px; }
  .hero h1 { font-size: 42px; }
  .hero.center { text-align: center; }
}

/* ----------------------------------------------------------------------------
   SECTION & PAGE TITLE
   ---------------------------------------------------------------------------- */
.section { padding: 32px 0; }
.page-head { margin: 28px 0 8px; }
.page-head h1 {
  font-size: 26px;
  margin: 0 0 6px;
  font-weight: 800;
  display: flex; align-items: center; gap: 10px;
}
.page-head .ico { font-size: 26px; }
.page-head p { color: var(--muted); margin: 0; font-size: 16.5px; max-width: 720px; }
@media (min-width: 720px) {
  .page-head h1 { font-size: 32px; }
}

.applies-year {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent-50);
  color: #065f46;
  border: 1px solid #a7f3d0;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 14.5px;
  font-weight: 700;
  margin-top: 12px;
}

/* ----------------------------------------------------------------------------
   GRID & CARDS
   ---------------------------------------------------------------------------- */
.grid { display: grid; gap: 18px; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 720px) { .tools-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .tools-grid { grid-template-columns: repeat(3, 1fr); } }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card h2 { font-size: 20px; margin: 0 0 14px; font-weight: 800; }
.card h3 { font-size: 17px; margin: 18px 0 10px; font-weight: 700; }

/* Thẻ công cụ ở trang chủ */
.tool-card {
  display: flex; flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  transition: transform .15s ease, box-shadow .15s ease;
}
.tool-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); text-decoration: none; }
.tool-card .tc-ico {
  width: 56px; height: 56px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-size: 28px;
  margin-bottom: 14px;
  background: var(--primary-50);
}
.tool-card h3 { font-size: 19px; margin: 0 0 6px; color: var(--text); font-weight: 800; }
.tool-card p { margin: 0; color: var(--muted); font-size: 15.5px; flex: 1; }
.tool-card .go {
  margin-top: 16px; font-weight: 700; color: var(--primary);
  display: inline-flex; align-items: center; gap: 6px;
}

/* ----------------------------------------------------------------------------
   FORM
   ---------------------------------------------------------------------------- */
.field { margin-bottom: 18px; }
.field > label {
  display: block;
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 7px;
}
.field .hint { display: block; color: var(--muted); font-weight: 400; font-size: 14px; margin-top: 4px; }

.input-wrap { position: relative; }
.input-wrap .suffix {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-weight: 600; font-size: 16px; pointer-events: none;
}

input[type="text"], input[type="number"], select {
  width: 100%;
  min-height: 54px;
  padding: 12px 16px;
  font-size: 18px;
  font-family: var(--font);
  color: var(--text);
  background: #fff;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input.has-suffix { padding-right: 44px; }
input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .15);
}
select { appearance: none; -webkit-appearance: none; background-image:
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235b6b7f' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center; padding-right: 44px; }

/* Nút số +/- cho người phụ thuộc */
.stepper { display: flex; align-items: stretch; gap: 0; max-width: 220px; }
.stepper button {
  width: 54px; min-height: 54px; font-size: 26px; font-weight: 700;
  background: var(--primary-50); color: var(--primary-dark);
  border: 2px solid var(--border-strong); cursor: pointer;
}
.stepper button:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); border-right: 0; }
.stepper button:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: 0; }
.stepper input { text-align: center; border-radius: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  min-height: 56px;
  padding: 14px 22px;
  font-size: 18px;
  font-weight: 800;
  font-family: var(--font);
  color: #fff;
  background: var(--primary);
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .12s, transform .05s;
}
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: translateY(1px); }
.btn-ghost {
  background: #fff; color: var(--primary); border: 2px solid var(--border-strong);
}
.btn-ghost:hover { background: var(--primary-50); }

/* Thanh chọn (segmented control / tab) */
.segmented {
  display: flex; gap: 6px; background: var(--primary-50);
  padding: 6px; border-radius: 12px; margin-bottom: 22px;
}
.segmented button {
  flex: 1; min-height: 48px; border: 0; background: transparent;
  font-size: 16px; font-weight: 700; color: var(--primary-dark);
  border-radius: 8px; cursor: pointer;
}
.segmented button.active { background: var(--primary); color: #fff; box-shadow: var(--shadow); }

/* ----------------------------------------------------------------------------
   KẾT QUẢ NỔI BẬT
   ---------------------------------------------------------------------------- */
.result-hero {
  background: linear-gradient(160deg, #047857, #059669);
  color: #fff;
  border-radius: var(--radius);
  padding: 26px;
  text-align: center;
  box-shadow: var(--shadow);
}
.result-hero .label { font-size: 16px; opacity: .92; font-weight: 600; }
.result-hero .value { font-size: 38px; font-weight: 800; margin: 6px 0; line-height: 1.1; }
.result-hero.is-tax { background: linear-gradient(160deg, #b91c1c, #dc2626); }
.result-hero.is-blue { background: linear-gradient(160deg, var(--primary-dark), var(--primary)); }
.result-hero .amount-words { margin-top: 8px; font-size: 14.5px; font-style: italic; font-weight: 600; opacity: .92; line-height: 1.4; }
@media (min-width: 720px) { .result-hero .value { font-size: 46px; } }

.stat-row { display: grid; gap: 12px; margin-top: 16px; }
@media (min-width: 560px) { .stat-row.cols-2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 760px) { .stat-row.cols-3 { grid-template-columns: repeat(3, 1fr); } }
.stat {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px;
}
.stat .label { color: var(--muted); font-size: 14.5px; font-weight: 600; }
.stat .value { font-size: 22px; font-weight: 800; margin-top: 4px; }
.stat.green .value { color: var(--accent); }
.stat.red .value { color: var(--danger); }
.stat.blue .value { color: var(--primary); }

/* ----------------------------------------------------------------------------
   BẢNG
   ---------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 15.5px; background: #fff; }
th, td { padding: 12px 14px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
th:first-child, td:first-child { text-align: left; }
thead th { background: var(--primary-50); color: var(--primary-dark); font-weight: 800; position: sticky; top: 0; }
tbody tr:nth-child(even) { background: #f8fafc; }
tbody tr.total-row { background: var(--primary-100); font-weight: 800; }
tfoot td { font-weight: 800; background: var(--primary-100); }
td.pos { color: var(--accent); }
td.neg { color: var(--danger); }

/* ----------------------------------------------------------------------------
   PHẦN TUỲ CHỈNH THAM SỐ (accordion)
   ---------------------------------------------------------------------------- */
details.settings {
  margin-top: 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
}
details.settings > summary {
  cursor: pointer; padding: 14px 16px; font-weight: 700; color: var(--primary-dark);
  list-style: none; display: flex; align-items: center; gap: 8px;
}
details.settings > summary::-webkit-details-marker { display: none; }
details.settings > summary::before { content: "⚙️"; }
details.settings[open] > summary { border-bottom: 1px solid var(--border); }
.settings-body { padding: 16px; }
.settings-grid { display: grid; gap: 14px; }
@media (min-width: 560px) { .settings-grid.cols-2 { grid-template-columns: 1fr 1fr; } }
.settings-grid label { font-size: 14.5px; font-weight: 600; display: block; margin-bottom: 5px; }
.settings-grid input { min-height: 46px; font-size: 16px; }

/* ----------------------------------------------------------------------------
   GHI CHÚ / CẢNH BÁO
   ---------------------------------------------------------------------------- */
.note {
  background: var(--warn-50); border: 1px solid #fcd34d; color: #7c2d12;
  border-radius: var(--radius-sm); padding: 14px 16px; font-size: 15px; margin-top: 16px;
}
.note.info { background: var(--primary-50); border-color: var(--primary-100); color: #1e3a8a; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.hidden { display: none !important; }

/* ----------------------------------------------------------------------------
   KHU VỰC QUẢNG CÁO (placeholder)
   ---------------------------------------------------------------------------- */
.ad-slot {
  margin: 22px auto;
  min-height: 90px;
  display: grid; place-items: center;
  background: repeating-linear-gradient(45deg, #f8fafc, #f8fafc 12px, #eef2f7 12px, #eef2f7 24px);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 14px; font-weight: 600;
  text-align: center;
}

/* ----------------------------------------------------------------------------
   FAQ
   ---------------------------------------------------------------------------- */
.faq details {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: 10px; padding: 0 16px;
}
.faq summary { cursor: pointer; font-weight: 700; padding: 16px 0; font-size: 16.5px; }
.faq details[open] summary { border-bottom: 1px solid var(--border); }
.faq .ans { padding: 12px 0 16px; color: #334155; }

/* ----------------------------------------------------------------------------
   FOOTER
   ---------------------------------------------------------------------------- */
.site-footer {
  margin-top: 48px;
  background: #0f172a;
  color: #cbd5e1;
  padding: 32px 0;
  font-size: 15px;
}
.site-footer a { color: #93c5fd; }
.site-footer .foot-grid { display: grid; gap: 22px; }
@media (min-width: 720px) { .site-footer .foot-grid { grid-template-columns: 2fr 1fr 1fr; } }
.site-footer h4 { color: #fff; margin: 0 0 10px; font-size: 16px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: 7px; }
.site-footer .copyright { margin-top: 24px; padding-top: 18px; border-top: 1px solid #1e293b; color: #94a3b8; font-size: 13.5px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ----------------------------------------------------------------------------
   NÚT IN / LƯU KẾT QUẢ
   ---------------------------------------------------------------------------- */
.result-actions { display: flex; justify-content: flex-end; margin-bottom: 14px; }
.btn-print {
  display: inline-flex; align-items: center; gap: 8px;
  background: #fff; color: var(--primary-dark);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 18px; font-size: 15.5px; font-weight: 700; cursor: pointer;
  font-family: var(--font);
}
.btn-print:hover { background: var(--primary-50); border-color: var(--primary); }

/* Chú thích biểu đồ */
.chart-legend { display: flex; gap: 20px; justify-content: center; margin-top: 12px; font-size: 14.5px; color: var(--muted); font-weight: 600; }
.chart-legend span { display: inline-flex; align-items: center; gap: 7px; }
.chart-legend i { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }

/* ----------------------------------------------------------------------------
   KHI IN (Ctrl+P / Lưu PDF): chỉ giữ nội dung quan trọng, ẩn phần điều hướng
   ---------------------------------------------------------------------------- */
@media print {
  body { background: #fff; font-size: 13px; }
  .site-header, .site-footer, .ad-slot, .faq, .nav-toggle,
  .segmented, details.settings, .btn, .result-actions,
  .applies-year, .page-head p { display: none !important; }

  .container { max-width: 100%; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }

  /* Hiện đầy đủ bảng (bỏ giới hạn cuộn) để in ra hết các dòng */
  .table-wrap { max-height: none !important; overflow: visible !important; border: 0; }
  table { font-size: 12px; }
  thead th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  /* Kết quả nổi bật: nền trắng, chữ đậm để in rõ */
  .result-hero { background: #fff !important; color: #111 !important; border: 2px solid #333; }
  .result-hero .label { color: #333 !important; }
  .result-hero .value { color: #111 !important; }
  .stat { border: 1px solid #ccc; }

  a[href]:after { content: ""; } /* không in URL sau link */
}

/* ===== Box affiliate (liên kết tài trợ) — thẻ tín dụng VPBank ===== */
.aff-box{position:relative;margin:24px 0;padding:20px;border:1px solid var(--border-strong);
  border-radius:var(--radius);background:linear-gradient(135deg,#eef4ff 0%,#ffffff 55%,#ecfdf5 100%);
  box-shadow:var(--shadow);overflow:hidden}
.aff-tag{position:absolute;top:12px;right:12px;font-size:11px;letter-spacing:.04em;
  text-transform:uppercase;color:var(--muted);background:rgba(255,255,255,.72);
  border:1px solid var(--border);border-radius:999px;padding:3px 10px}
.aff-grid{display:flex;gap:22px;align-items:center;flex-wrap:wrap}
.aff-imgs{position:relative;flex:0 0 300px;height:200px}
.aff-imgs img{position:absolute;width:230px;height:auto;border-radius:12px;
  filter:drop-shadow(0 10px 18px rgba(15,23,42,.22))}
.aff-imgs img:nth-child(1){top:26px;left:0;transform:rotate(-8deg);z-index:1}
.aff-imgs img:nth-child(2){top:6px;left:40px;z-index:3}
.aff-imgs img:nth-child(3){top:26px;left:80px;transform:rotate(8deg);z-index:2}
.aff-body{flex:1 1 300px;min-width:260px}
.aff-body h3{margin:0 0 12px;font-size:19px;line-height:1.35;color:var(--primary-dark)}
.aff-feats{list-style:none;margin:0 0 16px;padding:0}
.aff-feats li{position:relative;padding:4px 0 4px 28px;font-size:16px;color:var(--text)}
.aff-feats li::before{content:"\2713";position:absolute;left:0;top:3px;width:20px;height:20px;
  line-height:20px;text-align:center;color:#fff;background:var(--accent);border-radius:50%;
  font-size:13px;font-weight:700}
.aff-btn{display:inline-block;width:100%;box-sizing:border-box;text-align:center;
  background:linear-gradient(135deg,#10b981,#059669);color:#fff;font-weight:800;font-size:18px;
  padding:15px 22px;border-radius:12px;text-decoration:none;
  box-shadow:0 8px 20px rgba(5,150,105,.35);transition:transform .08s ease,box-shadow .2s ease}
.aff-btn:hover{transform:translateY(-1px);box-shadow:0 10px 26px rgba(5,150,105,.45);color:#fff}
.aff-btn:active{transform:translateY(0)}
.aff-note{margin:12px 0 0;font-size:13px;color:var(--muted);line-height:1.5}
@media (max-width:640px){
  .aff-box{padding:16px}
  .aff-grid{gap:6px}
  .aff-imgs{flex-basis:100%;height:168px;margin-bottom:6px}
  .aff-imgs img{width:196px}
  .aff-imgs img:nth-child(1){left:50%;margin-left:-128px}
  .aff-imgs img:nth-child(2){left:50%;margin-left:-98px}
  .aff-imgs img:nth-child(3){left:50%;margin-left:-68px}
  .aff-body h3{font-size:18px}
}

/* ===== Bài viết (SEO) & trang Cẩm nang ===== */
.post-body{max-width:760px}
.post-body h2{font-size:23px;margin:30px 0 10px;color:var(--primary-dark);line-height:1.3}
.post-body h3{font-size:19px;margin:22px 0 8px;color:var(--text)}
.post-body p{font-size:17px;line-height:1.75;margin:0 0 14px;color:#1f2937}
.post-body ul,.post-body ol{font-size:17px;line-height:1.75;padding-left:22px;margin:0 0 16px}
.post-body li{margin:6px 0}
.post-body a{color:var(--primary);font-weight:600}
.post-body strong{color:var(--text)}
.post-body table{width:100%;border-collapse:collapse;margin:16px 0;font-size:16px}
.post-body th,.post-body td{border:1px solid var(--border);padding:9px 12px;text-align:left}
.post-body th{background:var(--primary-50);color:var(--primary-dark)}
.post-body blockquote{margin:16px 0;padding:12px 16px;background:var(--primary-50);border-left:4px solid var(--primary);border-radius:8px;color:#1f2937}
.post-meta{color:var(--muted);font-size:15px;margin:4px 0 0}
.post-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:16px;margin-top:18px}
.post-card{display:block;padding:18px;border:1px solid var(--border);border-radius:var(--radius);background:var(--card);box-shadow:var(--shadow);text-decoration:none;color:inherit;transition:transform .08s ease,box-shadow .2s ease}
.post-card:hover{transform:translateY(-2px);box-shadow:var(--shadow-lg)}
.post-card .tag{display:inline-block;font-size:12px;font-weight:700;color:var(--primary);background:var(--primary-50);border-radius:999px;padding:2px 10px;margin-bottom:8px}
.post-card h3{margin:0 0 6px;color:var(--primary-dark);font-size:18px;line-height:1.35}
.post-card p{margin:0;color:var(--muted);font-size:15px;line-height:1.5}
.post-related{margin-top:24px}
.post-related h2{font-size:20px}

/* Ẩn ô quảng cáo khi CHƯA có mã (AdSense chưa chạy). Vẫn chừa chỗ sẵn trong HTML,
   khi dán mã <ins> vào thì ô không còn rỗng -> tự hiện. */
.ad-slot:empty{display:none !important}
