:root {
  --bg: #f4f6f9; --card: #fff; --text: #1d2430; --muted: #687385; --line: #dde2ea;
  --primary: #1f5fa8; --primary-text: #fff; --ok: #1e7b46; --danger: #b3261e; --info-bg: #e8f0fb;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14171c; --card: #1d2128; --text: #e6e9ee; --muted: #9aa4b2; --line: #313844;
          --primary: #5b9be0; --primary-text: #0d1117; --ok: #5cc28a; --danger: #ef6b62; --info-bg: #1d2a3d; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); }
h1 { font-size: 1.4rem; margin: .5rem 0; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.container { max-width: 960px; margin: 0 auto; padding: 12px 16px 48px; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: var(--primary); color: var(--primary-text); }
.topbar .brand { color: var(--primary-text); text-decoration: none; font-weight: 600; }
.menu summary { list-style: none; cursor: pointer; font-size: 1.4rem; padding: 0 6px; }
.menu summary::-webkit-details-marker { display: none; }
.menu nav { position: absolute; right: 8px; top: 48px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); min-width: 240px; padding: 6px 0; box-shadow: 0 6px 20px rgba(0,0,0,.15); }
.menu nav a, .menu nav .linklike { display: block; padding: 10px 16px; color: var(--text); text-decoration: none;
  width: 100%; text-align: left; font: inherit; }
.menu nav a:hover, .menu nav .linklike:hover { background: var(--bg); }
.linklike { background: none; border: 0; cursor: pointer; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.card.narrow { max-width: 420px; margin: 32px auto; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
label { display: block; margin: 8px 0; font-size: .95rem; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; min-height: 44px; }
label.check { display: flex; align-items: center; gap: 8px; }
label.check input { width: auto; min-height: 0; margin: 0; }
.btn { display: inline-block; padding: 10px 16px; min-height: 44px; font: inherit; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--text); text-decoration: none; }
.btn.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn.block { width: 100%; margin-top: 12px; }
.btn.danger-outline { color: var(--danger); border-color: var(--danger); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.row input, .row select { width: auto; flex: 1 1 180px; margin: 0; }
.grid { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
@media (min-width: 640px) { .grid { grid-template-columns: 1fr 1fr; } .grid .btn { align-self: end; } }
.flash { padding: 10px 14px; border-radius: 8px; margin: 8px 0; background: var(--info-bg); }
.flash-ok { border-left: 4px solid var(--ok); }
.flash-error { border-left: 4px solid var(--danger); }
.flash-info { border-left: 4px solid var(--primary); }
.badge { display: inline-block; font-size: .75rem; padding: 1px 8px; border-radius: 99px; background: var(--info-bg); color: var(--primary); margin-left: 4px; }
.badge.ok { color: var(--ok); } .badge.danger { color: var(--danger); } .badge.muted { color: var(--muted); }
ul.plain { list-style: none; padding: 0; margin: 0; } ul.plain li { padding: 4px 0; }
ul.list { list-style: none; padding: 0; margin: 0; }
ul.list > li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
ul.list > li:last-child { border-bottom: 0; }
ul.tree { list-style: none; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
ul.tree li { padding: 10px 12px 10px calc(12px + var(--depth) * 20px); border-bottom: 1px solid var(--line); }
ul.tree li:last-child { border-bottom: 0; }
ul.tree li.inactive > a, ul.tree li.locked > a { color: var(--muted); }
.checklist label { padding-left: calc(var(--depth) * 20px); }
.inline-edit summary { cursor: pointer; color: var(--primary); }
.temp-password code { font-size: 1.6rem; letter-spacing: 2px; }
code { background: var(--bg); padding: 1px 6px; border-radius: 4px; }
.htmx-request { opacity: .6; transition: opacity .2s; }

/* ---------- Nhiệm vụ ---------- */
.row.between { justify-content: space-between; }
.section-title { margin-top: 20px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin: 8px 0; }
.tabs a { padding: 10px 12px; white-space: nowrap; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; }
.tabs a.active { color: var(--primary); border-color: var(--primary); font-weight: 600; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 8px; }
.chip { white-space: nowrap; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--card);
  text-decoration: none; color: var(--text); font-size: .9rem; }
.chip.active { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.chip.danger:not(.active) { color: var(--danger); border-color: var(--danger); }
ul.tasks { list-style: none; padding: 0; margin: 8px 0; }
ul.tasks li.task { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 8px; margin: 8px 0; }
ul.tasks li.task.overdue { border-left-color: var(--danger); }
ul.tasks li.task.soon { border-left-color: #d08a00; }
ul.tasks li.empty { padding: 12px 0; }
.task-link { display: block; padding: 10px 12px; color: var(--text); text-decoration: none; }
.task-title { font-weight: 600; }
.task-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 2px; }
.status { font-size: .78rem; padding: 1px 8px; border-radius: 99px; background: var(--info-bg); color: var(--primary); }
.s-tiep_nhan, .s-phan_loai { background: #eee6fb; color: #6a3fb5; }
.s-cho_nghiem_thu { background: #fff2d6; color: #8a5a00; }
.s-da_nghiem_thu, .s-da_dong { background: #e3f4ea; color: var(--ok); }
.due { font-size: .8rem; color: var(--muted); }
.due.late { color: var(--danger); font-weight: 600; }
.due.soon { color: #b37400; font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 12px 0; }
.stat { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
  text-decoration: none; color: var(--text); }
.stat b { display: block; font-size: 1.8rem; line-height: 1.1; }
.stat span { font-size: .85rem; color: var(--muted); }
.stat.danger b { color: var(--danger); } .stat.warn b { color: #b37400; }
.steps { list-style: none; display: flex; overflow-x: auto; gap: 4px; padding: 0; margin: 10px 0; counter-reset: s; }
.steps li { flex: 1 0 auto; font-size: .75rem; padding: 6px 8px; border-radius: 6px; background: var(--card); border: 1px solid var(--line);
  color: var(--muted); white-space: nowrap; counter-increment: s; }
.steps li::before { content: counter(s) ". "; }
.steps li.done { color: var(--ok); }
.steps li.current { background: var(--primary); color: var(--primary-text); border-color: var(--primary); font-weight: 600; }
.progress { position: relative; height: 22px; background: var(--card); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.progress span { display: block; height: 100%; background: var(--ok); opacity: .35; }
.progress b { position: absolute; inset: 0; text-align: center; font-size: .8rem; line-height: 20px; }
.card.warn { border-left: 4px solid #d08a00; }
.card.actions details { border-top: 1px solid var(--line); padding: 8px 0; }
.card.actions details summary { cursor: pointer; color: var(--primary); font-weight: 500; padding: 4px 0; }
.card.actions form { margin: 8px 0; }
dl.info { display: grid; grid-template-columns: 1fr; gap: 2px 12px; margin: 0; }
dl.info dt { color: var(--muted); font-size: .85rem; margin-top: 6px; }
dl.info dd { margin: 0; }
@media (min-width: 640px) { dl.info { grid-template-columns: 180px 1fr; } dl.info dt { margin-top: 0; } }
.pre { white-space: pre-wrap; }
ol.timeline { list-style: none; padding: 0 0 0 14px; margin: 0; border-left: 2px solid var(--line); }
ol.timeline li { position: relative; padding: 6px 0 10px 10px; }
ol.timeline li::before { content: ""; position: absolute; left: -21px; top: 12px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
ol.timeline li.ev-binh_luan::before { background: var(--muted); }
ol.timeline li.ev-tra_lai::before, ol.timeline li.ev-lam_lai::before, ol.timeline li.ev-dung::before { background: var(--danger); }
ol.timeline li.ev-nghiem_thu::before, ol.timeline li.ev-dong::before { background: var(--ok); }
details.more summary { cursor: pointer; color: var(--primary); margin: 12px 0 4px; }
textarea { resize: vertical; }

/* ---------- Thông báo, văn bản ---------- */
.topbar { gap: 8px; }
.topbar .brand { margin-right: auto; }
.bell { position: relative; color: var(--primary-text); text-decoration: none; font-size: 1.2rem; padding: 0 6px; }
.bell-count { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: .7rem; line-height: 18px; text-align: center; font-weight: 700; }
ul.notif > li { padding: 0; }
ul.notif > li > a { display: block; padding: 10px 4px; color: var(--text); text-decoration: none; width: 100%; }
ul.notif > li.unread { background: var(--info-bg); border-radius: 6px; }
ul.notif > li.unread .n-title { font-weight: 700; }
.doc-link { display: block; color: var(--text); text-decoration: none; width: 100%; }
.notice { font-weight: 600; }
label.confirm { align-items: flex-start; background: var(--info-bg); padding: 8px; border-radius: 8px; }
input[type=file] { padding: 8px; }
