/* ===== Clean readable design – Tính thuế TNCN ===== */
:root {
  --bg: #f5f7fa;
  --bg-card: #ffffff;
  --bg-soft: #eef2f7;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #dbeafe;
  --green: #059669;
  --green-soft: #d1fae5;
  --red: #dc2626;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

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

/* Header */
.header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}

.nav-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.02em;
}

.logo span { color: var(--green); }

.nav-menu {
  display: flex;
  list-style: none;
  gap: 0.25rem;
  align-items: center;
}

.nav-menu a {
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 500;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  transition: all .15s;
}

.nav-menu a:hover,
.nav-menu a.active {
  color: var(--primary);
  background: var(--primary-soft);
  text-decoration: none;
}

.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1.3rem;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  color: var(--text);
}

/* Hero */
.hero {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  padding: 2.5rem 1rem;
  text-align: center;
}

.hero h1 {
  font-size: 1.75rem;
  margin-bottom: 0.6rem;
  font-weight: 700;
}

.hero p {
  font-size: 1.05rem;
  opacity: .92;
  max-width: 580px;
  margin: 0 auto;
}

/* Container */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Calculator */
.calculator-section {
  margin: -1.75rem auto 1.25rem;
  max-width: 880px;
  position: relative;
  z-index: 10;
}

.calc-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
  border: 1px solid var(--border);
}

.calc-card h2 {
  text-align: center;
  margin-bottom: 1.25rem;
  font-size: 1.2rem;
  color: var(--text);
}

/* Mode toggle */
.mode-toggle {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  background: var(--bg-soft);
  padding: 0.35rem;
  border-radius: 10px;
}

.mode-toggle label {
  flex: 1;
  text-align: center;
  padding: 0.65rem 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: all .15s;
  border: 2px solid transparent;
}

.mode-toggle input { display: none; }

.mode-toggle input:checked + span,
.mode-toggle label:has(input:checked) {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  border-color: var(--primary-soft);
}

.mode-toggle label span { display: block; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.1rem;
  margin-bottom: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
}

.form-group input,
.form-group select {
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.4rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  width: 100%;
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--border); text-decoration: none; }

/* Results */
.results {
  display: none;
  margin-top: 1.5rem;
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}

.results.show { display: block; }

