* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #f3f4f6; color: #111827;
}
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; }

/* đăng nhập */
#login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
#login-form { background: #fff; padding: 24px; border-radius: 12px; width: 100%; max-width: 320px; box-shadow: 0 2px 12px rgba(0,0,0,.08); }
.login-ten { font-size: 20px; font-weight: 600; margin: 0 0 16px; }
#login-form label { display: block; margin-bottom: 6px; color: #4b5563; }
#pin { width: 100%; padding: 12px; font-size: 22px; letter-spacing: 4px; border: 1px solid #d1d5db; border-radius: 8px; }
#login-form button { width: 100%; margin-top: 12px; padding: 12px; border: 0; border-radius: 8px; background: #1f2937; color: #fff; font-size: 17px; }
#login-msg { color: #b91c1c; min-height: 1.4em; margin: 10px 0 0; }

/* khung chính */
.dau { position: sticky; top: 0; z-index: 5; }
header {
  background: #1f2937; color: #fff;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
}
header h1 { font-size: 16px; margin: 0; font-weight: 600; }
#sync { font-size: 12px; color: #d1d5db; text-align: right; }
#sync.loi { color: #fca5a5; }
nav { display: flex; background: #fff; border-bottom: 1px solid #e5e7eb; }
nav button { flex: 1; padding: 11px 4px; border: 0; background: none; color: #4b5563; border-bottom: 3px solid transparent; }
nav button.chon { color: #111827; font-weight: 600; border-bottom-color: #dc2626; }
#dem-loi:not(:empty) { background: #dc2626; color: #fff; border-radius: 10px; padding: 0 7px; font-size: 13px; }
main { padding: 10px 10px 80px; max-width: 760px; margin: 0 auto; }
h2 { font-size: 17px; margin: 22px 4px 8px; }
.tongket { margin: 4px 4px 10px; color: #374151; }
.han { margin: 4px 4px 10px; padding: 8px 10px; background: #fef3c7; border-radius: 8px; color: #78350f; }
.nho { font-size: 13px; color: #6b7280; }

/* nhóm mục */
details.muc { background: #fff; border-radius: 10px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
details.muc > summary { list-style: none; cursor: pointer; padding: 13px 14px; display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
details.muc > summary::-webkit-details-marker { display: none; }
details.muc > summary::after { content: "+"; color: #9ca3af; margin-left: 6px; }
details.muc[open] > summary::after { content: "-"; }
.dem { font-weight: 400; color: #6b7280; white-space: nowrap; }
.dem.co-loi { color: #b91c1c; }
.khi-nao { margin: 0 14px 8px; font-size: 14px; color: #6b7280; }

/* thẻ mục kiểm */
.the { border-top: 1px solid #f0f0f0; padding: 12px 14px; background: #fff; border-left: 4px solid transparent; }
.the.tt-ok { border-left-color: #16a34a; }
.the.tt-loi { border-left-color: #dc2626; background: #fff7f7; }
.the.tt-kc { border-left-color: #9ca3af; }
.the .ten { font-weight: 600; }
.the .cach { font-size: 14px; color: #4b5563; margin-top: 3px; }
.nut-tt { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.nut-tt button.tt { padding: 7px 14px; border: 1px solid #d1d5db; border-radius: 18px; background: #fff; color: #374151; }
.nut-tt button.ok.chon { background: #16a34a; border-color: #16a34a; color: #fff; }
.nut-tt button.loi.chon { background: #dc2626; border-color: #dc2626; color: #fff; }
.nut-tt button.kc.chon { background: #6b7280; border-color: #6b7280; color: #fff; }
.nut-phu { display: inline-block; padding: 7px 12px; border: 1px dashed #9ca3af; border-radius: 18px; background: none; color: #374151; cursor: pointer; font-size: 14px; }
.chi-tiet { margin-top: 10px; }
textarea, .truong input, .them-muc input, .them-muc select {
  width: 100%; padding: 9px 10px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff;
}
textarea { resize: vertical; min-height: 54px; }
.anh { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.thumbs:empty { display: none; }
.thumb { width: 84px; height: 84px; padding: 0; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; background: #111; position: relative; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb span { position: absolute; left: 4px; bottom: 4px; background: rgba(0,0,0,.65); color: #fff; font-size: 11px; padding: 1px 5px; border-radius: 4px; }
.tien-do { width: 100%; font-size: 13px; color: #1d4ed8; }
.tien-do.loi { color: #b91c1c; }
.nut-xoa { margin-top: 8px; padding: 6px 12px; border: 1px solid #fca5a5; border-radius: 18px; background: #fff; color: #b91c1c; font-size: 14px; }

/* thêm mục tự đặt */
.them-muc { padding: 12px 14px; border-top: 1px solid #f0f0f0; display: flex; gap: 6px; }
.them-muc button { flex: none; padding: 8px 14px; border: 0; border-radius: 8px; background: #374151; color: #fff; }

/* tab gara */
.nut-chinh { display: block; width: 100%; padding: 12px; margin: 4px 0 12px; border: 0; border-radius: 10px; background: #1f2937; color: #fff; font-size: 16px; }
.danh-sach { background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.ghi { margin-top: 4px; white-space: pre-wrap; }
.ghi.trong { color: #9ca3af; font-style: italic; }
.tick { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; }
.tick input { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.tick.xong span { color: #6b7280; text-decoration: line-through; }
.viec-gara { background: #fff; border-radius: 10px; padding: 6px 14px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }

/* tab thông tin */
.truong { display: block; margin: 0 4px 12px; }
.truong span { display: block; font-size: 14px; color: #4b5563; margin-bottom: 4px; }
.khoi { background: #fff; border-radius: 10px; padding: 10px 14px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.khoi ul { margin: 0; padding-left: 20px; }
.hang-nut { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 4px; }

/* xem ảnh, video */
#viewer { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.92); display: flex; flex-direction: column; }
.xem-thanh { display: flex; gap: 8px; align-items: center; padding: 10px; padding-top: max(10px, env(safe-area-inset-top)); color: #e5e7eb; font-size: 14px; }
.xem-thanh span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xem-thanh button { padding: 8px 14px; border: 0; border-radius: 8px; background: #374151; color: #fff; }
.xem-thanh button.xoa { background: #991b1b; }
.xem-noi-dung { flex: 1; display: flex; align-items: center; justify-content: center; overflow: auto; }
.xem-noi-dung img, .xem-noi-dung video { max-width: 100%; max-height: 100%; }
