:root {
  --cam: #f07c1f;
  --cam-dam: #d4630b;
  --xanh: #3a9d3f;
  --xanh-dam: #2a7a2f;
  --kem: #fff8ee;
  --chu: #2b2b2b;
  --mo: #6b6b6b;
  --vien: #ead9c4;
  --toi: #26282c;
  --toi-2: #33363b;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  color: var(--chu);
  background: var(--kem);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }

/* ===== Đăng nhập ===== */
.man { min-height: 100%; }
#manDangNhap { display: grid; place-items: center; padding: 24px 16px; }
.the-dang-nhap {
  width: 100%; max-width: 380px; background: #fff; border-radius: 18px;
  padding: 32px 26px 24px; box-shadow: 0 10px 30px rgba(120, 70, 20, .12);
  border-top: 6px solid var(--cam); text-align: center;
}
.logo-to { width: 84px; height: 84px; object-fit: contain; }
.the-dang-nhap h1 { margin: 8px 0 2px; font-size: 26px; color: var(--cam-dam); }
.phu { margin: 0 0 22px; color: var(--xanh-dam); font-weight: 500; font-size: 14px; }
.the-dang-nhap label { display: block; text-align: left; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
#oMa {
  width: 100%; padding: 12px 14px; font-size: 17px; border: 2px solid var(--vien);
  border-radius: 10px; outline: none; font-family: inherit; letter-spacing: .5px;
}
#oMa:focus { border-color: var(--cam); }
.nut-chinh {
  width: 100%; margin-top: 14px; padding: 12px; border: 0; border-radius: 10px;
  background: var(--xanh); color: #fff; font-weight: 700; font-size: 16px;
}
.nut-chinh:hover { background: var(--xanh-dam); }
.nut-chinh:disabled { opacity: .6; cursor: wait; }
.loi { color: #c62828; min-height: 20px; font-size: 14px; margin: 10px 0 0; }
.ghi-chu { color: var(--mo); font-size: 12.5px; margin: 8px 0 0; }

/* ===== Thư viện ===== */
.thanh-tren {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: #fff; border-bottom: 3px solid var(--cam); position: sticky; top: 0; z-index: 5;
}
.logo-nho { width: 40px; height: 40px; object-fit: contain; }
.tieu-de { flex: 1; display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.tieu-de strong { color: var(--cam-dam); font-size: 17px; }
.tieu-de span { color: var(--mo); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nut-phu {
  border: 1.5px solid var(--vien); background: #fff; border-radius: 8px; padding: 6px 14px; color: var(--chu);
}
.nut-phu:hover { border-color: var(--cam); color: var(--cam-dam); }
.duong-dan { max-width: 960px; margin: 16px auto 0; padding: 0 16px; font-size: 14px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.duong-dan button { border: 0; background: none; color: var(--xanh-dam); padding: 2px 4px; font-weight: 600; }
.duong-dan button:hover { text-decoration: underline; }
.duong-dan .hien-tai { font-weight: 700; color: var(--chu); padding: 2px 4px; }
.duong-dan .cham { color: var(--mo); }
.danh-sach { max-width: 960px; margin: 12px auto 40px; padding: 0 16px; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.muc {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  background: #fff; border: 1.5px solid var(--vien); border-radius: 12px; padding: 14px;
  transition: border-color .15s, transform .15s, box-shadow .15s; color: var(--chu);
}
.muc:hover { border-color: var(--cam); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(120, 70, 20, .1); }
.muc .bieu { flex: none; width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #fff; }
.muc .bieu.thu-muc { background: var(--cam); font-size: 20px; }
.muc .bieu.pdf { background: #d84b3c; }
.muc .bieu.word, .muc .bieu.gdoc { background: #2f6bd8; }
.muc .bieu.ppt, .muc .bieu.gslide { background: #e08a1e; }
.muc .bieu.gsheet { background: var(--xanh); }
.muc .chu { min-width: 0; }
.muc .chu b { display: block; font-weight: 600; font-size: 15px; line-height: 1.35; word-break: break-word; }
.muc .chu small { color: var(--mo); font-size: 12.5px; }
.trong { grid-column: 1 / -1; text-align: center; color: var(--mo); padding: 40px 0; }
.khung-cho { grid-column: 1 / -1; display: grid; place-items: center; padding: 40px 0; }

/* ===== Trang xem ===== */
.man-xem { background: var(--toi); height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.thanh-xem {
  flex: none; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: #1d1f22; color: #fff;
}
.nut-quay { border: 0; background: #3a3d42; color: #fff; width: 38px; height: 38px; border-radius: 50%; font-size: 18px; }
.nut-quay:hover { background: var(--cam); }
.ten-tai-lieu { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vung-trang {
  flex: 1; overflow: auto; padding: 18px 12px 90px; outline: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.trang {
  position: relative; margin: 0 auto 16px; background: #fff; box-shadow: 0 4px 18px rgba(0, 0, 0, .45);
}
.trang canvas { display: block; width: 100%; height: 100%; pointer-events: none; }
.trang .so { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: #bbb; font-size: 14px; }
.trang canvas ~ .so { display: none; }
.trang .lop-che { position: absolute; inset: 0; }
.dang-tai {
  position: absolute; inset: 58px 0 0; display: grid; place-content: center; justify-items: center; gap: 12px;
  color: #ddd; font-size: 15px; background: var(--toi);
}
.vong, .khung-cho .vong { width: 38px; height: 38px; border: 4px solid rgba(240, 124, 31, .25); border-top-color: var(--cam); border-radius: 50%; animation: quay 0.9s linear infinite; }
@keyframes quay { to { transform: rotate(360deg); } }
.dieu-khien {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px; padding: 6px 10px;
  background: rgba(25, 26, 29, .92); color: #fff; border-radius: 999px; font-size: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .4); white-space: nowrap;
}
.dieu-khien button { border: 0; background: transparent; color: #fff; width: 34px; height: 34px; border-radius: 50%; font-size: 20px; line-height: 1; }
.dieu-khien button:hover { background: rgba(255, 255, 255, .14); }
#oTrang { width: 40px; text-align: center; border: 0; border-radius: 6px; background: #3a3d42; color: #fff; font: inherit; padding: 3px 0; }
#mucZoom { min-width: 44px; text-align: center; }
.vach { width: 1px; height: 22px; background: rgba(255, 255, 255, .25); margin: 0 4px; }

.thong-bao {
  position: fixed; left: 50%; top: 20px; transform: translateX(-50%); z-index: 50;
  background: #2b2b2b; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .3); max-width: calc(100% - 32px); text-align: center;
}

@media (max-width: 520px) {
  .danh-sach { grid-template-columns: 1fr; }
  .dieu-khien { gap: 2px; padding: 4px 8px; font-size: 13px; }
  .dieu-khien button { width: 30px; height: 30px; }
  .vung-trang { padding: 10px 6px 80px; }
}

/* Không cho in */
@media print {
  body * { display: none !important; }
  body::after { content: 'Tài liệu chỉ xem trực tuyến – không hỗ trợ in.'; display: block; padding: 40px; font-size: 18px; }
}