.result-highlight {
  background: linear-gradient(135deg, #059669, #047857);
  color: #fff;
  border-radius: var(--radius);
  padding: 1.4rem;
  text-align: center;
  margin-bottom: 1.25rem;
}

.result-highlight .label {
  font-size: 0.9rem;
  opacity: .9;
  font-weight: 500;
}

.result-highlight .amount {
  font-size: 1.85rem;
  font-weight: 700;
  margin: 0.4rem 0;
  letter-spacing: -0.02em;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.result-item {
  background: var(--bg-soft);
  padding: 0.9rem 1rem;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.result-item .label {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.result-item .value {
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--text);
  white-space: nowrap;
}

.result-item.negative .value { color: var(--red); }

.breakdown { margin-top: 1.5rem; }

.breakdown h3 {
  margin-bottom: 0.75rem;
  font-size: 1rem;
  color: var(--text);
}

.breakdown table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.breakdown th,
.breakdown td {
  padding: 0.65rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.breakdown th {
  background: var(--bg-soft);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.breakdown .total-row td {
  background: var(--primary-soft);
  font-weight: 600;
  color: var(--primary-dark);
}

.disclaimer {
  margin-top: 1.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: #fff7ed;
  border-left: 4px solid #f59e0b;
  padding: 0.85rem 1rem;
  border-radius: 0 8px 8px 0;
  line-height: 1.55;
}

/* Sections */
.section { padding: 1.5rem 0; }

.section-title {
  text-align: center;
  margin-bottom: 1.25rem;
  font-size: 1.4rem;
  color: var(--text);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.35rem;
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
  transition: transform .15s, box-shadow .15s;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.card h3 {
  margin-bottom: 0.5rem;
  font-size: 1.05rem;
  color: var(--text);
}

.card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.card .meta { font-size: 0.8rem; color: var(--text-muted); }

.card ul {
  margin-left: 1.2rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.card li { margin-bottom: 0.3rem; }

/* Blog */
.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

.blog-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
  transition: transform .15s, box-shadow .15s;
}

.blog-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.blog-card .img-placeholder {
  height: 110px;
  background: linear-gradient(135deg, #dbeafe, #d1fae5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.blog-card .content { padding: 1.15rem; }

.blog-card h3 {
  font-size: 1rem;
  margin-bottom: 0.4rem;
  line-height: 1.4;
}

.blog-card h3 a { color: var(--text); }
.blog-card h3 a:hover { color: var(--primary); }

.blog-card p {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 0.5rem;
}

/* Article / Page */
.article,
.page-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.75rem;
  max-width: 800px;
  margin: 1.25rem auto;
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}

.article h1,
.page-content h1 {
  font-size: 1.55rem;
  margin-bottom: 0.6rem;
  line-height: 1.35;
  color: var(--text);
}

.article .meta {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 1.4rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.article h2,
.page-content h2 {
  font-size: 1.2rem;
  margin: 1.5rem 0 0.6rem;
  color: var(--text);
}

.article h3,
.page-content h3 {
  font-size: 1.05rem;
  margin: 1.15rem 0 0.4rem;
  color: var(--text);
}

.article p,
.page-content p { margin-bottom: 0.9rem; }

.article ul,
.article ol,
.page-content ul {
  margin: 0 0 1rem 1.4rem;
}

.article li,
.page-content li { margin-bottom: 0.35rem; }

.article table,
.page-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.4rem;
  font-size: 0.9rem;
}

.article th,
.article td,
.page-content th,
.page-content td {
  padding: 0.65rem;
  border: 1px solid var(--border);
  text-align: left;
}

.article th,
.page-content th {
  background: var(--bg-soft);
  font-weight: 600;
}

.article .note,
.page-content .note {
  background: #fff7ed;
  border-left: 4px solid #f59e0b;
  padding: 1rem;
  margin: 1.15rem 0;
  border-radius: 0 8px 8px 0;
}

.article .tip,
.page-content .tip {
  background: var(--green-soft);
  border-left: 4px solid var(--green);
  padding: 1rem;
  margin: 1.15rem 0;
  border-radius: 0 8px 8px 0;
}

/* Footer */
.footer {
  background: #1e293b;
  color: #94a3b8;
  padding: 2rem 1rem 1.25rem;
  margin-top: 1.5rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 1.75rem;
  max-width: 1100px;
  margin: 0 auto 1.75rem;
}

.footer h4 {
  color: #f1f5f9;
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}

.footer ul { list-style: none; }
.footer li { margin-bottom: 0.4rem; }

.footer a {
  color: #94a3b8;
  font-size: 0.88rem;
}

.footer a:hover { color: #fff; }

.footer-bottom {
  text-align: center;
  padding-top: 1.25rem;
  border-top: 1px solid #334155;
  font-size: 0.8rem;
  max-width: 1100px;
  margin: 0 auto;
}

/* ========== AdSense – compact, collapse when empty ========== */
.ad-slot {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0.75rem auto;
  padding: 0;
  text-align: center;
  overflow: hidden;
  clear: both;
  line-height: 0;
  min-height: 0;           /* không giữ chỗ trống */
  background: transparent;
  border: none;
}

/* Chỉ hiện chiều cao khi ad đã render (có iframe bên trong) */
.ad-slot:has(iframe) {
  min-height: 90px;
  margin: 1rem auto;
}

.ad-slot ins.adsbygoogle {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 auto;
}

/* Ẩn hoàn toàn khi ad không fill (status unfilled) */
.ad-slot:has(ins.adsbygoogle[data-ad-status="unfilled"]),
.ad-slot:has(ins.adsbygoogle[data-ad-status="unfilled"]) + * {
  /* slot unfilled -> collapse */
}
.ad-slot:has(ins.adsbygoogle[data-ad-status="unfilled"]) {
  display: none !important;
  margin: 0 !important;
  min-height: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
}

.ad-slot-top { margin-top: 0.5rem; margin-bottom: 0.75rem; }
.ad-slot-mid { margin: 0.75rem auto; }
.ad-slot-bottom { margin-top: 0.75rem; margin-bottom: 0.5rem; }

@media (max-width: 768px) {
  .ad-slot:has(iframe) {
    margin-left: -0.5rem;
    margin-right: -0.5rem;
    width: calc(100% + 1rem);
    max-width: calc(100% + 1rem);
    min-height: 60px;
  }
  .article .ad-slot:has(iframe) {
    margin-left: 0;
    margin-right: 0;
    width: 100%;
    max-width: 100%;
  }
}

@media (min-width: 769px) {
  .ad-slot:has(iframe) {
    max-width: 728px;
  }
  .ad-slot-wide:has(iframe) {
    max-width: 970px;
  }
}

.text-center { text-align: center; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }

code {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.9em;
  color: var(--primary-dark);
}

@media (max-width: 768px) {
  .menu-toggle { display: block; }

  .nav-menu {
    display: none;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: #fff;
    flex-direction: column;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    gap: 0.25rem;
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
  }

  .nav-menu.open { display: flex; }

  .form-grid,
  .result-grid { grid-template-columns: 1fr; }

  .footer-grid { grid-template-columns: 1fr; }

  .hero h1 { font-size: 1.35rem; }
  .result-highlight .amount { font-size: 1.4rem; }

  .article,
  .page-content { padding: 1.15rem; }

  .mode-toggle label { font-size: 0.82rem; padding: 0.55rem 0.3rem; }
}
