:root{
  --go-dam:#3b2a20; --go:#8b5e34; --vang:#c9a06a; --vang-nhat:#f3e6d0;
  --nen:#f6f2ec; --the:#ffffff; --the2:#fbf8f4; --vien:#e6dccf; --vien2:#d6c8b6;
  --chu:#2a2420; --chu2:#6f6153; --chu3:#9a8b7c;
  --xanh:#2f7a55; --xanh-nen:#e6f2ec; --do:#b3432f; --do-nen:#f8e7e3; --cam:#b8741a; --cam-nen:#fbf0de;
  --bong:0 1px 2px rgba(59,42,32,.06), 0 4px 16px rgba(59,42,32,.06);
  --r:12px;
  color-scheme:light;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --nen:#1c1714; --the:#26201b; --the2:#2c251f; --vien:#3b322a; --vien2:#4a3f35;
    --chu:#f1e8dd; --chu2:#c2b3a3; --chu3:#93857a; --vang-nhat:#3a2e22;
    --xanh:#5cbf8c; --xanh-nen:#1f3329; --do:#e7826f; --do-nen:#3a221d; --cam:#e2a64f; --cam-nen:#3a2c18;
    --bong:0 1px 2px rgba(0,0,0,.3); color-scheme:dark;
  }
}
:root[data-theme="dark"]{
  --nen:#1c1714; --the:#26201b; --the2:#2c251f; --vien:#3b322a; --vien2:#4a3f35;
  --chu:#f1e8dd; --chu2:#c2b3a3; --chu3:#93857a; --vang-nhat:#3a2e22;
  --xanh:#5cbf8c; --xanh-nen:#1f3329; --do:#e7826f; --do-nen:#3a221d; --cam:#e2a64f; --cam-nen:#3a2c18;
  --bong:0 1px 2px rgba(0,0,0,.3); color-scheme:dark;
}
*{box-sizing:border-box}
html,body{margin:0; background:var(--nen); color:var(--chu); font:14px/1.5 'Be Vietnam Pro', system-ui, sans-serif}
button,input,select,textarea{font:inherit; color:inherit}
a{color:var(--go)}
.so{font-variant-numeric:tabular-nums}
[hidden]{display:none!important}

