/* "Phiếu lương" — warm ledger paper, jade ink, marigold stamp, vermilion for deductions. */
:root {
  --paper: #f5efe2;
  --paper-line: rgb(11 79 60 / .06);
  --surface: #fffdf8;
  --ink: #102a22;
  --muted: #5b6b63;
  --line: #e2d9c6;
  --jade: #0b4f3c;
  --jade-2: #12735a;
  --jade-soft: #e3efe8;
  --gold: #f2b134;
  --gold-soft: #fdf0cf;
  --red: #c4472d;
  --warn-bg: #fdecc8;
  --warn: #7a4b00;
  --shadow: 0 1px 0 rgb(16 42 34 / .04), 0 10px 30px -12px rgb(16 42 34 / .18);
  --radius: 16px;
  --font-body: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Bricolage Grotesque", "Be Vietnam Pro", system-ui, sans-serif;
  --font-num: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0d1714;
    --paper-line: rgb(242 177 52 / .04);
    --surface: #14211d;
    --ink: #ecf1ec;
    --muted: #9db0a7;
    --line: #26352f;
    --jade: #5fd0a7;
    --jade-2: #7fe0bd;
    --jade-soft: #15322a;
    --gold: #f5bf4f;
    --gold-soft: #3a2d10;
    --red: #ff8a6e;
    --warn-bg: #3b2a0b;
    --warn: #f8cf7a;
    --shadow: 0 1px 0 rgb(0 0 0 / .3), 0 14px 34px -14px rgb(0 0 0 / .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  /* ledger paper: faint ruled grid */
  background-image:
    linear-gradient(var(--paper-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--paper-line) 1px, transparent 1px);
  background-size: 28px 28px;
  font: 16px/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--jade-2); text-underline-offset: 3px; }
:where(a, button, input, select, summary):focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 32px); }
.nowrap { white-space: nowrap; }

