:root {
  --nen: #f4f6f9;
  --the: #ffffff;
  --chu: #1d2733;
  --nhat: #5f6b7a;
  --vien: #d9dee5;
  --chinh: #0b5394;
  --chinh-dam: #083d6e;
  --vang: #f2b400;
  --do: #b3261e;
  --xanh: #1e7b34;
  --tt: #8a5a00;
  --dt: #0b6e7a;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 "Segoe UI", Arial, sans-serif; background: var(--nen); color: var(--chu); }
.an { display: none !important; }
body:not([data-vai-tro="quan_tri"]) .chi-quan-tri { display: none !important; }
body[data-vai-tro="xem"] .chi-sua { display: none !important; }
.ten-nd { font-size: .85rem; color: #dce8f5; display: flex; align-items: center; }
h1, h2, h3 { margin: 0 0 .6em; line-height: 1.25; }
h2 { font-size: 1.2rem; }
code { background: #eef1f5; padding: 1px 5px; border-radius: 4px; word-break: break-all; }
.nho { color: var(--nhat); font-size: .88rem; }
.loi { color: var(--do); font-weight: 600; min-height: 1em; }

/* Đăng nhập */
#man-dang-nhap { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(135deg, var(--chinh) 0%, var(--chinh-dam) 100%); }
.hop-dang-nhap { background: var(--the); padding: 28px; border-radius: 10px; width: 100%; max-width: 380px;
  display: grid; gap: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.hop-dang-nhap h1 { color: var(--chinh); font-size: 1.5rem; margin: 0; border-bottom: 4px solid var(--vang); padding-bottom: 8px; }

/* Đầu trang */
.dau { background: var(--chinh); color: #fff; padding: 0 16px; display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px 24px;
  border-bottom: 4px solid var(--vang); position: sticky; top: 0; z-index: 5; }
.ten-pm { font-weight: 700; font-size: 1.15rem; display: flex; align-items: center; padding: 10px 0; }
.tab-chinh { display: flex; flex-wrap: wrap; flex: 1; }
.tab-chinh button { background: none; border: 0; color: #dce8f5; padding: 12px 14px; font: inherit; cursor: pointer;
  border-bottom: 3px solid transparent; margin-bottom: -4px; }
.tab-chinh button:hover { color: #fff; background: rgba(255,255,255,.08); }
.tab-chinh button.dang-chon { color: #fff; font-weight: 600; border-bottom-color: #fff; }
.tab-chinh .phu { margin-left: auto; }

main { padding: 16px; max-width: 1500px; margin: 0 auto; }
.bo-cuc { display: grid; grid-template-columns: 270px 1fr; gap: 16px; align-items: start; }
.menu-trai { background: var(--the); border: 1px solid var(--vien); border-radius: 8px; padding: 8px; display: grid; gap: 2px; position: sticky; top: 70px; }
.menu-trai .nhom-menu { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--nhat); padding: 10px 10px 4px; font-weight: 600; }
.menu-trai button { text-align: left; background: none; border: 0; padding: 7px 10px 7px 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 6px; font: inherit; cursor: pointer; color: var(--chu); }
.menu-trai button:hover { background: #eef3f9; }
.menu-trai button.dang-chon { background: var(--chinh); color: #fff; }
.vung-muc { min-width: 0; display: grid; gap: 16px; }

.the { background: var(--the); border: 1px solid var(--vien); border-radius: 8px; padding: 16px; margin-bottom: 16px; min-width: 0; }
.vung-muc .the { margin-bottom: 0; }
.dau-the { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.dau-the h2 { margin: 0; }

/* Nút & ô nhập */
.nut { font: inherit; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--vien); background: #fff; cursor: pointer; color: var(--chu); white-space: nowrap; }
.nut:hover { border-color: var(--chinh); }
.nut.chinh { background: var(--chinh); color: #fff; border-color: var(--chinh); }
.nut.chinh:hover { background: var(--chinh-dam); }
.nut.nho-nut { padding: 3px 8px; font-size: .85rem; }
.nut.xoa { color: var(--do); }
.nut:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--vien); border-radius: 6px; width: 100%; background: #fff; color: var(--chu); }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc2e8; border-color: var(--chinh); }
label { display: grid; gap: 3px; font-size: .9rem; color: var(--nhat); }
label.chon { display: flex; align-items: center; gap: 6px; color: var(--chu); }
label.chon input { width: auto; }
.luoi-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 14px; }
.luoi-form.hep { max-width: 420px; grid-template-columns: 1fr; }
.luoi-form .rong { grid-column: 1 / -1; }
.hang-nut { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.bo-loc { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 12px; }
.bo-loc label { min-width: 140px; }
.bo-loc .nhanh { display: flex; gap: 4px; flex-wrap: wrap; }

/* Bảng */
.cuon { overflow-x: auto; border: 1px solid var(--vien); border-radius: 6px; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: 6px 9px; border-bottom: 1px solid #e8ebef; text-align: left; vertical-align: top; }
th { background: #f0f4f8; position: sticky; top: 0; font-weight: 600; white-space: nowrap; }
td.so, th.so { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #f8fafc; }
#bang-bc td:nth-child(2), #bang-don td:nth-child(1) { min-width: 140px; }
tfoot td { font-weight: 700; background: #fff8e1; border-top: 2px solid var(--vang); }
.trong { text-align: center; color: var(--nhat); padding: 24px; }
.nhan { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.nhan.truyen_thong { background: #fff1d6; color: var(--tt); }
.nhan.dien_tu { background: #d9f2f4; color: var(--dt); }
.nhan.ngung { background: #eee; color: #777; }
.nhan.loai-0 { background: #dbe9f7; color: var(--chinh); }
.nhan.loai-1 { background: #d9f2e0; color: var(--xanh); }
.nhan.loai-2 { background: #fde4e1; color: var(--do); }
.nhan.loai-3 { background: #eee3f7; color: #6a3d8f; }

.tom-tat { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 12px; }
.o-so { background: #f6f9fc; border: 1px solid var(--vien); border-radius: 8px; padding: 10px 12px; }
.o-so .nhan-so { font-size: .82rem; color: var(--nhat); }
.o-so .gia-tri { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Tệp */
.vung-tha { border: 2px dashed #a9bcd2; border-radius: 8px; padding: 18px; text-align: center; background: #f8fbff; color: var(--nhat); }
.vung-tha.dang-keo { background: #e5f0fb; border-color: var(--chinh); }
.luoi-tep { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-top: 12px; }
.o-tep { border: 1px solid var(--vien); border-radius: 8px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.o-tep .anh { height: 130px; background: #eef1f5 center/cover no-repeat; display: grid; place-items: center; color: var(--nhat); font-weight: 700; font-size: 1.1rem; }
.o-tep .tt { padding: 8px; font-size: .84rem; display: grid; gap: 2px; flex: 1; }
.o-tep .tt b { word-break: break-word; }
.o-tep .hang-nut { margin: 0; padding: 0 8px 8px; justify-content: flex-start; }

/* Khung mảng chưa làm */
.khung-trong { border: 2px dashed var(--vien); border-radius: 8px; padding: 20px; color: var(--nhat); background: #fafbfc; }
.khung-trong ul { margin: 8px 0 0; }

dialog { border: 0; border-radius: 10px; padding: 20px; width: min(860px, calc(100vw - 32px)); max-height: calc(100vh - 32px); box-shadow: 0 10px 40px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(10, 25, 45, .45); }

.thong-bao { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1d2733; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 50; max-width: calc(100vw - 32px); }
.thong-bao.loi-tb { background: var(--do); }

@media (max-width: 800px) {
  .bo-cuc { grid-template-columns: 1fr; }
  .menu-trai { position: static; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
  .menu-trai .nhom-menu { grid-column: 1 / -1; }
  .tab-chinh .phu { margin-left: 0; }
  .dau { flex-direction: column; gap: 0; }
  .ten-pm { padding: 8px 0 0; }
  .tab-chinh { flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; }
  .tab-chinh button { padding: 10px 10px; }
}
@media print {
  .dau, .menu-trai, .bo-loc, .nut, .hang-nut { display: none !important; }
  .bo-cuc { grid-template-columns: 1fr; }
  .the { border: 0; padding: 0; }
  body { background: #fff; }
}

.o-ngay { width: 100%; max-width: 150px; }
.o-ngay.o-sai { border-color: var(--do); background: #fff3f2; }
/* Minh hoạ BHXH */
.luoi-form label.o-chon { display: flex; align-items: center; gap: 6px; align-self: end; padding-bottom: 8px; color: var(--chu); }
.luoi-form label.o-chon input { width: auto; }
#mh-kq table.tt td:first-child { width: 34%; color: var(--nhat); }
#mh-kq tr.dam td { background: #fff8e1; }
#mh-ts h4 { margin: 14px 0 4px; }
#mh-ts table input { padding: 4px 6px; }

/* Tab con trong một mục (VD Minh hoạ & bảng tính phí) */
.tab-con { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 2px solid var(--vien); margin-bottom: 14px; }
.tab-con button { font: inherit; padding: 8px 14px; border: 1px solid transparent; border-bottom: none; border-radius: 6px 6px 0 0; background: none; cursor: pointer; color: var(--chu); margin-bottom: -2px; }
.tab-con button:hover { color: var(--chinh); }
.tab-con button.dang-chon { background: var(--the); border-color: var(--vien); border-bottom: 2px solid var(--the); color: var(--chinh); font-weight: 600; }
.vung-muc > [data-noi-dung-con], .vung-muc > .tab-con { min-width: 0; }
.vung-muc > [data-noi-dung-con] { display: grid; gap: 16px; }

/* Biểu đồ Báo cáo ngày */
.luoi-bd-bcn { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 16px; margin-bottom: 16px; }
.bd-bcn svg { width: 100%; height: auto; display: block; }
.bd-bcn .truc { font-size: 11px; fill: var(--nhat); }
.bd-bcn .nhan-bd { font-size: 12px; fill: var(--chu); }
.chu-thich-bd { display: flex; gap: 16px; flex-wrap: wrap; font-size: .85rem; color: var(--nhat); margin-bottom: 6px; }
.chu-thich-bd i, .tt-bcn i { display: inline-block; width: 14px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.tt-bcn { position: fixed; display: none; z-index: 1000; pointer-events: none; background: #fff; color: var(--chu); border: 1px solid var(--vien); border-radius: 6px; padding: 8px 10px; font-size: .85rem; box-shadow: 0 4px 14px rgba(0,0,0,.12); max-width: 320px; }
.tt-bcn i { width: 10px; }
.luoi-bd-bcn > :first-child { grid-column: 1 / -1; }