/* Khung */
.khung{display:grid; grid-template-columns:240px 1fr; min-height:100vh}
.ben{background:var(--go-dam); color:#efe2cf; padding:18px 14px; position:sticky; top:0; height:100vh; display:flex; flex-direction:column; gap:4px}
.ben .logo{padding:4px 8px 18px; border-bottom:1px solid rgba(255,255,255,.08); margin-bottom:10px}
.nav{display:flex; align-items:center; gap:10px; padding:9px 12px; border-radius:9px; color:#d9c8b2; text-decoration:none; cursor:pointer; border:0; background:none; text-align:left; width:100%; font-weight:500}
.nav svg{width:18px; height:18px; flex:none; opacity:.85}
.nav:hover{background:rgba(255,255,255,.06); color:#fff}
.nav.on{background:var(--vang); color:var(--go-dam); font-weight:700}
.nav.on svg{opacity:1}
.ben .cuoi{margin-top:auto; font-size:12px; color:#a8957f; padding:8px}
.ben .cuoi button{background:none; border:0; color:#d9c8b2; text-decoration:underline; cursor:pointer; padding:0; font-size:12px}
.chinh{min-width:0; padding:22px 28px 60px}
.dau{display:flex; align-items:center; gap:12px; flex-wrap:wrap; margin-bottom:18px}
.dau h1{font-size:22px; margin:0; letter-spacing:-.01em}
.dau .phu{color:var(--chu2); font-size:13px}
.dau .day{margin-left:auto; display:flex; gap:8px; flex-wrap:wrap}

/* Nút */
.nut{display:inline-flex; align-items:center; gap:7px; border:1px solid var(--vien2); background:var(--the); padding:8px 14px; border-radius:9px; cursor:pointer; font-weight:600; font-size:13.5px; white-space:nowrap}
.nut:hover{border-color:var(--go)}
.nut svg{width:16px; height:16px}
.nut.chinh-n{background:var(--go-dam); color:#f5e9d6; border-color:var(--go-dam)}
.nut.chinh-n:hover{background:#4e3829}
.nut.vang{background:var(--vang); border-color:var(--vang); color:var(--go-dam)}
.nut.nho{padding:5px 10px; font-size:12.5px}
.nut.do{color:var(--do)}
.nut.trong{border-color:transparent; background:none}
.nut:disabled{opacity:.5; cursor:default}

/* Thẻ */
.the{background:var(--the); border:1px solid var(--vien); border-radius:var(--r); box-shadow:var(--bong); padding:18px}
.the h2{font-size:15px; margin:0 0 12px; display:flex; align-items:center; gap:8px}
.the h2 .phu{font-weight:400; color:var(--chu2); font-size:12.5px}
.luoi{display:grid; gap:16px}
.luoi.c4{grid-template-columns:repeat(4,1fr)}
.luoi.c3{grid-template-columns:repeat(3,1fr)}
.luoi.c2{grid-template-columns:repeat(2,1fr)}
.kpi .nhan{font-size:12px; color:var(--chu2); text-transform:uppercase; letter-spacing:.05em; font-weight:600}
.kpi .gt{font-size:24px; font-weight:700; margin-top:4px; letter-spacing:-.01em}
.kpi .ghi{font-size:12px; color:var(--chu3)}

/* Ô nhập */
label.o{display:flex; flex-direction:column; gap:4px; font-size:12px; color:var(--chu2); font-weight:600}
.inp{border:1px solid var(--vien2); background:var(--the); border-radius:8px; padding:7px 10px; width:100%; min-width:0}
.inp:focus{outline:2px solid var(--vang); outline-offset:0; border-color:var(--vang)}
textarea.inp{resize:vertical; min-height:60px}
.inp.so{text-align:right}
.hang-o{display:grid; gap:12px; align-content:start}

/* Bảng */
.bang-wrap{overflow-x:auto; border:1px solid var(--vien); border-radius:10px; background:var(--the)}
table.bang{width:100%; border-collapse:collapse; font-size:13px}
.bang th{background:var(--the2); color:var(--chu2); font-weight:600; font-size:11.5px; text-transform:uppercase; letter-spacing:.04em; text-align:left; padding:9px 10px; border-bottom:1px solid var(--vien); white-space:nowrap; position:sticky; top:0}
.bang td{padding:7px 10px; border-bottom:1px solid var(--vien); vertical-align:middle}
.bang tr:last-child td{border-bottom:0}
.bang td.so, .bang th.so{text-align:right}
.bang .inp{padding:5px 7px; border-color:transparent; background:transparent}
.bang .inp:hover{border-color:var(--vien2)}
.bang .inp:focus{background:var(--the)}
.bang tr.chon td{background:var(--vang-nhat)}
.bang tbody tr.click{cursor:pointer}
.bang tbody tr.click:hover td{background:var(--the2)}

/* Nhãn */
.nhan{display:inline-flex; align-items:center; gap:4px; font-size:11px; font-weight:700; padding:2px 8px; border-radius:99px; white-space:nowrap}
.nhan.mau{background:var(--do-nen); color:var(--do)}
.nhan.xanh{background:var(--xanh-nen); color:var(--xanh)}
.nhan.cam{background:var(--cam-nen); color:var(--cam)}
.nhan.xam{background:var(--the2); color:var(--chu2); border:1px solid var(--vien)}
.cap{display:inline-flex; align-items:center; justify-content:center; gap:3px; font-size:11px; font-weight:700; padding:2px 8px; border-radius:99px; color:#fff; white-space:nowrap}
.cap1{background:#6c9a5b} .cap2{background:#4f86a8} .cap3{background:#c08a2c} .cap4{background:#c4622d} .cap5{background:#9c3030}
.bao{border-radius:10px; padding:10px 14px; font-size:13px; display:flex; gap:10px; align-items:flex-start}
.bao.do{background:var(--do-nen); color:var(--do)}
.bao.cam{background:var(--cam-nen); color:var(--cam)}
.bao.xanh{background:var(--xanh-nen); color:var(--xanh)}
.lai{color:var(--xanh); font-weight:600}
.lo{color:var(--do); font-weight:600}
.mo{color:var(--chu2)}
.nho-chu{font-size:12px}

/* Dự toán */
.dt-bo{display:grid; grid-template-columns:minmax(0,1fr) 310px; gap:18px; align-items:start}
.dt-bo > div{min-width:0}
table.dt-dong{min-width:1040px}
.dt-thanh{display:none}
.dt-tong{position:sticky; top:16px}
.khu{margin-top:16px}
.khu-dau{display:flex; align-items:center; gap:10px; padding:10px 12px; background:var(--go-dam); color:#f3e3c7; border-radius:10px 10px 0 0}
.khu-dau input{background:transparent; border:0; color:#fff; font-weight:700; font-size:14px; letter-spacing:.03em; flex:1; min-width:0; text-transform:uppercase}
.khu-dau input:focus{outline:1px dashed var(--vang)}
.khu-dau .tong{font-weight:700}
.khu-dau button{background:none; border:0; color:#d9c8b2; cursor:pointer}
.khu .bang-wrap{border-radius:0 0 10px 10px; border-top:0}
.dt-dong .ten{font-weight:600}
.dt-dong .kt{display:flex; gap:4px}
.dt-dong .kt .inp{width:64px; text-align:right}
.hinh-nho{width:54px; height:42px; border-radius:6px; background:var(--the2); display:flex; align-items:center; justify-content:center; overflow:hidden; border:1px solid var(--vien)}
.hinh-nho img,.hinh-nho svg{max-width:100%; max-height:100%; object-fit:cover}
.chi-tiet td{background:var(--the2)!important; padding:14px 16px!important}
.ct-luoi{display:grid; grid-template-columns:1.1fr 1fr 1fr; gap:16px}
.phan-tich{width:100%; font-size:12.5px; border-collapse:collapse}
.phan-tich td{padding:4px 0; border-bottom:1px dashed var(--vien)}
.phan-tich td:last-child{text-align:right; font-variant-numeric:tabular-nums}
.phan-tich tr.dam td{font-weight:700; border-bottom:1px solid var(--vien2)}
.tong-dong{display:flex; justify-content:space-between; padding:6px 0; font-size:13.5px}
.tong-dong.lon{font-size:19px; font-weight:800; border-top:2px solid var(--go-dam); margin-top:6px; padding-top:10px}
.tong-dong .so{font-weight:600}
.thanh{height:8px; background:var(--the2); border-radius:99px; overflow:hidden; display:flex; margin:8px 0 4px}
.thanh span{display:block; height:100%}
.chu-thich{display:flex; flex-wrap:wrap; gap:10px; font-size:11.5px; color:var(--chu2)}
.chu-thich i{display:inline-block; width:9px; height:9px; border-radius:2px; margin-right:4px}
.da-luu{font-size:12px; color:var(--chu3)}

/* Thư viện sản phẩm */
.sp-luoi{display:grid; grid-template-columns:repeat(auto-fill, minmax(230px,1fr)); gap:14px}
.sp-the{background:var(--the); border:1px solid var(--vien); border-radius:var(--r); overflow:hidden; cursor:pointer; box-shadow:var(--bong); transition:transform .12s}
.sp-the:hover{transform:translateY(-2px); border-color:var(--vang)}
.sp-the .anh{aspect-ratio:4/3; background:linear-gradient(180deg,#fbf6ee,#f1e7d8); display:flex; align-items:center; justify-content:center}
.sp-the .anh img{width:100%; height:100%; object-fit:cover}
.sp-the .anh svg{width:78%; height:78%}
.sp-the .tt{padding:12px 14px}
.sp-the .ten{font-weight:700}
.sp-the .dong2{display:flex; justify-content:space-between; align-items:center; margin-top:6px; font-size:12.5px; color:var(--chu2)}
.loc{display:flex; gap:6px; flex-wrap:wrap; margin-bottom:14px}
.loc button{border:1px solid var(--vien2); background:var(--the); padding:5px 12px; border-radius:99px; cursor:pointer; font-size:12.5px}
.loc button.on{background:var(--go-dam); color:#f3e3c7; border-color:var(--go-dam)}
.sp-bo{display:grid; grid-template-columns:1fr 1fr; gap:18px; align-items:start}
.ban-ve-khung{background:#fffdf9; border:1px solid var(--vien); border-radius:10px; overflow:hidden}
.ban-ve-khung svg{display:block; width:100%; height:auto}
.anh-ds{display:flex; gap:10px; flex-wrap:wrap}
.anh-o{position:relative; width:120px; height:92px; border-radius:8px; overflow:hidden; border:1px solid var(--vien); background:var(--the2)}
.anh-o img{width:100%; height:100%; object-fit:cover; cursor:zoom-in}
.anh-o .pdf{display:flex; flex-direction:column; align-items:center; justify-content:center; height:100%; font-size:12px; color:var(--chu2); text-decoration:none; text-align:center; padding:6px}
.anh-o button{position:absolute; top:4px; right:4px; background:rgba(0,0,0,.55); color:#fff; border:0; border-radius:6px; font-size:11px; cursor:pointer; padding:2px 6px}
.anh-them{width:120px; height:92px; border:1.5px dashed var(--vien2); border-radius:8px; display:flex; flex-direction:column; align-items:center; justify-content:center; color:var(--chu2); cursor:pointer; font-size:12px; gap:4px; background:none}
.anh-them:hover{border-color:var(--go); color:var(--go)}
.tc-ds{display:grid; grid-template-columns:1fr 1fr; gap:6px 14px}
.tc-ds label{display:flex; gap:8px; align-items:center; font-size:13px; cursor:pointer}
.tc-ds .d{margin-left:auto; color:var(--chu3); font-size:11.5px}

/* Đăng nhập */
.vao{min-height:100vh; display:flex; align-items:center; justify-content:center; padding:16px; background:radial-gradient(circle at 30% 20%, #4a3628, #2a1e17)}
.vao .hop{background:var(--the); border-radius:18px; padding:32px 28px; width:min(380px,100%); box-shadow:0 20px 60px rgba(0,0,0,.35); text-align:center}
.vao .hop .inp{text-align:center; font-size:18px; letter-spacing:.2em; padding:12px; margin:18px 0 12px}

/* Hộp nổi */
.phu-man{position:fixed; inset:0; background:rgba(30,20,14,.55); z-index:50; display:flex; align-items:flex-start; justify-content:center; padding:30px 16px; overflow:auto}
.phu-man .hop{background:var(--the); border-radius:14px; width:min(720px,100%); padding:20px; box-shadow:0 20px 60px rgba(0,0,0,.35)}
.phu-man .hop.rong{width:min(1180px,100%)}
.chon-sp{max-height:60vh; overflow:auto; margin-top:12px}
.chon-sp .nhom-t{font-size:11.5px; font-weight:700; text-transform:uppercase; color:var(--chu3); margin:12px 0 6px; letter-spacing:.05em}
.chon-sp button{display:flex; align-items:center; gap:12px; width:100%; text-align:left; background:none; border:1px solid transparent; border-radius:9px; padding:7px 10px; cursor:pointer}
.chon-sp button:hover{background:var(--the2); border-color:var(--vien)}
.thong-bao{position:fixed; bottom:20px; left:50%; transform:translateX(-50%); background:var(--go-dam); color:#f5e9d6; padding:10px 18px; border-radius:10px; z-index:80; box-shadow:0 8px 30px rgba(0,0,0,.3); font-weight:600}

/* Vùng in */
#vung-in{display:none}
.xem-in{position:fixed; inset:0; z-index:60; background:#6b5d52; overflow:auto; padding:20px 12px 60px}
.xem-in .thanh-in{position:sticky; top:0; display:flex; gap:8px; justify-content:center; margin-bottom:16px; z-index:2}

@media (max-width: 1500px){
  .dt-bo{grid-template-columns:1fr}
  .dt-tong{position:static}
  .dt-thanh{display:flex; position:sticky; bottom:0; z-index:20; gap:18px; flex-wrap:wrap; align-items:center; background:var(--go-dam); color:#f3e3c7; padding:10px 16px; border-radius:12px 12px 0 0; margin:18px -4px 0; box-shadow:0 -6px 20px rgba(0,0,0,.15)}
  .dt-thanh b{color:#fff; font-size:16px}
  .dt-thanh .lai{color:#8fd8ae}
}
@media (max-width: 1100px){
  .sp-bo{grid-template-columns:1fr}
  .luoi.c4{grid-template-columns:repeat(2,1fr)}
  .ct-luoi{grid-template-columns:1fr}
}
@media (max-width: 760px){
  .khung{grid-template-columns:1fr}
  .ben{position:fixed; bottom:0; top:auto; height:auto; width:100%; flex-direction:row; padding:6px; z-index:40; overflow-x:auto; gap:2px}
  .ben .logo,.ben .cuoi{display:none}
  .nav{flex-direction:column; gap:2px; font-size:10.5px; padding:6px 8px; min-width:68px; align-items:center; text-align:center}
  .chinh{padding:16px 16px 90px}
  .luoi.c3,.luoi.c2,.tc-ds{grid-template-columns:1fr}
  .dau h1{font-size:19px}
  .hang-o[style*="grid-template-columns"]{grid-template-columns:1fr 1fr!important}
  .dt-thanh{bottom:62px; gap:10px; font-size:12px}
}
@media print{
  body > *:not(#vung-in){display:none!important}
  #vung-in{display:block!important}
  html,body{background:#fff}
}
