/* tínhnông – giao diện nông nghiệp
   Màu: lá lúa non, lúa chín, phù sa, nước kênh */
:root {
  --field: #EEF2E6;      /* nền: sương ruộng lúa */
  --paper: #FFFFFF;
  --ink: #1E2A1B;        /* mực lá đậm */
  --ink-soft: #55624F;
  --line: #D7DECB;
  --rice: #3C7A22;       /* lúa non */
  --rice-dark: #2C5C17;
  --rice-pale: #DCE9CC;
  --grain: #D6A21E;      /* lúa chín */
  --grain-pale: #FBF1D3;
  --silt: #8C6744;       /* phù sa */
  --canal: #2E6C8A;      /* nước kênh */
  --loss: #B3261E;
  --radius-s: 8px;
  --radius-l: 16px;
  --measure: 68ch;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--field);
  color: var(--ink);
  font-family: "Be Vietnam Pro", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.6;
}
a { color: var(--rice-dark); }
:focus-visible { outline: 3px solid var(--grain); outline-offset: 2px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
[hidden] { display: none !important; }

/* ---------- Header ---------- */
.site-head { background: var(--ink); color: #fff; }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; }
.logo { display: flex; align-items: center; gap: 0; color: #fff; text-decoration: none; font-weight: 800; font-size: 20px; letter-spacing: -0.02em; }
.logo svg { width: 26px; height: 26px; flex: none; margin-right: 8px; }
.logo span { color: var(--grain); }
.site-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.site-nav a { color: #D9E3CF; text-decoration: none; font-size: 15px; padding: 6px 10px; border-radius: 6px; }
.site-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.site-nav a[aria-current="page"] { color: #fff; background: rgba(255,255,255,.12); }
@media (max-width: 640px) { .site-nav a.hide-sm { display: none; } }

/* Dải luống cày dưới header trang công cụ */
.furrow {
  height: 14px;
  background:
    repeating-linear-gradient(115deg, var(--rice) 0 10px, var(--rice-dark) 10px 14px, #4E8E2B 14px 26px, var(--rice-dark) 26px 30px);
}

/* ---------- Home hero ---------- */
.hero { background: var(--ink); color: #fff; overflow: hidden; }
.hero .wrap { display: grid; grid-template-columns: 1fr; gap: 24px; padding-top: 40px; }
@media (min-width: 900px) { .hero .wrap { grid-template-columns: 1.05fr 0.95fr; align-items: end; padding-top: 56px; } }
.hero h1 {
  font-size: clamp(36px, 6vw, 62px);
  line-height: 1.04;
  letter-spacing: -0.035em;
  font-weight: 800;
  margin: 0 0 18px;
  max-width: 14ch;
}
.hero p { color: #CFD9C4; max-width: 46ch; margin: 0 0 32px; font-size: 18px; }
.hero-art { display: block; width: 100%; height: auto; margin-bottom: -2px; }
.hero-stats { display: flex; gap: 28px; flex-wrap: wrap; margin: 0 0 40px; padding: 0; list-style: none; color: #CFD9C4; font-size: 15px; }
.hero-stats b { display: block; color: var(--grain); font-size: 22px; font-weight: 800; }

/* ---------- Page title (tool pages) ---------- */
.page-title { padding: 32px 0 6px; }
.crumb { font-size: 14px; color: var(--ink-soft); margin: 0 0 10px; }
.crumb a { color: var(--ink-soft); }
.page-title h1 {
  font-size: clamp(30px, 4.6vw, 44px);
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-weight: 800;
  margin: 0 0 12px;
  max-width: 22ch;
}
.page-title p { margin: 0; color: var(--ink-soft); max-width: 58ch; }

/* ---------- Tool layout ---------- */
.tool { display: grid; grid-template-columns: 1fr; gap: 20px; margin: 28px 0 40px; }
@media (min-width: 900px) {
  .tool { grid-template-columns: 1.1fr 0.9fr; align-items: start; }
  .tool .result { position: sticky; top: 16px; }
}
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 24px; }
.panel-title { font-size: 18px; font-weight: 700; margin: 0 0 14px; letter-spacing: -0.01em; }

.field { margin-bottom: 22px; }
.field:last-child { margin-bottom: 0; }
.field > label, .field > .label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 8px; }
.hint { font-size: 14px; color: var(--ink-soft); margin: 6px 0 0; }
.error { color: var(--loss); font-size: 14px; margin: 6px 0 0; }
.error:empty { display: none; }

input[type="text"], input[type="number"], select {
  font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--paper); padding: 9px 12px;
}
input[aria-invalid="true"] { border-color: var(--loss); }
.num-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.num-row input { width: 150px; font-size: 20px; font-weight: 700; background: var(--field); font-variant-numeric: tabular-nums; }
.num-row select { font-size: 16px; }
.num-row .unit { color: var(--ink-soft); }

.choices { display: flex; flex-wrap: wrap; gap: 8px; border: 0; padding: 0; margin: 0; }
.choices legend { font-weight: 600; font-size: 15px; margin-bottom: 8px; padding: 0; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice span {
  display: block; padding: 8px 14px; font-size: 15px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 999px; background: var(--paper);
}
.choice input:checked + span { background: var(--rice); border-color: var(--rice); color: #fff; }
.choice input:focus-visible + span { outline: 3px solid var(--grain); outline-offset: 2px; }

.btn {
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
  padding: 9px 14px; border-radius: var(--radius-s);
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--ink); }
.btn-primary { background: var(--rice); border-color: var(--rice); color: #fff; }
.btn-primary:hover { background: var(--rice-dark); border-color: var(--rice-dark); }
.btn-ghost { border-style: dashed; color: var(--rice-dark); font-weight: 500; }
.btn-ghost:hover { border-color: var(--rice); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }

.note-grain { font-size: 14px; background: var(--grain-pale); color: #5E4500; padding: 10px 14px; border-radius: var(--radius-s); margin: 0 0 20px; border-left: 4px solid var(--grain); }

/* ---------- Cost rows ---------- */
.cost-group { border: 0; padding: 0; margin: 0 0 24px; }
.cost-group legend { font-weight: 700; font-size: 16px; padding: 0; margin-bottom: 2px; display: flex; align-items: center; gap: 8px; }
.cost-group legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.cost-group legend small { font-weight: 400; color: var(--ink-soft); font-size: 14px; }
.cost-group .sub { font-size: 13px; color: var(--ink-soft); margin: 0 0 10px; }
.cost-row { display: grid; grid-template-columns: 1fr 150px 38px; gap: 8px; align-items: center; margin-bottom: 8px; }
.cost-row input { width: 100%; font-size: 15px; padding: 8px 10px; }
.cost-row input.amt { text-align: right; background: var(--field); font-weight: 700; font-variant-numeric: tabular-nums; }
.icon-btn { width: 38px; height: 38px; border: 1px solid var(--line); background: var(--paper); border-radius: var(--radius-s); cursor: pointer; color: var(--ink-soft); font-size: 18px; line-height: 1; }
.icon-btn:hover { color: var(--loss); border-color: var(--loss); }
.group-total { font-size: 14px; color: var(--ink-soft); margin: 6px 0 0; text-align: right; }
.group-total b { color: var(--ink); }
@media (max-width: 480px) {
  .cost-row { grid-template-columns: 1.2fr 1fr 38px; gap: 6px; }
  .panel { padding: 18px; }
}

/* ---------- Ledger result ---------- */
.ledger { font-variant-numeric: tabular-nums; }
.verdict { border-radius: 12px; padding: 18px 18px 16px; background: var(--rice-pale); margin-bottom: 16px; }
.verdict.loss { background: #F8DEDA; }
.verdict .k { font-size: 14px; color: var(--ink-soft); font-weight: 600; }
.verdict .v { font-size: clamp(36px, 7vw, 50px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; margin: 4px 0; color: var(--rice-dark); }
.verdict.loss .v { color: var(--loss); }
.verdict .s { font-size: 14px; color: var(--ink-soft); margin: 0; }
.ledger dl { display: grid; grid-template-columns: 1fr auto; margin: 0; }
.ledger dt, .ledger dd { padding: 9px 0; border-bottom: 1px dashed var(--line); margin: 0; font-size: 15px; }
.ledger dt { color: var(--ink-soft); }
.ledger dd { font-weight: 700; text-align: right; }
.ledger dd.key { color: #9A6F00; }
.breakdown { margin-top: 18px; }
.breakdown h3, .sub-h { font-size: 15px; margin: 0 0 10px; }
.bar { height: 16px; display: flex; border-radius: 4px; overflow: hidden; background: var(--field); }
.bar span { display: block; height: 100%; }
.legend-list { list-style: none; padding: 0; margin: 10px 0 0; font-size: 14px; }
.legend-list li { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.legend-list i { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.legend-list b { margin-left: auto; font-variant-numeric: tabular-nums; }

/* ---------- Extra sections on tool pages ---------- */
.section { margin: 0 0 40px; }
.section > h2 { font-size: 24px; letter-spacing: -0.02em; margin: 0 0 6px; }
.section > p.lead { color: var(--ink-soft); margin: 0 0 16px; max-width: var(--measure); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.grid { border-collapse: collapse; width: 100%; font-size: 15px; font-variant-numeric: tabular-nums; }
table.grid th, table.grid td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.grid th { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
table.grid th:first-child, table.grid td:first-child { text-align: left; }
table.grid tr.current td { font-weight: 700; }

table.sens td.cell { font-weight: 600; }
table.sens td.base { outline: 2px solid var(--ink); outline-offset: -2px; }

.saved-empty { color: var(--ink-soft); font-size: 15px; margin: 0; }
.save-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.save-row input { flex: 1; min-width: 200px; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; font-size: 14px; color: var(--rice-dark); text-decoration: underline; cursor: pointer; }
.link-btn.danger { color: var(--loss); }

/* ---------- Conversions ---------- */
.conv-list { list-style: none; margin: 0; padding: 0; }
.conv-list li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 11px 0; border-bottom: 1px dashed var(--line); }
.conv-list .u { color: var(--ink-soft); font-size: 15px; }
.conv-list .u small { display: block; font-size: 12px; }
.conv-list .n { font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; text-align: right; }
.conv-list li.src .n { color: var(--rice-dark); }

/* ---------- Article ---------- */
.article { background: var(--paper); border-top: 1px solid var(--line); padding: 48px 0 56px; }
.article .wrap > * { max-width: var(--measure); }
.article section { margin-bottom: 36px; }
.article h2 { font-size: 22px; letter-spacing: -0.02em; margin: 0 0 10px; }
.article p, .article li { color: #2E3A2A; }
details { border-bottom: 1px solid var(--line); padding: 14px 0; }
details summary { cursor: pointer; font-weight: 600; }
details p { margin: 10px 0 0; }

/* ---------- Home ---------- */
.home-tools { padding: 48px 0 24px; }
.home-tools h2 { font-size: 26px; letter-spacing: -0.02em; margin: 0 0 18px; }
.tools-list { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.tool-card {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-l);
  padding: 22px; text-decoration: none; color: var(--ink); position: relative;
}
.tool-card:hover { border-color: var(--rice); }
.tool-card svg { width: 40px; height: 40px; }
.tool-card h3 { font-size: 20px; margin: 4px 0 0; letter-spacing: -0.01em; }
.tool-card p { margin: 0; color: var(--ink-soft); font-size: 15px; }
.tool-card .go { margin-top: auto; padding-top: 8px; font-weight: 600; color: var(--rice-dark); font-size: 15px; }
.how { padding: 24px 0 56px; }
.how h2 { font-size: 26px; letter-spacing: -0.02em; margin: 0 0 18px; }
.how ol { list-style: none; counter-reset: s; padding: 0; margin: 0; display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.how li { counter-increment: s; padding-top: 14px; border-top: 3px solid var(--grain); }
.how li::before { content: "Bước " counter(s); display: block; font-size: 14px; font-weight: 700; color: #9A6F00; margin-bottom: 4px; }
.how li b { display: block; font-size: 17px; margin-bottom: 2px; }
.how li span { color: var(--ink-soft); font-size: 15px; }

/* ---------- Footer ---------- */
.site-foot { background: var(--ink); color: #B9C5AE; padding: 28px 0 36px; font-size: 14px; }
.site-foot p { margin: 0 0 6px; max-width: var(--measure); }
.site-foot a { color: #DCE6D1; }

/* ---------- Mobile summary bar ---------- */
.mini-sum { display: none; }
@media (max-width: 899px) {
  .mini-sum {
    display: flex; position: sticky; bottom: 0; z-index: 5;
    justify-content: space-between; align-items: center; gap: 12px;
    background: var(--ink); color: #fff; padding: 12px 20px; font-size: 14px;
    text-decoration: none; font-variant-numeric: tabular-nums;
    border-top: 3px solid var(--grain);
  }
  .mini-sum b { font-size: 18px; }
  .mini-sum .neg { color: #FFB4AB; }
}

@media print {
  .site-head, .furrow, .toolbar, .btn-ghost, .icon-btn, .article, .site-foot, .mini-sum, .no-print { display: none !important; }
  body { background: #fff; }
  .tool { display: block; }
  .panel { border: 0; padding: 0; margin-bottom: 16px; }
}
@media (max-width: 640px) {
  .hero-stats { gap: 10px 22px; margin-bottom: 28px; }
  .hero-stats li { flex: 1 1 40%; }
  .hero-stats b { font-size: 17px; }
}

/* =====================================================
   MOBILE – thiết kế ưu tiên điện thoại
   ===================================================== */
html { -webkit-tap-highlight-color: transparent; }
.tabbar { display: none; }

@media (max-width: 899px) {
  :root { --tab-h: 62px; --sum-h: 0px; }
  body { padding-bottom: calc(var(--tab-h) + var(--sum-h) + env(safe-area-inset-bottom)); }
  body.has-sum { --sum-h: 58px; }

  /* Header gọn, menu chuyển xuống thanh tab */
  .site-head .wrap { min-height: 52px; }
  .site-nav { display: none; }
  .furrow { height: 8px; }

  /* Thanh tab dưới đáy */
  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    height: calc(var(--tab-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--paper); border-top: 1px solid var(--line);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    text-decoration: none; color: var(--ink-soft); font-size: 12px; font-weight: 600;
  }
  .tabbar svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
  .tabbar a[aria-current="page"] { color: var(--rice-dark); }
  .tabbar a[aria-current="page"] svg { stroke-width: 2.4; }
  .tabbar a[aria-current="page"]::before { content: ""; position: absolute; top: 0; width: 36px; height: 3px; border-radius: 0 0 3px 3px; background: var(--grain); }
  .tabbar a { position: relative; }

  /* Thanh kết quả nằm ngay trên thanh tab */
  .mini-sum {
    display: flex; position: fixed; left: 0; right: 0; z-index: 19;
    bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
    height: var(--sum-h); padding: 8px 20px; border-top: 3px solid var(--grain);
  }
  .mini-sum b { font-size: 17px; }

  /* Tiêu đề trang */
  .page-title { padding: 20px 0 0; }
  .page-title h1 { font-size: 27px; margin-bottom: 8px; }
  .page-title p { font-size: 16px; }
  .crumb { display: none; }

  /* Trang chủ */
  .hero .wrap { padding-top: 28px; gap: 8px; }
  .hero h1 { font-size: 34px; }
  .hero p { font-size: 16px; margin-bottom: 20px; }
  .hero-art { max-height: 150px; object-fit: cover; }
  .home-tools { padding-top: 28px; }
  .home-tools h2, .how h2 { font-size: 22px; }
  .tool-card { padding: 18px; flex-direction: row; flex-wrap: wrap; align-items: center; column-gap: 14px; }
  .tool-card svg { width: 44px; height: 44px; flex: none; }
  .tool-card h3 { flex: 1; margin: 0; font-size: 18px; }
  .tool-card p, .tool-card .go { flex-basis: 100%; }

  /* Khung công cụ sát mép hơn */
  .wrap { padding: 0 14px; }
  .tool { gap: 14px; margin: 18px 0 28px; }
  .panel { padding: 18px 16px; border-radius: 14px; }
  .section > h2 { font-size: 21px; }
  .section > p.lead { font-size: 15px; }

  /* Ô nhập: tối thiểu 16px để iPhone không tự phóng to, cao 48px dễ bấm */
  input[type="text"], input[type="number"], select { font-size: 16px; min-height: 48px; }
  .num-row input { font-size: 20px; flex: 1 1 140px; max-width: 220px; }
  .num-row select { flex: 1 1 140px; }
  .field { margin-bottom: 20px; }

  /* Lựa chọn dạng nút chia đều chiều ngang */
  .choices { gap: 6px; }
  .choice { flex: 1 1 auto; }
  .choice span { min-height: 46px; display: flex; align-items: center; justify-content: center; text-align: center; padding: 8px 12px; border-radius: 12px; }

  /* Thanh công cụ thành lưới 2 cột */
  .toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .toolbar .btn { justify-content: center; min-height: 44px; font-size: 14px; padding: 8px; }
  .btn { min-height: 46px; }

  /* Dòng chi phí: tên ở trên, số tiền + nút xóa ở dưới */
  .cost-row {
    grid-template-columns: 1fr 48px; grid-template-areas: "name del" "amt del";
    gap: 6px; padding: 10px 0; margin: 0; border-bottom: 1px dashed var(--line);
  }
  .cost-row .name { grid-area: name; border-color: transparent; background: transparent; padding: 0 2px; min-height: 30px; font-weight: 600; }
  .cost-row .name:focus { border-color: var(--line); background: var(--paper); }
  .cost-row .amt { grid-area: amt; font-size: 18px; text-align: left; }
  .cost-row .icon-btn { grid-area: del; width: 48px; height: 48px; align-self: center; }
  .cost-group .btn-ghost { width: 100%; justify-content: center; margin-top: 8px; }
  .group-total { width: 100%; text-align: left; }

  /* Kết quả */
  .verdict .v { font-size: 38px; }
  .ledger dt, .ledger dd { font-size: 15px; padding: 10px 0; }

  /* Bảng rộng: cuộn ngang, cột đầu đứng yên */
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  table.grid { font-size: 14px; }
  table.grid th, table.grid td { padding: 9px 10px; }
  table.grid th:first-child, table.grid td:first-child { position: sticky; left: 0; background: var(--paper); z-index: 1; box-shadow: 1px 0 0 var(--line); }
  .scroll-hint { display: block; font-size: 13px; color: var(--ink-soft); margin: 0 0 8px; }

  /* Vụ đã lưu: chuyển bảng thành thẻ */
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; }
  table.cards thead { display: none; }
  table.cards tr { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 10px; }
  table.cards td { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border: 0; text-align: right; white-space: normal; position: static; box-shadow: none; }
  table.cards td::before { content: attr(data-label); color: var(--ink-soft); font-weight: 400; text-align: left; }
  table.cards td:first-child { font-weight: 700; font-size: 16px; border-bottom: 1px dashed var(--line); padding-bottom: 8px; margin-bottom: 4px; }
  table.cards td:first-child::before { content: none; }
  table.cards td:last-child { justify-content: flex-end; gap: 20px; padding-top: 8px; }
  table.cards td:last-child::before { content: none; }
  table.cards .link-btn { font-size: 15px; min-height: 36px; }

  /* Bài viết */
  .article { padding: 32px 0 36px; }
  .article h2 { font-size: 20px; }
  .article p, .article li { font-size: 16px; }
  details summary { min-height: 44px; display: flex; align-items: center; }

  .site-foot { padding: 22px 0 26px; }
}
.scroll-hint { display: none; }

@media print { .tabbar { display: none !important; } body { padding: 0 !important; } }
@media (max-width: 899px) {
  table.cards td:first-child { position: static; box-shadow: none; background: transparent; }
  table.cards tr { display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; }
  table.cards td:first-child, table.cards td:last-child { grid-column: 1 / -1; }
  table.cards td { flex-direction: column; align-items: flex-start; text-align: left; gap: 0; font-weight: 700; }
  table.cards td::before { font-size: 13px; font-weight: 400; }
  table.cards td:last-child { flex-direction: row; justify-content: flex-end; }
  .hero h1 { font-size: 31px; }
  .hero-stats { margin-bottom: 16px; }
}
@media (max-width: 899px) { .scroll-hint { display: block; } }

/* =====================================================
   GIAO DIỆN DỄ DÙNG CHO BÀ CON
   ===================================================== */
body { font-size: 18px; }
.page-title p, .hero p { font-size: 18px; }
.easy .field > label, .easy .field > .label { font-size: 17px; font-weight: 700; }
.easy .hint { font-size: 15px; }
.easy .choices { margin-top: 10px; }

.btn-grain { background: var(--grain); border-color: var(--grain); color: var(--ink); font-size: 18px; padding: 14px 22px; border-radius: 12px; font-weight: 700; }
.btn-grain:hover { background: #E8B53A; border-color: #E8B53A; }
.btn.wide { width: 100%; justify-content: center; font-size: 17px; padding: 14px; }

.quick { display: flex; gap: 8px; margin-bottom: 18px; }
.quick .btn { flex: 1; justify-content: center; }

.step { display: flex; align-items: center; gap: 10px; font-size: 20px; margin: 26px 0 14px; letter-spacing: -0.01em; }
.step:first-of-type { margin-top: 4px; }
.step > span:first-child {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--rice); color: #fff; font-size: 16px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
}

.item-row { display: grid; grid-template-columns: 1fr minmax(140px, 46%); gap: 10px; align-items: center; padding: 6px 0; }
.item-row .name { font-size: 17px; font-weight: 600; }
.item-row .amt { width: 100%; text-align: right; font-size: 19px; font-weight: 700; background: var(--field); min-height: 50px; font-variant-numeric: tabular-nums; }
.item-row.custom { grid-template-columns: 1fr minmax(120px, 40%) 44px; }
.item-row.custom .name { font-weight: 600; min-height: 50px; }
.item-row .icon-btn { width: 44px; height: 50px; }
.add-item { width: 100%; justify-content: center; margin-top: 8px; min-height: 48px; }

.verdict.canal { background: #DCE6EC; }
.verdict.canal .v { color: var(--canal); }
.easy .verdict .v { font-size: clamp(38px, 8vw, 52px); }
.easy .verdict .s { font-size: 16px; }
.easy.ledger dt, .easy.ledger dd { font-size: 17px; padding: 12px 0; }
.easy.ledger dd.key { font-size: 19px; }
.easy .verdict { margin-top: 0; }
.panel.easy > .verdict { margin: 8px 0 0; }

.crop-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; }
.crop-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; font-size: 18px; }
.crop-top .pos { color: var(--rice-dark); font-weight: 800; }
.crop-top .neg { color: var(--loss); font-weight: 800; }
.crop-sub { margin: 4px 0 10px; color: var(--ink-soft); font-size: 15px; }
.crop-act { display: flex; gap: 8px; }
.crop-act .btn { flex: 1; justify-content: center; }
.btn-del { color: var(--loss); }
.btn-del:hover { border-color: var(--loss); }

.tabs2 { margin: 0 0 20px !important; }
.unit-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.unit-pick .choice span { text-align: center; border-radius: 12px; min-height: 48px; display: flex; align-items: center; justify-content: center; }

.mini-sum span { font-size: 15px; }
.install-tip { margin: 22px 0 0; font-size: 16px; color: var(--ink-soft); background: var(--paper); border: 1px dashed var(--line); border-radius: 12px; padding: 14px 16px; }
.tool-card p { font-size: 16px; }
.home-tools { padding-bottom: 48px; }

@media (max-width: 899px) {
  body { font-size: 17px; }
  .page-title h1 { font-size: 30px; }
  .hero h1 { font-size: 34px; }
  .hero p { font-size: 17px; }
  .step { font-size: 19px; }
  .item-row { grid-template-columns: 1fr 48%; }
  .item-row.custom { grid-template-columns: 1fr 40% 44px; }
  .item-row .name { font-size: 16px; }
  .mini-sum { align-items: center; }
  .mini-sum b { font-size: 20px; }
  .tool-card { flex-wrap: nowrap; }
  .tool-card > div, .tool-card h3 { flex: 1; }
  .tool-card p { flex-basis: 100%; }
  .unit-pick .choice span { font-size: 16px; }
  .crop-act .btn { min-height: 46px; }
}

@media (max-width: 899px) {
  .tool-card { display: grid; grid-template-columns: 48px 1fr; column-gap: 14px; row-gap: 2px; align-items: start; }
  .tool-card svg { grid-row: span 2; }
  .tool-card h3, .tool-card p { flex: none; }
}

/* ---------- Mẹo có link (affiliate) ---------- */
.tip { margin: 14px 0 0; padding: 12px 14px; font-size: 16px; line-height: 1.55; color: var(--ink); background: var(--grain-pale); border-radius: 10px; }
.tip b { color: #7A5600; }
.tip a { color: var(--rice-dark); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.tip-ad { font-size: 13px; color: var(--ink-soft); white-space: nowrap; }
@media print { .tip { display: none !important; } }

/* =====================================================
   CHẤT NÔNG NGHIỆP: chữ bảng hiệu, đồng lúa, khóm lúa
   ===================================================== */
h1, h2, h3, .logo, .step, .aff-title, .verdict .v, .panel-title {
  font-family: "Bitter", "Be Vietnam Pro", Georgia, serif;
}
h1 { letter-spacing: -0.015em !important; }
.verdict .v, .mini-sum b { font-variant-numeric: lining-nums tabular-nums; }

/* Dải đồng lúa đầu mỗi trang công cụ */
.banner {
  position: relative;
  background:
    repeating-linear-gradient(100deg, rgba(255,255,255,.045) 0 2px, transparent 2px 26px),
    var(--rice);
  color: #fff;
  padding-bottom: 30px;
}
.banner::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 22px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='22' viewBox='0 0 44 22'%3E%3Cg fill='%23FBFAF0'%3E%3Cpath d='M9 22C8 15 5 10 1 6c5 3 8 8 9 16z'/%3E%3Cpath d='M10 22c0-8 1-13 4-19-1 6-2 12-2 19z'/%3E%3Cpath d='M11 22c2-6 5-10 10-13-4 4-6 7-8 13z'/%3E%3Cpath d='M30 22c-1-5-3-9-7-12 5 2 8 6 9 12z'/%3E%3Cpath d='M31 22c1-7 3-12 7-17-2 6-4 10-5 17z'/%3E%3Crect y='20' width='44' height='2'/%3E%3C/g%3E%3C/svg%3E") repeat-x bottom left / 44px 22px;
}
.banner .page-title { padding: 30px 0 14px; }
.banner .page-title h1 { color: #fff; }
.banner .page-title p { color: #E3EED6; }
.banner .crumb, .banner .crumb a { color: #CFE2BE; }

/* Khóm lúa chuyển cảnh dưới hero và trên chân trang */
.hero { position: relative; }
.hero::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 22px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='22' viewBox='0 0 44 22'%3E%3Cg fill='%23FBFAF0'%3E%3Cpath d='M9 22C8 15 5 10 1 6c5 3 8 8 9 16z'/%3E%3Cpath d='M10 22c0-8 1-13 4-19-1 6-2 12-2 19z'/%3E%3Cpath d='M11 22c2-6 5-10 10-13-4 4-6 7-8 13z'/%3E%3Cpath d='M30 22c-1-5-3-9-7-12 5 2 8 6 9 12z'/%3E%3Cpath d='M31 22c1-7 3-12 7-17-2 6-4 10-5 17z'/%3E%3Crect y='20' width='44' height='2'/%3E%3C/g%3E%3C/svg%3E") repeat-x bottom left / 44px 22px;
}
.site-foot { position: relative; margin-top: 26px; }
.site-foot::before {
  content: ""; position: absolute; left: 0; right: 0; top: -21px; height: 22px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='22' viewBox='0 0 44 22'%3E%3Cg fill='%23124A16'%3E%3Cpath d='M9 22C8 15 5 10 1 6c5 3 8 8 9 16z'/%3E%3Cpath d='M10 22c0-8 1-13 4-19-1 6-2 12-2 19z'/%3E%3Cpath d='M11 22c2-6 5-10 10-13-4 4-6 7-8 13z'/%3E%3Cpath d='M30 22c-1-5-3-9-7-12 5 2 8 6 9 12z'/%3E%3Cpath d='M31 22c1-7 3-12 7-17-2 6-4 10-5 17z'/%3E%3Crect y='20' width='44' height='2'/%3E%3C/g%3E%3C/svg%3E") repeat-x bottom left / 44px 22px;
}
.article + .site-foot, main + .site-foot { margin-top: 22px; }
.article { padding-bottom: 60px; }

/* Số bước hình lá lúa */
.step > span:first-child { border-radius: 70% 0 70% 0; background: var(--rice); }

/* Khung nhập như thửa ruộng: viền trên màu lúa non */
.panel.easy { border-top: 5px solid var(--rice-pale); }
.result .panel.easy { border-top-color: var(--grain); }

/* Dòng khoản chi có icon */
.item-row .name { display: flex; align-items: center; gap: 10px; }
.item-row .ic {
  flex: none; width: 34px; height: 34px; padding: 6px; border-radius: 10px;
  background: var(--rice-pale); color: var(--rice-dark);
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.item-row:nth-child(2n) .ic { background: var(--grain-pale); color: #8A6200; }

/* Kết quả lời: nền lúa chín nhạt, có bó lúa mờ ở góc */
.verdict { position: relative; overflow: hidden; }
.verdict:not(.loss):not(.canal) { background: #EAF2DC; }
.verdict::after {
  content: ""; position: absolute; right: -6px; bottom: -8px; width: 92px; height: 92px; opacity: .14;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232C5C17' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M12 22V9'/%3E%3Cpath d='M12 9c-1-3 0-5 2-6'/%3E%3Cpath d='M12 12c-2-2-5-2-6 0M12 12c2-2 5-2 6 0M12 16c-2-2-4-2-5 0M12 16c2-2 4-2 5 0'/%3E%3C/svg%3E") no-repeat center / contain;
}
.verdict.loss::after { opacity: .08; filter: grayscale(1); }

/* Thẻ công cụ trang chủ: nhấn viền dưới như bờ ruộng */
.tool-card { border-bottom: 4px solid var(--rice-pale); }
.tool-card:hover { border-color: var(--rice); }

@media (max-width: 899px) {
  .banner { padding-bottom: 26px; }
  .banner .page-title { padding: 20px 0 10px; }
  .site-foot { margin-top: 24px; }
}
@media print { .banner { background: none; color: inherit; } .banner::after, .site-foot::before, .hero::after { display: none; } }
.site-foot, .article + .site-foot, main + .site-foot { margin-top: 0; }
@media (max-width: 899px) { .site-foot { margin-top: 0; } }
main:not(:has(.article)) + * + .site-foot, .home-tools { padding-bottom: 56px; }

/* ---------- Thu gọn phần đầu trang ---------- */
.hero .wrap { padding-top: 26px; gap: 16px; }
@media (min-width: 900px) { .hero .wrap { padding-top: 30px; grid-template-columns: 1.2fr 0.8fr; } }
.hero h1 { font-size: clamp(28px, 4vw, 42px); margin-bottom: 10px; max-width: 18ch; }
.hero p { font-size: 16px; margin-bottom: 18px; }
.hero p[style] { margin: 0 0 26px !important; }
.btn-grain { font-size: 16px; padding: 10px 18px; }
.hero-art { max-height: 170px; width: auto; max-width: 100%; justify-self: end; }
.hero::after, .banner::after { height: 14px; background-size: 30px 14px; }

.banner { padding-bottom: 16px; }
.banner .page-title { padding: 16px 0 8px; }
.banner .page-title h1 { font-size: clamp(24px, 3.2vw, 32px); margin-bottom: 4px; }
.banner .page-title p { font-size: 15px; }

@media (max-width: 899px) {
  .hero .wrap { padding-top: 18px; }
  .hero h1 { font-size: 27px; }
  .hero p { font-size: 15px; }
  .hero-art { max-height: 110px; justify-self: center; }
  .banner { padding-bottom: 14px; }
  .banner .page-title { padding: 14px 0 6px; }
  .banner .page-title h1 { font-size: 24px; }
  .banner .page-title p { font-size: 15px; }
}
@media (max-width: 899px) {
  .hero .wrap { gap: 0; }
  .hero p[style] { margin: 0 0 6px !important; }
  .hero-art { max-height: 84px; }
}

/* ---------- Tối giản phần đầu trang ---------- */
.furrow { display: none; }
.site-head .wrap { min-height: 50px; }
.logo { font-size: 18px; }

.hero .wrap { display: block; padding-top: 16px !important; padding-bottom: 18px; }
.hero-art { display: none; }
.hero h1 { font-size: 24px !important; max-width: none; margin: 0 0 4px; }
.hero p { font-size: 15px !important; margin: 0 0 12px !important; max-width: 60ch; }
.hero p[style] { margin: 0 !important; }
.btn-grain { font-size: 15px; padding: 9px 16px; min-height: 0; border-radius: 10px; }

.banner { padding-bottom: 12px !important; }
.banner .page-title { padding: 12px 0 2px !important; }
.banner .page-title h1 { font-size: 22px !important; margin: 0; }
.banner .page-title p { display: none; }

.home-tools { padding-top: 22px !important; }
.home-tools h2 { font-size: 19px !important; margin-bottom: 12px; }
.tools-list { gap: 10px; }
.tool-card { padding: 14px 16px; gap: 4px; }
.tool-card svg { width: 36px !important; height: 36px !important; }
.tool-card h3 { font-size: 17px; }
.tool-card p { font-size: 15px; }
.install-tip { font-size: 14px; padding: 10px 14px; margin-top: 14px; }

@media (max-width: 899px) {
  .hero h1 { font-size: 22px !important; }
  .tool-card { grid-template-columns: 36px 1fr; column-gap: 12px; }
}

/* ---------- Icon minh họa ---------- */
.item-row .ic, .item-row:nth-child(2n) .ic {
  width: 40px; height: 40px; padding: 3px; border-radius: 11px;
  background: var(--paper); border: 1px solid var(--line);
  fill: none; stroke: none; color: inherit;
}
.tool-card svg { width: 44px !important; height: 44px !important; }
@media (max-width: 899px) { .tool-card { grid-template-columns: 44px 1fr; } }

/* =====================================================
   BỘ NHẬN DIỆN MỚI – tính nông
   Xanh lúa #17661B / #23801F, chuyển màu #17661B → #2C8A22 → #5DA81F,
   xanh non #8CC63F, vàng nắng #F2B714, nền kem #FBFAF0.
   Chữ tiêu đề Baloo 2, chữ thường Be Vietnam Pro.
   ===================================================== */
:root {
  --field: #FBFAF0;
  --ink: #1C3318;
  --ink-soft: #546650;
  --line: #E3E6D3;
  --rice: #23801F;
  --rice-dark: #17661B;
  --rice-pale: #E1F0CF;
  --lime: #8CC63F;
  --grain: #F2B714;
  --grain-pale: #FDF4D2;
  --deep: #124A16;
  --brand-grad: linear-gradient(120deg, #17661B 0%, #2C8A22 55%, #5DA81F 100%);
}
h1, h2, h3, .step, .aff-title, .verdict .v, .panel-title, .mini-sum b {
  font-family: "Baloo 2", "Be Vietnam Pro", system-ui, sans-serif;
  letter-spacing: 0 !important;
}
h1, h2, h3 { line-height: 1.2; }

/* Đầu trang trắng, logo màu */
.site-head { background: #fff; color: var(--ink); box-shadow: 0 1px 0 var(--line), 0 4px 14px rgba(23,102,27,.06); position: relative; z-index: 6; }
.site-head .wrap { min-height: 56px; }
.logo { display: flex; align-items: center; }
.logo img { display: block; height: 36px; width: auto; }
.site-nav a { color: var(--ink-soft); font-weight: 600; }
.site-nav a:hover { background: var(--rice-pale); color: var(--rice-dark); }
.site-nav a[aria-current="page"] { color: var(--rice-dark); background: var(--rice-pale); }

/* Dải xanh đầu trang có luống ruộng lượn sóng */
.hero, .banner {
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(242,183,20,.28), transparent 55%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='60' viewBox='0 0 240 60'%3E%3Cpath d='M0 44 C40 30 80 58 120 44 S200 30 240 44' fill='none' stroke='%23ffffff' stroke-opacity='.09' stroke-width='2'/%3E%3Cpath d='M0 22 C40 8 80 36 120 22 S200 8 240 22' fill='none' stroke='%23ffffff' stroke-opacity='.06' stroke-width='2'/%3E%3C/svg%3E") repeat-x left bottom / 240px 60px,
    var(--brand-grad);
  color: #fff;
}
.hero h1, .banner .page-title h1 { color: #fff; }
.hero p { color: #EAF4DA; }
.btn-grain { background: var(--grain); border-color: var(--grain); color: #2A2200; font-weight: 700; box-shadow: 0 3px 0 #C99300; }
.btn-grain:hover { background: #F7C531; border-color: #F7C531; }

/* Nút, lựa chọn, số bước */
.btn-primary, .choice input:checked + span { background: var(--rice); border-color: var(--rice); }
.btn-primary:hover { background: var(--rice-dark); border-color: var(--rice-dark); }
.step > span:first-child { background: var(--brand-grad); }
.panel { border-color: var(--line); box-shadow: 0 2px 10px rgba(23,102,27,.05); }
.panel.easy { border-top-color: var(--lime); }
.result .panel.easy { border-top-color: var(--grain); }
.num-row input, .item-row .amt, .cost-row input.amt { background: #F4F6EA; }
.verdict:not(.loss):not(.canal) { background: #EAF5DA; }
.tool-card { border-bottom-color: var(--lime); }

/* Thanh kết quả và chân trang màu xanh đậm */
@media (max-width: 899px) {
  .mini-sum { background: var(--deep); border-top-color: var(--grain); }
  .mini-sum b { color: #fff; }
  .mini-sum .neg { color: #FFB4AB; }
  .logo img { height: 32px; }
  .site-head .wrap { min-height: 52px; }
}
.site-foot { background: var(--deep); color: #C9DDBA; }
.site-foot a { color: #fff; }
.banner .page-title h1 { max-width: none; }
