:root {
  --brand: #1f4e79;
  --brand-2: #2e75b6;
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #5f6b7a;
  --line: #dde3ea;
  --neg: #c62828;
  --neg-bg: #fdecec;
  --radius: 10px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }

.topbar { position: sticky; top: 0; z-index: 10; background: var(--brand); color: #fff; padding: 10px 16px 0; }
.topbar-row { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.topbar h1 { margin: 0 0 8px; font-size: 18px; font-weight: 650; }
.link-btn { background: transparent; border: 1px solid #9fbbd6; color: #fff; border-radius: 8px; padding: 6px 12px; font: inherit; font-size: 14px; cursor: pointer; margin-bottom: 8px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tab { flex: 0 0 auto; border: 0; background: transparent; color: #cfe0f1; padding: 10px 14px; font: inherit; border-radius: 8px 8px 0 0; cursor: pointer; }
.tab.active { background: var(--bg); color: var(--brand); font-weight: 650; }

main { max-width: 1600px; margin: 0 auto; padding: 16px; }
.filters { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 550; min-width: 170px; }
.filters label.grow { flex: 1 1 240px; }
input, select { font: inherit; color: var(--text); padding: 8px 10px; border: 1px solid #c6cfda; border-radius: 8px; background: #fff; min-height: 40px; }
input:focus, select:focus { outline: 2px solid var(--brand-2); outline-offset: 0; }
#day { font-weight: 650; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.filters label.chk { flex-direction: row; align-items: center; gap: 6px; min-width: 0; color: var(--text); font-weight: 500; font-size: 14px; }
.chk input { min-height: 0; width: 18px; height: 18px; }
.actions { display: flex; gap: 8px; margin-left: auto; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 14px; border: 1px solid #c6cfda; border-radius: 8px; background: #fff; color: var(--text); font: inherit; font-weight: 550; cursor: pointer; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-block { width: 100%; }

.status { margin: 12px 2px 6px; color: var(--muted); }
.neg { color: var(--neg); font-weight: 650; }
.khobox { margin: 0 0 10px; }
.khobox summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: 14px; padding: 4px 2px; user-select: none; }
.khosum { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 0; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.chip.on { border-color: var(--brand); background: #e8f0f8; font-weight: 650; }

.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; overflow-anchor: none; height: calc(100vh - 300px); min-height: 380px; }
table { border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 13.5px; }
th, td { padding: 0 8px; border-bottom: 1px solid var(--line); text-align: left; }
/* chữ dài tự xuống dòng khi cột hẹp (không bị ẩn mất) */
td { padding: 6px 8px; line-height: 1.4; white-space: normal; overflow-wrap: anywhere; word-break: break-word; vertical-align: top; box-sizing: border-box; }
td.r { white-space: nowrap; }
/* tiêu đề cũng tự xuống dòng khi cột hẹp; dòng ô lọc dính ngay dưới (vị trí tính bằng JS theo chiều cao thật) */
th { position: sticky; top: 0; background: #eef2f7; font-size: 12.5px; color: #34404f; z-index: 2; height: 46px; padding: 6px 10px 6px 8px; line-height: 1.25; vertical-align: middle; white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
th.sortable { cursor: pointer; user-select: none; }
/* thanh kéo đổi độ rộng cột ở mép phải tiêu đề */
th .rs { position: absolute; top: 0; right: -4px; width: 9px; height: 100%; cursor: col-resize; z-index: 3; touch-action: none; }
th .rs::after { content: ""; position: absolute; left: 4px; top: 8px; bottom: 8px; width: 1px; background: #c3cddb; }
th .rs:hover::after, body.resizing th .rs::after { background: var(--brand-2); width: 3px; left: 3px; }
body.resizing, body.resizing * { cursor: col-resize !important; user-select: none !important; }
th.sortable:hover { background: #e2e9f2; }
th.sortable.on { color: var(--brand); background: #dde8f4; }
th .arrow { color: #8a97a8; font-size: 11px; white-space: nowrap; }
th.on .arrow { color: var(--brand); }
.fhead th { top: 46px; height: 38px; white-space: nowrap; padding: 4px 4px; background: #f6f8fb; z-index: 2; }
.fhead input { width: 100%; min-height: 30px; padding: 4px 6px; font-size: 12.5px; border-radius: 6px; }
tr.spacer td, tr.spacer { height: auto; padding: 0; border: 0; line-height: 0; }
tr.ph td { color: var(--muted); font-style: italic; }
td.r, th.r { text-align: right; }
td.r { white-space: nowrap; }
td.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; word-break: break-all; }
td small { color: var(--muted); }
tr.big td { background: #fafbfd; }
tr.neg-row td { background: var(--neg-bg); color: var(--neg); }
tr.neg-row td small { color: #a33; }
td.lai { font-weight: 650; }
.tag { background: #e6edf5; color: var(--brand); border-radius: 4px; padding: 0 4px; font-size: 11px; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 30px; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 12px 0; }
.note { color: var(--muted); font-size: 13px; max-width: 1100px; }

/* đăng nhập */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 24px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; text-align: center; }
.login-card img { margin: 0 auto; }
.login-card h1 { font-size: 18px; margin: 0; color: var(--brand); }
.login-card label { display: flex; flex-direction: column; gap: 4px; text-align: left; font-size: 14px; color: var(--muted); font-weight: 550; }
.msg { min-height: 1.2em; font-size: 14px; }
.msg.err { color: var(--neg); }
.hint { margin: 0; font-size: 13px; color: var(--muted); }

@media (max-width: 700px) {
  main { padding: 10px; }
  .filters label { min-width: 0; flex: 1 1 45%; }
  .actions { margin-left: 0; width: 100%; }
  .actions .btn { flex: 1; }
  .table-wrap { max-height: none; }
}

/* phần hướng dẫn thu gọn, bấm mới bung ra */
.notebox { margin: 10px 0; }
.notebox summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: 13.5px; padding: 4px 2px; user-select: none; }
.notebox .note { margin: 6px 0 0; }
