:root {
  --nen: #f7f4ee; --the: #ffffff; --chu: #1c2a24; --mo: #5d6b64; --vien: #dfe5e0; --vien2: #eef1ee;
  --chinh: #c2611b; --chinh2: #fbeee2; --chinh-dam: #14213d;
  --cam: #c2610c; --cam2: #fdf0e3; --do: #b42318; --do2: #fdecea; --vang: #a16207; --vang2: #fef6db;
  --xanh: #1d5fa8; --xanh2: #e6eff9; --tim: #6b46c1; --tim2: #efe9fb;
  --bo: 10px; --bong: 0 1px 2px rgba(20, 40, 30, .06), 0 2px 8px rgba(20, 40, 30, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--nen); color: var(--chu); font: 14.5px/1.5 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
a { color: var(--chinh); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
.dang-tai { padding: 60px 20px; text-align: center; color: var(--mo); }
.mo { color: var(--mo); }
.nho { font-size: 12.5px; }
.so { font-variant-numeric: tabular-nums; }
.phai { text-align: right; }

/* ---------- Thanh trên ---------- */
.dau { background: var(--chinh-dam); color: #fff; position: sticky; top: 0; z-index: 20; }
.dau-trong { max-width: 1280px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 18px; min-height: 56px; }
.thuong-hieu { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; letter-spacing: .3px; white-space: nowrap; }
.thuong-hieu:hover { text-decoration: none; }
.logo { width: 32px; height: 32px; border-radius: 8px; background: #fff; color: var(--chinh-dam); display: grid; place-items: center; font-weight: 800; }
.thuong-hieu small { display: block; font-weight: 400; font-size: 11.5px; opacity: .75; letter-spacing: 0; }
.dieu-huong { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.dieu-huong::-webkit-scrollbar { display: none; }
.dieu-huong a { color: rgba(255, 255, 255, .8); padding: 17px 12px 15px; border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 500; }
.dieu-huong a:hover { color: #fff; text-decoration: none; }
.dieu-huong a.dang { color: #fff; border-bottom-color: #f0a35e; }
.nguoi-dung { position: relative; }
@media (max-width: 860px) {
  .dau-trong { flex-wrap: wrap; gap: 4px 12px; padding-top: 8px; }
  .thuong-hieu { flex: 1; }
  .dieu-huong { order: 3; flex-basis: 100%; }
  .dieu-huong a { padding: 9px 10px 8px; }
  .menu-nd { top: 38px; }
}
.nguoi-dung > button { background: rgba(255, 255, 255, .12); border: 0; color: #fff; border-radius: 20px; padding: 6px 12px; cursor: pointer; font: inherit; white-space: nowrap; }
.menu-nd { position: absolute; right: 0; top: 42px; background: var(--the); color: var(--chu); border-radius: var(--bo); box-shadow: 0 8px 30px rgba(0, 0, 0, .18); min-width: 200px; padding: 6px; z-index: 30; }
.menu-nd button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 12px; border-radius: 6px; font: inherit; cursor: pointer; color: var(--chu); }
.menu-nd button:hover { background: var(--vien2); }

/* ---------- Khung trang ---------- */
.trang { max-width: 1280px; margin: 0 auto; padding: 20px 16px 60px; }
.tieu-de-trang { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.tieu-de-trang p { margin: 4px 0 0; color: var(--mo); }
.tab-con { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.tab-con a { padding: 7px 13px; border-radius: 20px; background: var(--the); border: 1px solid var(--vien); color: var(--chu); font-weight: 500; font-size: 13.5px; }
.tab-con a:hover { text-decoration: none; border-color: var(--chinh); }
.tab-con a.dang { background: var(--chinh); border-color: var(--chinh); color: #fff; }
.the { background: var(--the); border: 1px solid var(--vien); border-radius: var(--bo); box-shadow: var(--bong); padding: 16px; }
.the + .the { margin-top: 14px; }
.the-dau { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.luoi { display: grid; gap: 14px; }
.luoi-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.luoi-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.luoi-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.luoi-ct { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 960px) { .luoi-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .luoi-3, .luoi-ct { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 620px) { .luoi-2, .luoi-4 { grid-template-columns: minmax(0, 1fr); } h1 { font-size: 19px; } .thuong-hieu small { display: none; } }

/* ---------- Chỉ số ---------- */
.chi-so { background: var(--the); border: 1px solid var(--vien); border-radius: var(--bo); padding: 14px 16px; box-shadow: var(--bong); }
.chi-so .nhan { color: var(--mo); font-size: 13px; }
.chi-so .gia-tri { font-size: 24px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.chi-so .phu { font-size: 12.5px; color: var(--mo); margin-top: 2px; }
.chi-so.canh-bao .gia-tri { color: var(--do); }
a.chi-so { display: block; color: inherit; }
a.chi-so:hover { text-decoration: none; border-color: var(--chinh); }

/* ---------- Nút & ô nhập ---------- */
.nut { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--vien); background: var(--the); color: var(--chu); border-radius: 8px; padding: 8px 13px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.nut:hover { border-color: var(--chinh); text-decoration: none; }
.nut.chinh { background: var(--chinh); border-color: var(--chinh); color: #fff; }
.nut.chinh:hover { background: var(--chinh-dam); }
.nut.nguy { color: var(--do); }
.nut.nguy:hover { border-color: var(--do); }
.nut.nho { padding: 4px 9px; font-size: 13px; }
.nut.icon { padding: 4px 8px; }
.nut:disabled { opacity: .5; cursor: not-allowed; }
.nhom-nut { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
input, select, textarea { font: inherit; color: var(--chu); background: #fff; border: 1px solid var(--vien); border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(194, 97, 27, .22); border-color: var(--chinh); }
textarea { resize: vertical; min-height: 70px; }
input[type=checkbox] { width: auto; }
.loc { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.loc > * { flex: 1 1 150px; max-width: 240px; }
.loc .tim { flex: 2 1 220px; max-width: 360px; }

/* ---------- Bảng ---------- */
.bang-boc { overflow-x: auto; border: 1px solid var(--vien); border-radius: var(--bo); background: var(--the); }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 9px 11px; text-align: left; border-bottom: 1px solid var(--vien2); vertical-align: top; }
th { background: #faf7f2; font-weight: 600; font-size: 12.5px; color: var(--mo); white-space: nowrap; position: sticky; top: 0; }
th.sx { cursor: pointer; }
th.sx:hover { color: var(--chinh); }
tbody tr:last-child td { border-bottom: 0; }
tr.bam { cursor: pointer; }
tr.bam:hover td { background: #fbf7f1; }
td.thao-tac { white-space: nowrap; text-align: right; width: 1%; }
.ten-kh { font-weight: 600; }
.cat { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trong { padding: 30px; text-align: center; color: var(--mo); }

/* ---------- Nhãn ---------- */
.nhan-mau { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--vien2); color: var(--mo); }
.m0 { background: #eef1ee; color: #4b5852; } .m1 { background: var(--xanh2); color: var(--xanh); } .m2 { background: var(--tim2); color: var(--tim); }
.m3 { background: var(--vang2); color: var(--vang); } .m4 { background: var(--cam2); color: var(--cam); } .m5 { background: var(--chinh2); color: var(--chinh); }
.m6 { background: #d6f0e4; color: #0a4d39; } .m7 { background: var(--do2); color: var(--do); }
.uu-A { background: var(--do2); color: var(--do); } .uu-B { background: var(--cam2); color: var(--cam); } .uu-C { background: var(--vien2); color: var(--mo); }
.cham-xanh { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #2f9e6e; margin-right: 6px; }
.cham-xam { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #c5ccc8; margin-right: 6px; }
.qua-han { color: var(--do); font-weight: 600; }
.hom-nay { color: var(--cam); font-weight: 600; }

/* ---------- Thanh ngang (phễu, biểu đồ) ---------- */
.thanh-dong { display: grid; grid-template-columns: 150px 1fr 70px; gap: 10px; align-items: center; padding: 5px 0; }
.thanh-dong .ten { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thanh { height: 10px; border-radius: 6px; background: var(--vien2); overflow: hidden; }
.thanh > i { display: block; height: 100%; background: var(--chinh); border-radius: 6px; min-width: 2px; }
@media (max-width: 620px) { .thanh-dong { grid-template-columns: 110px 1fr 56px; } }

/* ---------- Chi tiết ---------- */
.o-tt { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; }
.o-tt .dong { min-width: 0; }
.o-tt .dong.rong { grid-column: 1 / -1; }
.o-tt .k { font-size: 12px; color: var(--mo); }
.o-tt .v { overflow-wrap: anywhere; }
@media (max-width: 620px) { .o-tt { grid-template-columns: minmax(0, 1fr); } }
.dong-thoi-gian { border-left: 2px solid var(--vien); margin-left: 6px; padding-left: 14px; }
.muc-tg { position: relative; padding-bottom: 14px; }
.muc-tg::before { content: ''; position: absolute; left: -20px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--chinh); border: 2px solid #fff; }
.muc-tg .dau-tg { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--mo); }
.ghi-chu-ngang { background: var(--vang2); border: 1px solid #f3e1a6; color: #6b4b05; border-radius: 8px; padding: 10px 12px; font-size: 13.5px; }
.ghi-chu-xanh { background: var(--chinh2); border: 1px solid #bfe1d4; color: var(--chinh-dam); border-radius: 8px; padding: 10px 12px; font-size: 13.5px; }

/* ---------- Khung 4 trụ ---------- */
.the-tru { display: block; color: inherit; border-top: 4px solid var(--chinh); }
.the-tru:hover { text-decoration: none; border-color: var(--chinh); }
.the-tru.ns { border-top-color: #1d5fa8; } .the-tru.tc { border-top-color: #a16207; } .the-tru.mk { border-top-color: #6b46c1; } .the-tru.bh { border-top-color: #0f6b4f; }
.the-tru .cau { color: var(--mo); font-size: 13px; margin: 4px 0 10px; }
.the-mod { display: block; color: inherit; }
.the-mod:hover { text-decoration: none; border-color: var(--chinh); }
.the-mod .ma { font-size: 12px; color: var(--mo); font-weight: 600; }
.the-mod p { margin: 6px 0 10px; color: var(--mo); font-size: 13.5px; }
.danh-sach { margin: 0; padding-left: 20px; }
.danh-sach li { margin: 3px 0; }

/* ---------- Modal & thông báo ---------- */
#modal { position: fixed; inset: 0; background: rgba(15, 30, 22, .45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 30px 12px; overflow-y: auto; }
#modal[hidden] { display: none; }
.hop { background: var(--the); border-radius: 12px; width: 100%; max-width: 720px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.hop.nho { max-width: 440px; }
.hop-dau { padding: 16px 18px; border-bottom: 1px solid var(--vien2); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.hop-than { padding: 16px 18px; }
.hop-chan { padding: 12px 18px; border-top: 1px solid var(--vien2); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.dong-x { background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: var(--mo); }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form label { display: block; font-size: 13px; font-weight: 500; }
.form label > span { display: block; margin-bottom: 4px; color: var(--mo); }
.form .rong { grid-column: 1 / -1; }
.form .goi-y { font-size: 12px; color: var(--mo); margin-top: 3px; }
@media (max-width: 620px) { .form { grid-template-columns: minmax(0, 1fr); } }
#bao { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1c2a24; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 60; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); max-width: calc(100% - 32px); }
#bao.loi { background: var(--do); }

/* ---------- Đăng nhập ---------- */
.man-dn { min-height: 100vh; display: grid; place-items: center; padding: 20px 16px; background: linear-gradient(160deg, #14213d 0%, #24345a 45%, #f3ede2 45.1%); }
.hop-dn { background: #fff; border-radius: 14px; box-shadow: 0 20px 50px rgba(0, 0, 0, .18); width: 100%; max-width: 400px; padding: 26px 24px; }
.hop-dn .logo { width: 44px; height: 44px; font-size: 22px; background: var(--chinh); color: #fff; }
.chon-nguoi { display: grid; gap: 8px; margin: 14px 0; }
.chon-nguoi button { text-align: left; border: 1px solid var(--vien); background: #fff; border-radius: 8px; padding: 10px 12px; font: inherit; cursor: pointer; }
.chon-nguoi button.dang { border-color: var(--chinh); background: var(--chinh2); font-weight: 600; }
.o-pin { letter-spacing: 8px; font-size: 22px; text-align: center; }

/* ---------- Danh mục trong Thiết lập ---------- */
.ds-muc { display: grid; gap: 6px; }
.ds-muc .dong-muc { display: flex; gap: 6px; }
.ds-muc .dong-muc input { flex: 1; }

/* ---------- In ---------- */
@media print {
  .dau, .tab-con, .nhom-nut, .thao-tac, .loc, .khong-in { display: none !important; }
  body { background: #fff; }
  .trang { padding: 0; max-width: none; }
  .the, .bang-boc { box-shadow: none; border: 0; }
  th { position: static; }
}

/* ---------- Riêng app HappyAI ---------- */
.hop-dn .logo { background: var(--chinh-dam); }
.logo { color: var(--chinh-dam); font-size: 13px; }
.cham-moi { display: inline-block; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #e5484d; color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; margin-left: 4px; vertical-align: 1px; }
.buoc-gd { display: flex; gap: 4px; flex-wrap: wrap; margin: 6px 0 2px; }
.buoc-gd button { font: inherit; font-size: 12.5px; border: 1px solid var(--vien); background: #fff; color: var(--mo); border-radius: 16px; padding: 4px 10px; cursor: pointer; }
.buoc-gd button.qua { background: var(--chinh2); border-color: #f0c9a6; color: var(--chinh); }
.buoc-gd button.dang { background: var(--chinh); border-color: var(--chinh); color: #fff; font-weight: 600; }
.tien-gd { height: 6px; background: var(--vien2); border-radius: 4px; overflow: hidden; min-width: 80px; }
.tien-gd i { display: block; height: 100%; background: var(--chinh); }
.luoi-b { width: 100%; border-collapse: collapse; }
.luoi-b th, .luoi-b td { border: 1px solid var(--vien2); padding: 6px 8px; text-align: center; }
.luoi-b td:first-child, .luoi-b th:first-child { text-align: left; font-weight: 600; }
.luoi-b select { width: auto; padding: 4px 6px; }
.luoi-b td.d0 { background: #fdecea; } .luoi-b td.d1 { background: #fef6db; } .luoi-b td.d2 { background: #e3f4ec; }
.o-check { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; border-bottom: 1px dashed var(--vien2); }
.o-check input { margin-top: 4px; }
.goi-y-hop { background: #f3f6fb; border: 1px solid #d9e3f2; border-radius: 8px; padding: 10px 12px; font-size: 13.5px; color: #24345a; }
.goi-y-hop b { color: var(--chinh-dam); }
.tep-luoi { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.tep-the { border: 1px solid var(--vien); border-radius: 10px; padding: 10px; background: #fff; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tep-the .xem { height: 120px; border-radius: 6px; background: var(--vien2); display: grid; place-items: center; overflow: hidden; font-size: 34px; }
.tep-the .xem img, .tep-the .xem video { width: 100%; height: 100%; object-fit: cover; }
.tep-the audio { width: 100%; height: 34px; }
.tep-the .ten { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vung-tha { border: 2px dashed var(--vien); border-radius: 10px; padding: 18px; text-align: center; color: var(--mo); cursor: pointer; display: block; }
.vung-tha:hover, .vung-tha.dang { border-color: var(--chinh); background: var(--chinh2); }
.dm-chon { display: grid; gap: 8px; }
.dm-chon label { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--vien); border-radius: 8px; padding: 9px 11px; cursor: pointer; background: #fff; }
.dm-chon label.goi { border-color: #f0c9a6; background: #fffaf4; }
.dm-chon input { margin-top: 4px; }
.phan-dong { display: grid; grid-template-columns: 28px 1.2fr 80px 1fr 130px; gap: 8px; align-items: start; padding: 8px 0; border-bottom: 1px solid var(--vien2); }
@media (max-width: 760px) { .phan-dong { grid-template-columns: 28px 1fr 1fr; } .phan-dong > .rong-dd { grid-column: 1 / -1; } }
.cot-bieu { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 10px; }
.cot-bieu .cot { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; height: 100%; justify-content: flex-end; }
.cot-bieu .doi { display: flex; gap: 2px; align-items: flex-end; height: 120px; width: 100%; justify-content: center; }
.cot-bieu .doi i { width: 40%; max-width: 18px; border-radius: 3px 3px 0 0; min-height: 1px; }
.cot-bieu .t { font-size: 11px; color: var(--mo); }
.mau-thu { background: #1f6f5c; } .mau-chi { background: #e0a46e; }
.chu-thich { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--mo); margin-right: 12px; }
.chu-thich i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.so-duong { color: #1f6f5c; } .so-am { color: var(--do); }
