/* Màu theo logo AIURIS Law Firm: đen than #231F20, vàng đồng #B8A574 */
:root {
  --den-logo: #231f20;
  --vang-logo: #b8a574;
  --nen: #f7f5f0;
  --the: #ffffff;
  --chu: #231f20;
  --phu: #6b6460;
  --vien: #e6e0d3;
  --chinh: #231f20;          /* nút chính */
  --chinh-dam: #000000;
  --tren-chinh: #ffffff;     /* chữ trên nút chính */
  --nhan: #7a6a3e;           /* vàng đậm cho chữ, liên kết (đủ tương phản trên nền trắng) */
  --chinh-nhat: #f3eee2;     /* nền vàng nhạt */
  --do: #b3261e;
  --do-nhat: #fdecea;
  --vang-nhat: #fbf3dc;
  --vang: #7a5a00;
  --bong: 0 1px 2px rgba(35, 31, 32, .06), 0 2px 8px rgba(35, 31, 32, .05);
  --bo: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --nen: #141213; --the: #1f1c1d; --chu: #efe9dd; --phu: #a89f95; --vien: #3a3433;
    --chinh: #c9b688; --chinh-dam: #d9c89c; --tren-chinh: #1a1718; --nhan: #d4c294; --chinh-nhat: #2c2720;
    --do: #ff8a80; --do-nhat: #3a1c1a; --vang-nhat: #352d1a; --vang: #e8cf8a;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--nen); color: var(--chu);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 1.4rem; margin: 0 0 .5rem; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }

/* Thanh đầu giữ nền trắng ở cả chế độ tối để logo hiển thị đúng màu */
.thanh-tren {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 16px; background: #fff; color: var(--den-logo); border-bottom: 3px solid var(--vang-logo);
}
.tieu-de { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { height: 40px; width: auto; flex: none; }
.chu-tieu-de { border-left: 1px solid var(--vang-logo); padding-left: 12px; min-width: 0; }
.ten-app { font-weight: 700; font-size: .95rem; }
.ten-ho { font-size: .8rem; color: #6b6460; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.chon-nam { font-size: .85rem; display: flex; align-items: center; gap: 6px; color: #6b6460; }
.chon-nam select { background: #fff; color: var(--den-logo); border: 1px solid var(--vang-logo); border-radius: 8px; padding: 4px 6px; }
.goc-phai { display: flex; align-items: center; gap: 8px; flex: none; }
.nut-dong-bo {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--vang-logo); background: #fff; color: var(--den-logo);
  border-radius: 99px; padding: 4px 10px; font-size: .8rem; cursor: pointer; min-height: 32px; white-space: nowrap;
}
.nut-dong-bo.xong span:first-child { color: #2e7d32; font-weight: 700; }
.nut-dong-bo.loi, .nut-dong-bo.can-dang-nhap { background: #fbf3dc; border-color: #c9a53c; }
.nut-dong-bo.loi span:first-child { color: #b3261e; font-weight: 700; }
.nut-dong-bo.dang span:first-child { display: inline-block; animation: xoay 1s linear infinite; }
@keyframes xoay { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .nut-dong-bo.dang span:first-child { animation: none; } }
.nut-google { display: flex; align-items: center; justify-content: center; gap: 10px; }
.nut-google .g { font-weight: 700; color: #4285f4; font-family: Arial, sans-serif; font-size: 1.1rem; }
.tac-gia { text-align: center; font-size: .78rem; color: var(--phu); margin: 4px 16px 16px; letter-spacing: .01em; }
.tac-gia::before { content: "✦ "; color: var(--vang-logo); }
.tac-gia a { color: inherit; }
.logo-the { display: block; height: 48px; width: auto; margin: 4px 0 8px; background: #fff; padding: 6px 10px; border-radius: 8px; }

main { max-width: 760px; margin: 0 auto; padding: 12px 16px; outline: none; }
.the { background: var(--the); border-radius: var(--bo); box-shadow: var(--bong); padding: 16px; margin-bottom: 12px; }
.chao { text-align: left; }
.ds-dau { padding-left: 1.2rem; }
.nho { font-size: .85rem; color: var(--phu); }
.mo { color: var(--phu); font-style: italic; }
.so-lon { font-size: 1.8rem; font-weight: 700; letter-spacing: -.02em; }

.thanh-duoi {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--the); border-top: 1px solid var(--vien); padding-bottom: env(safe-area-inset-bottom);
}
.thanh-duoi button {
  border: 0; background: none; padding: 8px 4px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: .78rem; color: var(--phu); cursor: pointer; min-height: 60px;
}
.thanh-duoi button span { font-size: 1.35rem; }
.thanh-duoi button.dang-chon { color: var(--chu); font-weight: 700; box-shadow: inset 0 3px 0 var(--vang-logo); }

.nut {
  border: 1px solid var(--vien); background: var(--the); border-radius: 10px; padding: 10px 16px; cursor: pointer;
  min-height: 44px; font-weight: 600;
}
.nut:hover { border-color: var(--vang-logo); }
.nut.chinh { background: var(--chinh); border-color: var(--chinh); color: var(--tren-chinh); }
.nut.chinh:hover { background: var(--chinh-dam); border-color: var(--chinh-dam); }
.nut.to { width: 100%; padding: 14px; font-size: 1.05rem; margin: 8px 0; }
.nut.nguy { color: var(--do); border-color: var(--do); background: transparent; }
.nut-chu { background: none; border: 0; color: var(--nhan); text-decoration: underline; cursor: pointer; padding: 4px; font-weight: 600; }
.nut-chu.do { color: var(--do); }
.nut-nhanh { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.nut-nhanh .nut { flex: 1 1 160px; }

.luoi-nut { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-bottom: 12px; }
.nut-o {
  text-align: left; background: var(--the); border: 1px solid var(--vien); border-radius: var(--bo); padding: 14px;
  display: flex; flex-direction: column; gap: 2px; cursor: pointer; box-shadow: var(--bong); min-height: 92px;
}
.nut-o:hover { border-color: var(--vang-logo); }
.nut-o .bieu { font-size: 1.5rem; }

.thanh-tien-do { height: 10px; background: var(--chinh-nhat); border-radius: 99px; overflow: hidden; margin: 8px 0 4px; }
.thanh-tien-do span { display: block; height: 100%; background: var(--vang-logo); border-radius: 99px; }
.thanh-tien-do span.vuot { background: var(--den-logo); }
@media (prefers-color-scheme: dark) { .thanh-tien-do span.vuot { background: #efe9dd; } }

.bang-gon { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.bang-gon th, .bang-gon td { padding: 6px 4px; text-align: right; border-bottom: 1px solid var(--vien); }
.bang-gon th:first-child, .bang-gon td:first-child { text-align: left; }
.bang-gon th { font-size: .8rem; color: var(--phu); font-weight: 600; }
.bang-gon tr.tong td { font-weight: 700; border-bottom: 0; }
details { margin-top: 8px; }
/* công thức tính thuế từng bước */
.cong-thuc, .giai-thich { border-top: 1px solid var(--vien); padding-top: 8px; margin-top: 12px; }
.buoc-tinh { margin: 8px 0 0; padding: 0; list-style: none; counter-reset: buoc; }
.buoc-tinh > li { position: relative; padding: 0 0 12px 34px; margin-bottom: 12px; border-bottom: 1px dashed var(--vien); counter-increment: buoc; }
.buoc-tinh > li:last-child { border-bottom: 0; margin-bottom: 0; }
.buoc-tinh > li::before {
  content: counter(buoc); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%;
  background: var(--vang-logo); color: #231f20; font-weight: 700; font-size: .85rem; display: flex; align-items: center; justify-content: center;
}
.buoc-tinh h3 { font-size: .95rem; margin: 2px 0 6px; line-height: 1.35; }
.ct-dong { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: .9rem; font-variant-numeric: tabular-nums; }
.ct-dong span { color: var(--phu); min-width: 0; overflow-wrap: anywhere; }
.ct-dong b { white-space: nowrap; font-weight: 600; }
.ct-dong.cong { border-top: 1px solid var(--vien); margin-top: 2px; padding-top: 5px; }
.ct-dong.cong span { color: var(--chu); font-weight: 600; }
.ct-dong.cong b { font-weight: 700; }
.ket-luan { margin: 6px 0 0; padding: 6px 10px; border-radius: 8px; background: var(--chinh-nhat); font-size: .9rem; }
.giai-thich ul { padding-left: 1.1rem; margin: 8px 0 0; }
.giai-thich li { margin-bottom: 8px; line-height: 1.55; }
summary { cursor: pointer; color: var(--nhan); font-weight: 600; }
.the h2 { border-left: 3px solid var(--vang-logo); padding-left: 8px; }

.ds-tien, .ds-han, .ds-ghi, .ds-sua { list-style: none; margin: 0; padding: 0; }
.ds-tien li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--vien); font-variant-numeric: tabular-nums; }
.ds-tien li:last-child { border-bottom: 0; }
.ds-han li { padding: 6px 0; border-bottom: 1px solid var(--vien); }
.ds-han li:last-child { border-bottom: 0; }
.ds-sua li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--vien); }
.ds-sua li span { flex: 1; display: flex; flex-direction: column; }
.ds-sua li small { color: var(--phu); }
.ds-sua + .nut { margin-top: 8px; }

.canh-bao { padding: 10px 12px; border-radius: 10px; margin: 6px 0; font-size: .92rem; }
.canh-bao.cao { background: var(--do-nhat); color: var(--do); }
.canh-bao.vua { background: var(--vang-nhat); color: var(--vang); }
.canh-bao.thap { background: var(--chinh-nhat); color: var(--chu); }
.nhac { background: var(--vang-nhat); }

.dong-loc { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.dong-loc h2 { margin: 0; }
.dong-loc select, .luoi-chon select { padding: 8px; border-radius: 8px; border: 1px solid var(--vien); background: var(--the); }
.ds-ghi li { border-bottom: 1px solid var(--vien); }
.ds-ghi li:last-child { border-bottom: 0; }
.dong-ghi { width: 100%; display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 10px 0; text-align: left; cursor: pointer; }
.dong-ghi .giua { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.dong-ghi .giua b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dong-ghi .tien { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--chu); }
.dong-ghi .tien.am { color: var(--phu); }
.nhan { font-size: .72rem; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: var(--chinh-nhat); color: var(--nhan); white-space: nowrap; }
.nhan.chi, .nhan.giamtru { background: var(--vang-nhat); color: var(--vang); }
.nhan.tien, .nhan.xuatkho { background: var(--nen); color: var(--phu); }

/* biểu mẫu */
dialog {
  border: 0; padding: 0; border-radius: 16px; width: min(560px, calc(100vw - 16px)); max-height: calc(100dvh - 32px);
  background: var(--the); color: var(--chu); box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog form { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
.hop-dau { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--vien); }
.hop-dau h2 { margin: 0; }
.nut-dong { border: 0; background: none; font-size: 1.2rem; cursor: pointer; padding: 6px 10px; }
.hop-than { padding: 12px 16px; overflow-y: auto; }
.hop-chan { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--vien); align-items: center; }
.hop-chan .gian { flex: 1; }
.loi-form { color: var(--do); font-weight: 600; margin: 4px 0 0; min-height: 1em; }

.truong { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.truong > span { font-weight: 600; font-size: .92rem; }
.truong small { color: var(--phu); font-size: .8rem; }
.truong input, .truong select, .dong-hang input, .dong-hang select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--vien); border-radius: 10px; background: var(--the); min-height: 44px;
}
.truong input:focus, .truong select:focus { outline: 2px solid var(--vang-logo); outline-offset: 0; border-color: var(--vang-logo); }
.o-tien { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
fieldset { border: 1px solid var(--vien); border-radius: 12px; padding: 8px 12px 10px; margin: 0 0 12px; }
legend { font-weight: 600; font-size: .92rem; padding: 0 4px; }
.chon { display: block; position: relative; padding: 6px 0 6px 28px; cursor: pointer; }
.chon input { position: absolute; left: 0; top: 9px; margin: 0; width: 18px; height: 18px; accent-color: var(--chinh); }
.hang-ngang { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.hang-ngang legend { width: 100%; }
.dong-hang { display: grid; grid-template-columns: 2fr 1fr 1.4fr auto; gap: 6px; margin-bottom: 6px; }
.khu-hang[data-co-tien="0"] .dong-hang { grid-template-columns: 2fr 1fr auto; }
.nut-xoa-dong { border: 0; background: none; color: var(--do); cursor: pointer; padding: 0 8px; }
[hidden] { display: none !important; }

.luoi-chon { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 10px; }
.xem-so { padding: 8px; }
.khung-so { overflow-x: auto; background: #fff; color: #000; border-radius: 8px; padding: 12px; }

.thong-bao {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0;
  background: #1c2421; color: #fff; padding: 10px 16px; border-radius: 10px; transition: .25s; pointer-events: none; z-index: 20;
  max-width: calc(100vw - 32px);
}
.thong-bao.hien { opacity: 1; transform: translate(-50%, 0); }
.thong-bao.loi { background: var(--do); }

/* ---------- sổ (mẫu TT 152) ---------- */
.so { font-family: "Times New Roman", Times, serif; font-size: 13px; color: #000; min-width: 560px; }
.so-dau { width: 100%; border: 0; margin-bottom: 8px; }
.so-dau td { vertical-align: top; border: 0; padding: 0; }
.so-mau { text-align: center; width: 45%; font-size: 12px; }
.so-ten { text-align: center; font-size: 15px; font-weight: 700; margin: 10px 0 4px; }
.so-ky-ke-khai { text-align: center; margin-bottom: 8px; }
.so-bang { width: 100%; border-collapse: collapse; }
.so-bang th, .so-bang td { border: 1px solid #000; padding: 3px 5px; vertical-align: top; }
.so-bang th { font-weight: 700; text-align: center; }
.so-bang .so-cot th { font-weight: 400; font-style: italic; }
.so-bang .r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.so-bang .c { text-align: center; white-space: nowrap; }
.so-bang tr.tong td { font-weight: 700; }
.so-bang tr.nhom td { font-style: italic; font-weight: 600; }
.so-bang .tht { padding-left: 18px; }
.so-bang.nho { font-size: 11.5px; }
.so-chu { font-size: 11.5px; font-style: italic; margin: 6px 0; }
.so-thong-tin { margin: 6px 0; line-height: 1.6; }
.so-ky { width: 100%; margin-top: 14px; border: 0; }
.so-ky td { border: 0; text-align: center; width: 50%; vertical-align: top; padding-bottom: 60px; }
.ngat-trang { break-after: page; height: 24px; }

/* gõ nhanh, định kỳ */
.go-nhanh label { display: block; margin-bottom: 6px; }
.go-nhanh textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--vien); border-radius: 10px; background: var(--the);
  font-size: 1.05rem; resize: vertical; min-height: 64px;
}
.go-nhanh textarea:focus { outline: 2px solid var(--vang-logo); border-color: var(--vang-logo); }
.dong-go { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.dong-go .nut { min-width: 120px; }
.xem-tien { color: var(--nhan); font-weight: 600; font-size: .85rem; min-height: 1em; }
.ds-xem { list-style: none; margin: 0; padding: 0; }
.ds-xem li { border-bottom: 1px solid var(--vien); padding: 6px 0 10px; }
.ds-xem li.co-loi { opacity: .65; }
.ds-xem .goc { font-style: italic; }
.xem-dong { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; padding-left: 28px; }
.xem-dong select { padding: 8px; border-radius: 8px; border: 1px solid var(--vien); background: var(--the); min-height: 40px; }
.xem-dong b { font-variant-numeric: tabular-nums; }
.xem-dong .nho { grid-column: 1 / -1; }
.ds-vd { padding-left: 1.1rem; }
.ds-vd li { margin-bottom: 6px; }
code { background: var(--chinh-nhat); padding: 1px 6px; border-radius: 6px; font-size: .92em; }
.luoi-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.nho-nut { min-height: 36px; padding: 6px 14px; }
.dinh-ky { border-left: 4px solid var(--vang); }
.chon.bi-khoa { color: var(--phu); cursor: not-allowed; }
.chon.bi-khoa input { cursor: not-allowed; }
.nhan-khoa { display: inline-block; font-size: .75rem; font-weight: 700; padding: 1px 8px; border-radius: 99px; background: var(--vien); color: var(--chu); margin-left: 4px; }
.dang-xac-nhan { background: var(--do) !important; color: #fff !important; border-color: var(--do) !important; text-decoration: none; border-radius: 8px; padding: 4px 8px; }

.vung-in { display: none; }
@media print {
  @page { size: A4; margin: 15mm 12mm; }
  body.dang-in > *:not(.vung-in) { display: none !important; }
  body.dang-in { background: #fff; padding: 0; }
  body.dang-in .vung-in { display: block; }
  .so { min-width: 0; }
  .so-bang tr { break-inside: avoid; }
}

@media (max-width: 560px) {
  .logo { height: 30px; }
  .chu-tieu-de { padding-left: 8px; }
  .ten-app { font-size: .82rem; }
  .ten-ho { max-width: 30vw; }
  .chon-nam { font-size: 0; gap: 0; }
  .nut-dong-bo .chu-db { display: none; }
  .nut-dong-bo { padding: 4px 9px; }
  .chon-nam select { font-size: .85rem; }
}
@media (max-width: 380px) {
  .chu-tieu-de { display: none; }
}
@media (max-width: 480px) {
  .dong-hang { grid-template-columns: 1fr 1fr; }
  .dong-hang select { grid-column: 1 / -1; }
  .khu-hang[data-co-tien="0"] .dong-hang { grid-template-columns: 1fr auto; }
  .so-lon { font-size: 1.5rem; }
}
