:root {
  --card: #fff;
  --ink: #15182b;
  --muted: #4a5068;
  --accent: #1f6feb;
  --line: #e6e8f0;
  --surface: #f7f8fc;
  --radius-card: 12px;
  --radius-input: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  background: #f4f5fa;
}

/* ── Header / Footer ── */
.site-header,
.site-footer {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 1rem 1.25rem;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.site-footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  flex-direction: column;
  align-items: flex-start;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.5;
  padding-top: 1.25rem;
  padding-bottom: 1.5rem;
}
.brand { font-weight: 800; text-decoration: none; color: var(--ink); }
.brand span { color: var(--accent); }
.site-nav { display: flex; flex-wrap: wrap; gap: .15rem .25rem; }
.site-nav a { display: inline-block; padding: .4rem .55rem; }
.site-nav a,
.site-footer a { margin-right: 1rem; color: var(--muted); text-decoration: none; }
.site-nav a:hover,
.site-footer a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }
/* Visible keyboard focus on every interactive element */
.site-nav a:focus-visible,
.site-footer a:focus-visible,
.article a:focus-visible,
.feedback button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Page shell ── */
.page {
  max-width: 720px;
  margin: 1.75rem auto;
  padding: 0 1.25rem;
}

/* ── Calculator: hero ── */
.hero { margin-bottom: 1.5rem; }
.hero h1 {
  font-size: clamp(1.5rem, 4vw, 1.9rem);
  margin: .2rem 0 .5rem;
  text-wrap: balance;
}
.lede { color: var(--muted); margin: 0; line-height: 1.5; }