/* ---------- header ---------- */
.site-header { background: var(--jade); color: #f5efe2; border-bottom: 3px solid var(--gold); }
@media (prefers-color-scheme: dark) { .site-header { background: #0a2a20; } }
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 20px; padding-top: 12px; padding-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand span { font: 800 1.25rem/1 var(--font-display); letter-spacing: -.02em; display: flex; align-items: baseline; gap: 8px; }
.brand em { font: 500 .72rem/1 var(--font-num); font-style: normal; color: var(--gold); letter-spacing: .04em; text-transform: uppercase; }
.site-header nav { display: flex; gap: 4px; flex-wrap: wrap; }
.site-header nav a { padding: 6px 12px; border-radius: 999px; text-decoration: none; color: rgb(245 239 226 / .78); font-weight: 500; font-size: .95rem; }
.site-header nav a:hover { color: #fff; background: rgb(255 255 255 / .08); }
.site-header nav a[aria-current="page"] { background: var(--gold); color: #102a22; font-weight: 600; }

/* ---------- type ---------- */
main.wrap { padding-top: clamp(24px, 4vw, 44px); padding-bottom: 56px; }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -.02em; }
h1 { font-weight: 800; font-size: clamp(1.75rem, 1.1rem + 2.6vw, 3rem); line-height: 1.08; margin: 0 0 10px; text-wrap: balance; max-width: 22ch; }
h2 { font-weight: 600; font-size: 1.2rem; margin: 0 0 14px; }
h3 { font-weight: 600; font-size: 1.02rem; margin: 22px 0 8px; }
.lede { color: var(--muted); max-width: 62ch; margin: 0 0 18px; font-size: 1.05rem; }

/* ---------- law strip ---------- */
.law {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px;
  background: var(--gold-soft); border: 1px dashed color-mix(in srgb, var(--gold) 70%, var(--ink) 10%);
  border-radius: 12px; padding: 10px 14px; margin: 0 0 22px; font-size: .92rem;
}
.law strong { font-weight: 600; }
.law-badge {
  font: 600 .7rem/1 var(--font-num); letter-spacing: .08em; text-transform: uppercase;
  color: #102a22; background: var(--gold); padding: 6px 9px; border-radius: 6px;
}
.law a { margin-left: auto; font-weight: 600; white-space: nowrap; }

/* ---------- cards & layout ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(16px, 2.2vw, 22px); margin: 0 0 16px; min-width: 0; box-shadow: var(--shadow); }
.calc { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 900px) {
  .calc { grid-template-columns: minmax(340px, 400px) minmax(0, 1fr); gap: 24px; }
  .calc .form { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
}
@media (min-width: 640px) and (max-width: 899px) {
  .calc .form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .calc .form > .seg, .calc .form > .chips, .calc .form > .field:first-of-type, .calc .form > .row2 { grid-column: 1 / -1; }
  .calc .form > fieldset.field { grid-column: 1; }
}

/* ---------- form ---------- */
.form { display: grid; gap: 16px; margin: 0; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.card { border: 1px solid var(--line); }
legend { font-weight: 600; padding: 0; margin-bottom: 8px; }
.offer legend { font: 800 1.2rem/1.2 var(--font-display); }
.field { display: grid; gap: 6px; }
.field > span { font-weight: 600; font-size: .93rem; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.field small, .ins-box small { color: var(--muted); font-size: .82rem; }
.hint { font-weight: 400; font-size: .82rem; }
input, select {
  font: inherit; color: var(--ink); background: var(--paper);
  border: 1.5px solid var(--line); border-radius: 10px; padding: 0 12px; width: 100%; min-width: 0; height: 44px;
  transition: border-color .15s, background-color .15s;
}
input:hover, select:hover { border-color: color-mix(in srgb, var(--jade) 35%, var(--line)); }
input:focus, select:focus { border-color: var(--jade); background: var(--surface); outline: none; }
#amount { height: 56px; font: 600 1.45rem/1 var(--font-num); letter-spacing: -.01em; }
.row2 { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: end; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--paper); border: 1.5px solid var(--line); border-radius: 12px; padding: 3px; }
.seg label { text-align: center; padding: 9px 6px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--muted); transition: background-color .15s, color .15s; }
.seg input { position: absolute; opacity: 0; pointer-events: none; width: auto; height: auto; }
.seg label:has(input:checked) { background: var(--jade); color: #fffdf8; box-shadow: 0 2px 8px -2px rgb(11 79 60 / .5); }
@media (prefers-color-scheme: dark) { .seg label:has(input:checked) { color: #0d1714; } }
.seg label:has(input:focus-visible) { outline: 2px solid var(--gold); }
.seg3 label { padding: 8px 4px; font-size: .9rem; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: 500 .85rem/1 var(--font-num); cursor: pointer; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); padding: 7px 11px;
  transition: transform .12s, border-color .12s, background-color .12s;
}
.chip:hover { border-color: var(--gold); background: var(--gold-soft); transform: translateY(-1px); }

.stepper { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; height: 44px; border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--paper); }
.stepper input { border: 0; border-radius: 0; height: 41px; text-align: center; font: 600 1.05rem/1 var(--font-num); appearance: textfield; -moz-appearance: textfield; background: transparent; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper button { font: 600 1.25rem/1 var(--font-num); border: 0; background: var(--surface); color: var(--jade); cursor: pointer; }
.stepper button:hover { background: var(--gold-soft); }
.stepper:focus-within { border-color: var(--jade); }

.ins-box { display: grid; gap: 8px; margin-top: 10px; }
#ins-amount-box[hidden], #ins-pct-box[hidden] { display: none; }
.suffix { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; border: 1.5px solid var(--line); border-radius: 10px; background: var(--paper); padding-right: 12px; }
.suffix input { border: 0; background: transparent; font-family: var(--font-num); }
.suffix span { color: var(--muted); font-size: .88rem; white-space: nowrap; }
.suffix:focus-within { border-color: var(--jade); }

.btn {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 14px; cursor: pointer; text-decoration: none;
  font: 600 .95rem/1 var(--font-body); color: #102a22; background: var(--gold);
  border: 0; border-radius: 999px; padding: 11px 18px; box-shadow: 0 3px 0 color-mix(in srgb, var(--gold) 60%, #000);
  transition: transform .12s, box-shadow .12s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 0 color-mix(in srgb, var(--gold) 60%, #000); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 color-mix(in srgb, var(--gold) 60%, #000); }

/* ---------- result: the payslip ---------- */
.headline {
  position: relative; overflow-x: clip; overflow-y: visible;
  background: var(--jade); color: #f5efe2; border: 0;
  padding-right: clamp(96px, 16vw, 150px);
}
@media (prefers-color-scheme: dark) { .headline { background: #0f3a2d; } }
.receipt { margin-bottom: 28px; }
.receipt::after {
  /* torn payslip edge */
  content: ""; position: absolute; left: 0; right: 0; bottom: -11px; height: 12px; background: inherit;
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 18px 100%;
  mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 18px 100%;
}
.headline .kpi { display: grid; gap: 4px; }
.kpi-label { font: 500 .78rem/1.2 var(--font-num); letter-spacing: .1em; text-transform: uppercase; color: rgb(245 239 226 / .72); }
.kpi-value {
  font: 600 clamp(2rem, 1.2rem + 3.4vw, 3.4rem)/1.05 var(--font-num); letter-spacing: -.03em;
  color: var(--gold); font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.kpi-sub { color: rgb(245 239 226 / .85); margin-top: 6px; font-size: .95rem; }
.headline a.btn, .headline .btn { color: #102a22; }
.headline .warn { background: rgb(253 236 200 / .95); color: #7a4b00; }
.stamp {
  position: absolute; top: 16px; right: 16px; width: clamp(74px, 11vw, 104px); aspect-ratio: 1;
  display: grid; place-content: center; text-align: center; border-radius: 50%;
  border: 2px solid var(--gold); outline: 1px solid var(--gold); outline-offset: 3px;
  color: var(--gold); transform: rotate(-12deg); opacity: .9; line-height: 1;
}
.stamp span { font: 600 .62rem/1 var(--font-num); letter-spacing: .2em; text-transform: uppercase; }
.stamp b { font: 800 clamp(1.1rem, .8rem + 1vw, 1.5rem)/1.1 var(--font-display); }
.flash { animation: flash .6s ease-out; }
@keyframes flash { 0% { color: #fff; text-shadow: 0 0 18px rgb(242 177 52 / .9); } 100% { color: var(--gold); text-shadow: none; } }

.warn { background: var(--warn-bg); color: var(--warn); padding: 8px 12px; border-radius: 8px; margin: 10px 0 0; font-size: .92rem; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.breakdown th { text-align: left; font-weight: 400; color: var(--muted); padding: 8px 0; }
.breakdown td { text-align: right; padding: 8px 0; white-space: nowrap; font: 500 .95rem/1.4 var(--font-num); }
.breakdown tr + tr th, .breakdown tr + tr td { border-top: 1px dashed var(--line); }
.breakdown td:where(:not(:empty)) { color: var(--ink); }
.breakdown tr:has(td:first-of-type) td { }
.breakdown tr.strong th, .breakdown tr.strong td { color: var(--ink); font-weight: 600; }
.breakdown tr.total th, .breakdown tr.total td { color: var(--jade); font-weight: 700; font-size: 1.12rem; border-top: 2px solid var(--ink); padding-top: 12px; }
.breakdown tr.total th { font-family: var(--font-display); }
.breakdown tr.note td { text-align: left; white-space: normal; font: .82rem/1.4 var(--font-body); color: var(--muted); padding-top: 0; border-top: 0; }
.breakdown .minus { color: var(--red); }
.grid th, .grid td { padding: 9px 10px; border-bottom: 1px dashed var(--line); text-align: right; }
.grid td { font: 500 .93rem/1.4 var(--font-num); }
.grid th:first-child, .grid td:first-child { text-align: left; font-family: var(--font-body); }
.grid thead th { font: 600 .72rem/1.3 var(--font-num); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border-bottom: 1.5px solid var(--ink); }
.grid tr.muted td { color: var(--muted); opacity: .7; }
.grid tr.total td, .grid tr.total th { font-weight: 700; color: var(--jade); border-bottom: 0; border-top: 2px solid var(--ink); }
.grid tbody tr:hover td { background: var(--gold-soft); }
.scroll { overflow-x: auto; }
.sticky thead th { position: sticky; top: 0; background: var(--surface); }
.legal td { text-align: left !important; vertical-align: top; font-family: var(--font-body) !important; }
.legal td small { color: var(--muted); }

/* ---------- content ---------- */
.prose { max-width: 75ch; margin: 40px 0 0; }
.prose h2 { font-size: clamp(1.3rem, 1.1rem + .8vw, 1.7rem); font-weight: 800; }
.prose li { margin-bottom: 6px; }
.prose li::marker { color: var(--gold); font-weight: 700; }
.faq details { border-bottom: 1px dashed var(--line); padding: 12px 0; }
.faq summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::after { content: "+"; font: 600 1.2rem/1 var(--font-num); color: var(--jade); transition: transform .2s; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq summary::-webkit-details-marker { display: none; }
.faq p { margin: 8px 0 0; color: var(--muted); }
.links { display: flex; flex-wrap: wrap; gap: 8px; }
.links a { padding: 6px 12px; border: 1.5px solid var(--line); border-radius: 999px; text-decoration: none; background: var(--surface); font-size: .9rem; color: var(--ink); transition: border-color .12s, background-color .12s; }
.links a:hover { border-color: var(--gold); background: var(--gold-soft); }
.crumbs { font-size: .88rem; color: var(--muted); margin-bottom: 10px; }
.note { color: var(--muted); }
.offers { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 700px) { .offers { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.offers .card { margin: 0; }
#compare .row2 { margin-top: 16px; }
.verdict { font-size: 1.12rem; margin: 0 0 14px; padding: 12px 14px; background: var(--gold-soft); border-radius: 10px; }

/* ---------- footer ---------- */
.site-footer { border-top: 3px solid var(--gold); background: var(--jade); color: rgb(245 239 226 / .8); font-size: .88rem; padding: 22px 0 34px; }
@media (prefers-color-scheme: dark) { .site-footer { background: #0a2a20; } }
.site-footer a { color: var(--gold); }

/* ---------- motion: one staggered reveal on load ---------- */
@media (prefers-reduced-motion: no-preference) {
  main > *, .calc > *, .result > * { animation: rise .5s cubic-bezier(.2, .7, .2, 1) both; }
  main > :nth-child(2) { animation-delay: .04s; }
  main > :nth-child(3) { animation-delay: .08s; }
  .calc > :nth-child(2) { animation-delay: .1s; }
  .result > :nth-child(2) { animation-delay: .16s; }
  .result > :nth-child(3) { animation-delay: .22s; }
  .result > :nth-child(4) { animation-delay: .28s; }
  .stamp { animation: stamp .45s .35s cubic-bezier(.3, 1.6, .5, 1) both; }
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes stamp { from { opacity: 0; transform: rotate(-30deg) scale(1.6); } to { opacity: .9; transform: rotate(-12deg) scale(1); } }

/* ---------- small screens ---------- */
@media (max-width: 520px) {
  .headline { padding-right: clamp(16px, 2.2vw, 22px); }
  .headline .kpi { padding-right: 70px; }
  .stamp { width: 60px; top: 12px; right: 12px; }
  .stamp span { font-size: .5rem; }
  .stamp b { font-size: 1rem; }
}
@media (max-width: 480px) {
  .site-header nav a { padding: 5px 9px; font-size: .88rem; }
  .grid th, .grid td { padding: 7px 5px; font-size: .86rem; }
  .card { padding: 15px; }
}
@media (max-width: 340px) {
  .row2 { grid-template-columns: minmax(0, 1fr); }
  .seg3 label { font-size: .8rem; }
  .law a { margin-left: 0; }
  .brand em { display: none; }
}
@media (min-width: 1440px) { body { font-size: 17px; } }
