/* KDE – Khánh Đăng M&E · màu nhận diện: đỏ #E31B23, đen #141414, trắng */
:root {
  --do: #e31b23; --do-dam: #b5121a; --do-nhat: #fdecec; --den: #141414; --den-2: #1f1f1f; --den-3: #2b2b2b;
  --nen: #f4f4f5; --mat: #ffffff; --vien: #e4e4e7; --vien-2: #d4d4d8; --chu: #18181b; --chu-2: #52525b; --chu-3: #71717a;
  --xanh: #15803d; --xanh-nhat: #dcfce7; --vang: #a16207; --vang-nhat: #fef9c3; --lam: #1d4ed8; --lam-nhat: #dbeafe; --tim: #6d28d9; --tim-nhat: #ede9fe;
  --bo: 8px; --bong: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--chu); font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--nen); }
a { color: var(--do-dam); text-decoration: none; } a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 700; }
.an { display: none !important; }

/* ---------- Đăng nhập ---------- */
.dang-nhap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.dn-trai { background: var(--den); color: #fff; display: flex; flex-direction: column; justify-content: center; padding: 48px; position: relative; overflow: hidden; }
.dn-trai::after { content: ""; position: absolute; right: -120px; top: -60px; width: 280px; height: 140%; background: var(--do); transform: rotate(14deg); border-radius: 140px; opacity: .92; }
.dn-trai h1 { font-size: 34px; line-height: 1.2; position: relative; z-index: 1; max-width: 460px; }
.dn-trai p { color: #c4c4c8; position: relative; z-index: 1; max-width: 440px; line-height: 1.6; }
.dn-trai ul { position: relative; z-index: 1; padding-left: 18px; color: #e4e4e7; line-height: 1.9; }
.dn-phai { display: flex; align-items: center; justify-content: center; padding: 32px 16px; background: #fff; }
.dn-hop { width: 100%; max-width: 360px; }
.dn-hop img { width: 220px; display: block; margin: 0 auto 24px; }
.dn-hop label { display: block; font-weight: 600; margin: 14px 0 6px; }
.dn-hop .nut { width: 100%; margin-top: 22px; padding: 11px; }
.dn-hop .loi { color: var(--do-dam); margin-top: 12px; min-height: 20px; }
.dn-hop .phu { text-align: center; margin-top: 18px; color: var(--chu-3); font-size: 13px; }
@media (max-width: 820px) { .dang-nhap { grid-template-columns: 1fr; } .dn-trai { display: none; } }

/* ---------- Khung ứng dụng ---------- */
.khung { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.thanh-ben { background: var(--den); color: #d4d4d8; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.tb-logo { background: #fff; padding: 12px 16px; display: flex; align-items: center; gap: 10px; border-bottom: 3px solid var(--do); }
.tb-logo img { height: 40px; }
.tb-logo span { font-size: 12px; color: var(--chu-2); line-height: 1.3; font-weight: 600; }
.menu { padding: 8px 0 24px; flex: 1; }
.menu .nhom { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #8a8a90; padding: 16px 20px 6px; }
.menu a { display: flex; align-items: center; gap: 10px; padding: 8px 20px; color: #d4d4d8; border-left: 3px solid transparent; text-decoration: none; }
.menu a:hover { background: var(--den-2); color: #fff; }
.menu a.dang { background: var(--den-3); color: #fff; border-left-color: var(--do); }
.menu a .bt { width: 20px; text-align: center; opacity: .9; }
.menu a .dem { margin-left: auto; background: var(--do); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; }
.tb-chan { padding: 12px 20px; font-size: 12px; color: #8a8a90; border-top: 1px solid var(--den-3); }
.chinh { min-width: 0; display: flex; flex-direction: column; }
.thanh-tren { background: #fff; border-bottom: 1px solid var(--vien); display: flex; align-items: center; gap: 12px; padding: 10px 24px; position: sticky; top: 0; z-index: 20; }
.thanh-tren h1 { font-size: 18px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thanh-tren .tim-nhanh { width: 280px; max-width: 40vw; }
.nut-menu { display: none; background: none; border: 0; font-size: 22px; cursor: pointer; padding: 4px 8px; }
.nguoi { display: flex; align-items: center; gap: 8px; cursor: pointer; position: relative; padding: 4px 8px; border-radius: var(--bo); }
.nguoi:hover { background: var(--nen); }
.nguoi .av { width: 32px; height: 32px; border-radius: 50%; background: var(--do); color: #fff; display: grid; place-items: center; font-weight: 700; }
.nguoi small { display: block; color: var(--chu-3); font-size: 12px; }
.menu-nguoi { position: absolute; right: 0; top: 46px; background: #fff; border: 1px solid var(--vien); border-radius: var(--bo); box-shadow: var(--bong); min-width: 200px; padding: 6px; }
.menu-nguoi button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.menu-nguoi button:hover { background: var(--nen); }
.noi-dung { padding: 20px 24px 40px; min-width: 0; }
@media (max-width: 960px) {
  .khung { grid-template-columns: 1fr; }
  .thanh-ben { position: fixed; z-index: 50; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .khung.mo-menu .thanh-ben { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .nut-menu { display: block; }
  .thanh-tren { padding: 8px 12px; } .thanh-tren .tim-nhanh { display: none; }
  .nguoi > div { display: none; }
  .noi-dung { padding: 14px 12px 32px; }
}

/* ---------- Thành phần chung ---------- */
.nut { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--vien-2); background: #fff; padding: 7px 14px; border-radius: var(--bo); cursor: pointer; font-weight: 600; white-space: nowrap; }
.nut:hover { border-color: var(--chu-3); }
.nut.chinh-nut { background: var(--do); border-color: var(--do); color: #fff; }
.nut.chinh-nut:hover { background: var(--do-dam); border-color: var(--do-dam); }
.nut.den { background: var(--den); border-color: var(--den); color: #fff; }
.nut.nguy { color: var(--do-dam); border-color: #f3b4b7; }
.nut.nho { padding: 4px 10px; font-size: 13px; }
.nut:disabled { opacity: .5; cursor: default; }
.o, input[type=text].o, select.o, textarea.o { width: 100%; border: 1px solid var(--vien-2); border-radius: 6px; padding: 7px 10px; background: #fff; min-height: 36px; }
.o:focus { outline: 2px solid rgba(227,27,35,.25); border-color: var(--do); }
textarea.o { min-height: 70px; resize: vertical; }
.o:disabled, .o[readonly] { background: #f4f4f5; color: var(--chu-2); }
.the { background: var(--mat); border: 1px solid var(--vien); border-radius: 10px; box-shadow: var(--bong); }
.the > h3 { font-size: 15px; padding: 14px 16px 0; display: flex; align-items: center; gap: 8px; }
.the > h3 .phai { margin-left: auto; font-weight: 400; font-size: 13px; }
.the .than { padding: 12px 16px 16px; }
.nhan { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #f4f4f5; color: var(--chu-2); white-space: nowrap; }
.nhan.xanh { background: var(--xanh-nhat); color: var(--xanh); } .nhan.vang { background: var(--vang-nhat); color: var(--vang); }
.nhan.do { background: var(--do-nhat); color: var(--do-dam); } .nhan.lam { background: var(--lam-nhat); color: var(--lam); } .nhan.tim { background: var(--tim-nhat); color: var(--tim); }
.nhan.den { background: var(--den); color: #fff; }
.mo { color: var(--chu-3); } .nho-chu { font-size: 12px; }
.so { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chu-do { color: var(--do-dam); font-weight: 600; }

/* Thanh công cụ danh sách */
.cong-cu { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.cong-cu .tim { flex: 1 1 260px; max-width: 420px; position: relative; }
.cong-cu .tim input { padding-left: 32px; }
.cong-cu .tim::before { content: "⌕"; position: absolute; left: 10px; top: 6px; color: var(--chu-3); font-size: 17px; }
.cong-cu .gian { flex: 1; }
.bo-loc { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: flex-end; }
.bo-loc .muc { display: flex; flex-direction: column; gap: 3px; min-width: 150px; }
.bo-loc .muc label { font-size: 12px; color: var(--chu-3); font-weight: 600; }
.bo-loc .muc .o { min-height: 32px; padding: 5px 8px; }
.bo-loc .ngay2 { display: flex; gap: 4px; } .bo-loc .ngay2 .o { width: 140px; }

/* Bảng */
.bang-boc { overflow-x: auto; background: #fff; border: 1px solid var(--vien); border-radius: 10px; }
table.bang { width: 100%; border-collapse: collapse; }
.bang th { background: var(--den); color: #fff; text-align: left; font-weight: 600; padding: 9px 10px; font-size: 13px; white-space: nowrap; position: sticky; top: 0; }
.bang th.so { text-align: right; }
.bang th.sx { cursor: pointer; } .bang th.sx:hover { background: var(--den-3); }
.bang th .mui { color: var(--do); margin-left: 4px; }
.bang td { padding: 8px 10px; border-bottom: 1px solid var(--vien); vertical-align: top; }
.bang tbody tr:hover td { background: #fafafa; }
.bang tbody tr.bam { cursor: pointer; }
.bang tfoot td { font-weight: 700; background: var(--do-nhat); border-top: 2px solid var(--do); }
.bang.gon td, .bang.gon th { padding: 5px 8px; }
.trong { padding: 32px; text-align: center; color: var(--chu-3); }
.phan-trang { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding: 10px 0; color: var(--chu-2); flex-wrap: wrap; }

/* Hộp thoại */
.phu-nen { position: fixed; inset: 0; background: rgba(20,20,20,.5); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 32px 12px; overflow-y: auto; }
.hop { background: #fff; border-radius: 12px; width: 100%; max-width: 760px; box-shadow: 0 20px 60px rgba(0,0,0,.3); display: flex; flex-direction: column; }
.hop.rong { max-width: 1100px; } .hop.hep { max-width: 460px; }
.hop-dau { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--vien); border-top: 4px solid var(--do); border-radius: 12px 12px 0 0; }
.hop-dau h2 { font-size: 17px; flex: 1; }
.hop-dau .dong { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--chu-3); line-height: 1; }
.hop-than { padding: 16px 18px; }
.hop-chan { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--vien); background: #fafafa; border-radius: 0 0 12px 12px; flex-wrap: wrap; position: sticky; bottom: 0; }
.hop-chan .trai { margin-right: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* Biểu mẫu */
.luoi { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.luoi .tr { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.luoi .tr.r2 { grid-column: span 2; }
.luoi .tr > label { font-size: 13px; font-weight: 600; color: var(--chu-2); }
.luoi .tr > label .bb { color: var(--do); }
.luoi .tr .goi { font-size: 12px; color: var(--chu-3); }
.luoi .tieu-muc { grid-column: span 2; font-weight: 700; border-bottom: 2px solid var(--do); padding-bottom: 4px; margin-top: 6px; }
.luoi .hang-ngang { display: flex; gap: 6px; }
.chk { display: flex; align-items: center; gap: 8px; min-height: 36px; }
.chk input { width: 18px; height: 18px; accent-color: var(--do); }
.luoi .tr.r-full { grid-column: 1 / -1; }
@media (min-width: 900px) { .hop.rong .luoi { grid-template-columns: repeat(3, minmax(0, 1fr)); } .hop.rong .luoi .tieu-muc { grid-column: 1 / -1; } }
@media (max-width: 640px) { .luoi { grid-template-columns: 1fr; } .luoi .tr.r2, .luoi .tr.r-full, .luoi .tieu-muc { grid-column: span 1; } }

/* Ô chọn có tìm kiếm */
.cb { position: relative; }
.cb-dd { position: absolute; left: 0; right: 0; top: 100%; margin-top: 2px; background: #fff; border: 1px solid var(--vien-2); border-radius: 6px; box-shadow: var(--bong); z-index: 120; max-height: 260px; overflow-y: auto; }
.cb-dd div { padding: 7px 10px; cursor: pointer; } .cb-dd div:hover, .cb-dd div.chon { background: var(--do-nhat); }
.cb-dd .mo { cursor: default; } .cb-dd .mo:hover { background: none; }
.cb .xoa-cb { position: absolute; right: 6px; top: 7px; border: 0; background: none; color: var(--chu-3); cursor: pointer; font-size: 16px; }

/* Dòng hàng */
.dong-hang { margin-top: 16px; }
.dong-hang h4 { margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
.dong-hang table { width: 100%; border-collapse: collapse; }
.dong-hang th { background: #f4f4f5; font-size: 12px; text-align: left; padding: 6px; color: var(--chu-2); }
.dong-hang td { padding: 4px; border-bottom: 1px solid var(--vien); vertical-align: top; }
.dong-hang td .o { min-height: 32px; padding: 5px 7px; }
.dong-hang .c-tb { min-width: 240px; } .dong-hang .c-sl { width: 80px; } .dong-hang .c-gia { width: 130px; } .dong-hang .c-tt { width: 130px; } .dong-hang .c-seri { min-width: 180px; }
.dong-hang textarea.o { min-height: 32px; height: 32px; font-family: Consolas, monospace; font-size: 12px; }
.dong-hang textarea.o:focus { height: 90px; }
.tong-cong { display: grid; grid-template-columns: auto 160px; gap: 4px 16px; justify-content: end; margin-top: 10px; }
.tong-cong .so { font-weight: 600; } .tong-cong .lon { font-size: 17px; color: var(--do-dam); }

/* Liên kết / tệp */
.lien-ket { margin-top: 18px; }
.tab { display: flex; gap: 4px; border-bottom: 1px solid var(--vien); margin-bottom: 10px; flex-wrap: wrap; }
.tab button { border: 0; background: none; padding: 8px 12px; cursor: pointer; border-bottom: 3px solid transparent; font-weight: 600; color: var(--chu-2); }
.tab button.dang { border-bottom-color: var(--do); color: var(--chu); }
.tep-ds { display: flex; flex-direction: column; gap: 6px; }
.tep-ds .tep { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--vien); border-radius: 6px; }
.tep-ds .tep .ten { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tha-tep { border: 2px dashed var(--vien-2); border-radius: 8px; padding: 14px; text-align: center; color: var(--chu-3); cursor: pointer; margin-top: 8px; }
.tha-tep.keo { border-color: var(--do); background: var(--do-nhat); }

/* Tổng quan */
.o-so { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (max-width: 500px) { .o-so { grid-template-columns: 1fr 1fr; gap: 8px; } .o-so .the { padding: 10px 12px; } .o-so .gt { font-size: 19px; } }
.o-so .the { padding: 14px 16px; position: relative; overflow: hidden; }
.o-so .the::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--den); }
.o-so .the.nhan-do::before { background: var(--do); }
.o-so .nh { color: var(--chu-3); font-size: 13px; font-weight: 600; }
.o-so .gt { font-size: 24px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.o-so .ph { font-size: 12px; color: var(--chu-3); margin-top: 2px; }
.luoi-tq { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; }
@media (max-width: 500px) { .luoi-tq { grid-template-columns: 1fr; } }
.ds-gon { list-style: none; margin: 0; padding: 0; }
.ds-gon li { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--vien); }
.ds-gon li:last-child { border-bottom: 0; }
.ds-gon li .gt { margin-left: auto; text-align: right; }
.bieu-do { position: relative; }
.bieu-do svg { width: 100%; height: 220px; display: block; }
.bieu-do .tip { position: absolute; pointer-events: none; background: var(--den); color: #fff; padding: 6px 10px; border-radius: 6px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -110%); }
.cham-nhanh { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.cham-nhanh .gio { font-size: 32px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Chấm công */
.bang-cong { font-size: 12px; }
.bang-cong th, .bang-cong td { padding: 4px 3px !important; text-align: center; }
.bang-cong td.ten, .bang-cong th.ten { text-align: left; position: sticky; left: 0; background: #fff; z-index: 2; min-width: 170px; }
.bang-cong th.ten { background: var(--den); z-index: 3; }
.bang-cong th.cn { background: var(--do-dam); }
.bang-cong td.cn { background: #fff5f5; }
.bang-cong td.o-cc { cursor: pointer; min-width: 34px; font-weight: 600; }
.bang-cong td.o-cc:hover { outline: 2px solid var(--do); outline-offset: -2px; }
.cc-X { color: var(--xanh); } .cc-le { color: var(--vang); } .cc-P, .cc-L, .cc-CT { color: var(--lam); } .cc-thieu { color: #fff; background: var(--do) !important; } .cc-KL, .cc-Ô { color: var(--chu-3); }
.cc-tre { box-shadow: inset 0 -3px 0 var(--vang); }
.chu-thich { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--chu-2); margin: 8px 0; }
.nut-cham { font-size: 18px; padding: 14px 26px; border-radius: 12px; }

/* Tra cứu */
.kq-seri { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.kq-seri .the { padding: 14px 16px; }
.kq-seri .dong { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; font-size: 13px; }
.kq-seri .dong span:first-child { color: var(--chu-3); }

/* Báo cáo */
.bc-khung { display: grid; grid-template-columns: 240px 1fr; gap: 16px; align-items: start; }
.bc-ds a { display: block; padding: 8px 12px; border-radius: 6px; color: var(--chu); }
.bc-ds a:hover { background: var(--nen); text-decoration: none; }
.bc-ds a.dang { background: var(--den); color: #fff; }
.bc-ds .nhom { font-size: 11px; text-transform: uppercase; color: var(--chu-3); padding: 10px 12px 4px; letter-spacing: .06em; }
@media (max-width: 900px) { .bc-khung { grid-template-columns: 1fr; } }

/* Thông báo nổi */
.toast { position: fixed; right: 16px; bottom: 16px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast div { background: var(--den); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--bong); border-left: 4px solid var(--xanh); max-width: 380px; }
.toast div.loi { border-left-color: var(--do); }

/* ---------- Bản in ---------- */
.ban-in { background: #fff; max-width: 820px; margin: 0 auto; padding: 28px 36px; color: #000; font-size: 13px; box-shadow: var(--bong); }
.ban-in .dau-in { display: flex; gap: 16px; align-items: center; border-bottom: 3px solid var(--do); padding-bottom: 10px; }
.ban-in .dau-in img { height: 64px; }
.ban-in .dau-in .ct b { font-size: 15px; display: block; }
.ban-in h2 { text-align: center; font-size: 20px; margin: 18px 0 2px; color: var(--do-dam); }
.ban-in .so-in { text-align: center; margin-bottom: 14px; color: #444; }
.ban-in table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.ban-in th, .ban-in td { border: 1px solid #999; padding: 5px 7px; }
.ban-in th { background: #f1f1f1; }
.ban-in .ky { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; margin-top: 28px; min-height: 110px; }
.ban-in .ky b { display: block; } .ban-in .ky i { font-size: 12px; color: #555; }
.ban-in .tt { display: grid; grid-template-columns: 150px 1fr; gap: 4px 10px; }
.thanh-in { max-width: 820px; margin: 0 auto 12px; display: flex; gap: 8px; }
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .thanh-ben, .thanh-tren, .thanh-in, .toast { display: none !important; }
  .khung { display: block; } .noi-dung { padding: 0; }
  .ban-in { box-shadow: none; padding: 0; max-width: none; }
}