/* ── Calculator: form ── */
.calc-form {
  display: grid;
  gap: 1rem;
  background: #fff;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}
.calc-form label { display: grid; gap: .35rem; font-weight: 600; font-size: .95rem; }
.calc-form input {
  padding: .7rem .85rem;
  font-size: 1.05rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-input);
  transition: border-color .15s, box-shadow .15s;
}
.calc-form input:focus {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

/* ── Calculator: result ── */
.result {
  background: #fff;
  margin-top: 1.25rem;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}
.headline {
  display: grid;
  gap: .2rem;
  text-align: center;
  padding: .75rem 0 1.25rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.25rem;
}
.headline-value {
  font-size: clamp(2.4rem, 8vw, 3rem);
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.headline-label,
.headline-sub { color: var(--muted); font-size: .9rem; }
.figures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  margin-bottom: 1.25rem;
}
.figures div {
  background: var(--surface);
  border-radius: var(--radius-input);
  padding: .85rem;
  display: grid;
  gap: .25rem;
}
.figures span { font-size: .875rem; color: var(--muted); }
.figures strong { font-size: 1.1rem; font-variant-numeric: tabular-nums; }

/* ── Comparison table ── */
.compare {
  width: 100%;
  border-collapse: collapse;
  font-size: .95rem;
}
.compare caption {
  text-align: left;
  font-weight: 600;
  font-size: .85rem;
  color: var(--muted);
  margin-bottom: .5rem;
  caption-side: top;
  padding: 0 0 .4rem;
}
.compare th,
.compare td {
  text-align: left;
  padding: .6rem .65rem;
  border-bottom: 1px solid var(--line);
}
.compare td:last-child,
.compare th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.compare thead th { font-size: .85rem; color: var(--muted); font-weight: 600; }
.compare .total { font-weight: 700; }
.compare .total td { background: var(--surface); border-top: 2px solid var(--line); border-bottom-color: transparent; }
.proof { color: #0a7d33; font-weight: 600; margin-top: 1rem; font-size: .9rem; }
.hint { color: #b00020; margin-top: .75rem; }

/* ── "Cách tính" section ── */
.how {
  background: #fff;
  margin-top: 1.25rem;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}
.how h2 { margin: 0 0 .6rem; font-size: 1.05rem; }
.how p { margin: 0; color: var(--muted); font-size: .95rem; line-height: 1.6; }
.how code {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: .1em .35em;
  font-size: .9em;
}

/* ── Ad slot ── */
.ad-slot {
  display: block;
  margin: 1.5rem 0;
}
/* Collapse the slot until a real ad fills it (avoids an empty gap before
   AdSense is approved, and when a unit is returned unfilled). */
.ad-slot:empty,
.ad-slot[data-ad-status="unfilled"] {
  display: none !important;
  margin: 0;
}

/* ── Article pages ── */
.article h1 {
  font-size: clamp(1.55rem, 4vw, 2rem);
  margin: 0 0 .6rem;
  text-wrap: balance;
  line-height: 1.2;
}
.article .lede {
  font-size: 1.05rem;
  line-height: 1.65;
  margin-bottom: 1.75rem;
}
.article section { margin-bottom: 2rem; }
.article h2 {
  font-size: 1.2rem;
  margin: 0 0 .75rem;
  text-wrap: balance;
}
.article p { line-height: 1.75; margin: 0 0 1rem; }
.article p:last-child { margin-bottom: 0; }
.article pre {
  background: #f7f8fc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .85rem 1rem;
  overflow-x: auto;
  font-size: .9rem;
  line-height: 1.5;
  margin: .75rem 0 1rem;
}
.article code { font-family: "Courier New", Courier, monospace; font-size: .9em; }
.article a { color: var(--accent); text-underline-offset: 3px; }
.article a:hover { text-decoration: none; }

/* FAQ dl */
.faq { margin: 0; }
.faq dt {
  font-weight: 700;
  margin-top: 1.1rem;
  line-height: 1.4;
}
.faq dt:first-child { margin-top: 0; }
.faq dd {
  margin: .35rem 0 0 0;
  color: var(--muted);
  line-height: 1.7;
}

/* Article tables */
.article table {
  width: 100%;
  border-collapse: collapse;
  font-size: .95rem;
  margin: 1rem 0;
}
.article table th,
.article table td {
  text-align: left;
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--line);
  line-height: 1.4;
}
.article table th { font-weight: 700; font-size: .875rem; color: var(--muted); }
.article table td:last-child,
.article table th:last-child { text-align: right; }

/* Article lists */
.article ul,
.article ol {
  padding-left: 1.4rem;
  margin: .5rem 0 1rem;
  line-height: 1.75;
}
.article li { margin-bottom: .3rem; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .site-header { flex-wrap: nowrap; gap: .5rem; }
  .site-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .site-nav::-webkit-scrollbar { display: none; }
}
@media (max-width: 480px) {
  .figures { grid-template-columns: 1fr; }
  .headline-value { font-size: 2.2rem; }
  .page { padding: 0 1rem; }
  .calc-form,
  .result,
  .how,
  .feedback { padding: 1.1rem 1rem; }
}

/* Feedback section */
.feedback { background:#fff; margin-top:1.25rem; padding:1.25rem; border:1px solid var(--line); border-radius:var(--radius-card); }
.feedback h2 { margin:0 0 .6rem; font-size:1.05rem; }
.feedback p { color:var(--muted); }
.feedback form { display:grid; gap:.6rem; }
.feedback textarea { width:100%; padding:.7rem .8rem; font:inherit; border:1px solid var(--line); border-radius:var(--radius-input); resize:vertical; }
.feedback textarea:focus { outline:3px solid var(--accent); outline-offset:2px; border-color:var(--accent); }
.feedback button { justify-self:start; padding:.7rem 1.2rem; font-weight:600; color:#fff; background:var(--accent); border:0; border-radius:var(--radius-input); cursor:pointer; }
.feedback button:disabled { opacity:.6; cursor:progress; }
.feedback .hp { position:absolute; left:-9999px; width:1px; height:1px; overflow:hidden; }
.feedback-status { margin:.1rem 0 0; font-weight:600; min-height:1.2em; }
.feedback-status.is-success { color:#0a7d33; }
.feedback-status.is-error { color:#b00020; }

/* Knowledge hub list */
.hub-list { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: 1rem; }
.hub-list li { border: 1px solid var(--line); border-radius: var(--radius-card); padding: 1rem 1.2rem; background: #fff; }
.hub-list a { font-size: 1.12rem; font-weight: 700; color: var(--accent); text-decoration: none; }
.hub-list a:hover { text-decoration: underline; }
.hub-list p { margin: .35rem 0 0; color: var(--muted); font-size: .95rem; line-height: 1.5; }
