/* =============================================================
   Phan mem thi dua THCS - giao dien tieng Viet, uu tien dien thoai
   (Chuong V va Chuong VII: responsive, khong can cai ung dung)
   ============================================================= */
:root {
  --navy: #12507f;          /* mau chu dao - xanh muc, diu mat khi nhin lau */
  --navy-dark: #0c3b60;
  --navy-soft: #e8eff6;     /* nen nhat cua mau chu dao */
  --navy-line: #cfe0ee;
  --red: #b83227;
  --green: #1b7a45;
  --amber: #a9690b;
  --bg: #f1f4f8;
  --card: #fff;
  --line: #e3e8ee;
  --line-soft: #edf1f5;
  --text: #1c2531;
  --muted: #667283;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 16px -10px rgba(16, 24, 40, .22);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .07);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--navy); }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* ------------------------------ Khung ------------------------------ */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-dark) 100%);
  color: #fff; padding: 10px 14px; box-shadow: 0 1px 0 rgba(255, 255, 255, .08) inset;
  display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30;
}
.topbar h1 {
  font-size: 16px; margin: 0; font-weight: 600; flex: 1; line-height: 1.25;
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0;
}
.topbar .sub { display: block; font-size: 12px; opacity: .82; font-weight: 400; }
.topbar .scope { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.icon-btn {
  background: rgba(255,255,255,.14); border: 0; color: #fff; width: 38px; height: 38px;
  border-radius: 10px; font-size: 17px; line-height: 1; cursor: pointer; position: relative;
  flex: none; padding: 0;
  /* Can giua bieu tuong theo ca hai chieu trong khung nut */
  display: inline-flex; align-items: center; justify-content: center;
}
/* O chon nam hoc tren thanh dieu huong */
.year-picker {
  background: rgba(255,255,255,.14); color: #fff; border: 0; border-radius: 10px;
  height: 38px; padding: 0 8px; font-size: 13px; font-weight: 600; font-family: inherit;
  flex: none; max-width: 150px; cursor: pointer;
}
.year-picker:disabled { cursor: default; opacity: 1; }
.year-picker option { color: var(--ink); background: #fff; font-weight: 400; }
.year-picker:hover:not(:disabled) { background: rgba(255,255,255,.24); }

.icon-btn:hover { background: rgba(255,255,255,.24); }
.icon-btn .badge {
  position: absolute; top: -4px; right: -4px; background: var(--red); color: #fff;
  font-size: 11px; min-width: 18px; height: 18px; border-radius: 9px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
}
/* Nut tron do de xoa, dat o cuoi dong tieu chi va canh ten nhom */
.circle-del {
  width: 26px; height: 26px; padding: 0; flex: none;
  border: 0; border-radius: 50%; cursor: pointer;
  background: var(--red); color: #fff;
  font-size: 18px; font-weight: 700; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  vertical-align: middle;
}
.circle-del:hover { filter: brightness(1.12); }
.circle-del:active { transform: translateY(1px); }
h2.with-del { display: flex; align-items: center; gap: 10px; }

/* O nhap so lan kem hai nut +/- du to de bam bang ngon tay */
.stepper { display: inline-flex; align-items: center; gap: 6px; }
.stepper .step {
  width: 46px; height: 46px; padding: 0; flex: none;
  font-size: 26px; font-weight: 700; line-height: 1;
  background: var(--navy); color: #fff; border: 0; border-radius: 9px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.stepper .step:hover { filter: brightness(1.15); }
.stepper .step:active { transform: translateY(1px); }
.stepper .times {
  width: 64px; min-width: 64px; height: 46px; margin: 0; padding: 0 4px;
  text-align: center; font-size: 19px; font-weight: 600;
}
/* O tich cho tieu chi chi ghi duoc 1 lan/ngay */
.times.tick { width: 30px; height: 30px; margin: 0; accent-color: var(--navy); cursor: pointer; }

/* Moi o nhap so trong ung dung: mui ten tang giam cua trinh duyet qua nho nen
   phong to o len cho de bam bang ngon tay. */
input[type="number"] {
  min-height: 44px; font-size: 16px;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  opacity: 1; height: 38px; width: 22px; cursor: pointer;
}
/* Dong bang thi can giua theo chieu doc cho khoi le dong */
tr.mid td { vertical-align: middle; }

/* Bo mui ten ti hon san co cua trinh duyet, da co nut +/- thay the */
.stepper .times::-webkit-outer-spin-button,
.stepper .times::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper .times { -moz-appearance: textfield; }

/* O chon vai o ngoai cung ben trai thanh tren */
/* Nam ngay duoi dong ten noi phu trach, nen thap va gon hon nut bieu tuong */
.seat-picker {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  background: rgba(255, 255, 255, .14); border-radius: 8px; height: 26px; padding: 0 7px;
}
.seat-picker:hover { background: rgba(255, 255, 255, .24); }
.seat-ico {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: #fff; stroke-width: 1.9; stroke-linecap: round;
}
.seat-picker select {
  background: transparent; border: 0; color: #fff; font-size: 12.5px; font-weight: 600;
  font-family: inherit; padding: 0; width: auto; max-width: 120px; cursor: pointer;
}
.seat-picker select:focus { outline: none; box-shadow: none; }
.seat-picker select option { color: var(--text); background: #fff; font-weight: 400; }

/* Dai nhac khi dang lam viec duoi vai nguoi khac - phai thay ngay, khong the bo qua */
.acting-bar {
  background: #fdf6ea; border-bottom: 1px solid #f0dcb8; color: #7a4c06;
  padding: 9px 14px; font-size: 13.5px;
  position: sticky; top: 58px; z-index: 29;
}

/* Luoi hai cot cho bang dai, tu xep lai mot cot tren dien thoai */
.split2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 14px; }
.split2 .table-wrap { margin: 0; }

.layout { flex: 1; display: flex; }
.sidebar {
  width: 232px; background: #fff; border-right: 1px solid var(--line); padding: 12px 8px;
  flex: none;
}
.sidebar a {
  display: block; padding: 10px 12px; border-radius: 9px; text-decoration: none;
  color: var(--text); font-size: 14px; margin-bottom: 2px;
}
.sidebar a {
  border-left: 3px solid transparent; transition: background .12s ease, color .12s ease;
}
.sidebar a:hover { background: var(--line-soft); }
.sidebar a.active {
  background: var(--navy-soft); color: var(--navy-dark); font-weight: 600;
  border-left-color: var(--navy);
}
.sidebar .group { font-size: 11px; text-transform: uppercase; color: var(--muted);
  padding: 12px 12px 4px; letter-spacing: .04em; }
main { flex: 1; padding: 16px; max-width: 1180px; width: 100%; }
/* Nut menu chi co tac dung tren dien thoai - man hinh rong da hien san menu ben trai */
#btn-menu { display: none; }
@media (max-width: 860px) {
  #btn-menu { display: inline-flex; }
  .sidebar { display: none; }
  .sidebar.open {
    display: block; position: fixed; inset: 56px 0 0 0; width: 100%; z-index: 25; overflow-y: auto;
  }
  main { padding: 12px 12px 84px; }
}

/* Thanh dieu huong duoi cho dien thoai */
.tabbar { display: none; }
@media (max-width: 860px) {
  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: #fff;
    border-top: 1px solid var(--line); z-index: 26; padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a {
    flex: 1; text-align: center; padding: 8px 2px; font-size: 11px; text-decoration: none;
    color: var(--muted);
  }
  .tabbar a.active { color: var(--navy); font-weight: 600; }
  .tabbar .ico { display: block; font-size: 19px; line-height: 1.2; }
}

/* ------------------------------ Thanh phan ------------------------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card h2 {
  margin: 0 0 12px; font-size: 16px; color: var(--navy-dark);
  display: flex; align-items: center; gap: 8px;
}
/* Gach mau nho truoc tieu de khung - du de phan doan, khong loe loet */
.card h2::before {
  content: ''; width: 4px; height: 17px; border-radius: 3px;
  background: var(--navy); flex: none;
}
.card h3 { margin: 0 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; }
.page-title { font-size: 21px; margin: 0 0 4px; letter-spacing: -.01em; }
.page-desc { color: var(--muted); margin: 0 0 14px; font-size: 13px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 180px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 15px; box-shadow: var(--shadow-sm);
}
.stat .v { font-size: 24px; font-weight: 700; }
.stat .l { font-size: 12px; color: var(--muted); }
.stat.good .v { color: var(--green); } .stat.bad .v { color: var(--red); }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea, button { font-family: inherit; font-size: 15px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #d5dce4; border-radius: 10px;
  background: #fff; color: var(--text); transition: border-color .12s ease, box-shadow .12s ease;
}
input:hover, select:hover, textarea:hover { border-color: #bcc7d3; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px var(--navy-soft);
}
textarea { min-height: 80px; resize: vertical; }
.field { margin-bottom: 12px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

button, .btn {
  border: 1px solid transparent; border-radius: 10px; padding: 10px 16px; cursor: pointer;
  font-weight: 600; background: var(--navy); color: #fff; text-decoration: none;
  display: inline-block; text-align: center; box-shadow: var(--shadow-sm);
  transition: background .12s ease, transform .06s ease, box-shadow .12s ease;
}
button:hover, .btn:hover { background: var(--navy-dark); }
button:active, .btn:active { transform: translateY(1px); box-shadow: none; }
button:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
button:disabled:hover { background: var(--navy); }
.btn-ghost {
  background: #fff; color: var(--navy-dark); border-color: #d5dce4; box-shadow: none;
}
.btn-ghost:hover { background: var(--navy-soft); border-color: var(--navy-line); }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #9d2a20; }
.btn-green { background: var(--green); }
.btn-green:hover { background: #156237; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-block { display: block; width: 100%; }
.btn-lg { padding: 15px 20px; font-size: 17px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 10px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: top; }
th {
  color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
  background: #f7f9fb; border-bottom: 1px solid var(--line); white-space: nowrap;
}
th:first-child { border-top-left-radius: 10px; }
th:last-child { border-top-right-radius: 10px; }
td.n, th.n { text-align: center; }
tbody tr:nth-child(even) { background: #fcfdfe; }
tbody tr:hover { background: var(--navy-soft); }
tbody tr:last-child td { border-bottom: 0; }
.table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
}

.tag {
  display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600;
  background: var(--navy-soft); color: var(--navy-dark);
}
.tag.red { background: #fdecea; color: var(--red); }
.tag.green { background: #e6f4ea; color: var(--green); }
.tag.amber { background: #fdf3e2; color: var(--amber); }
.tag.gray { background: #eef0f2; color: var(--muted); }

.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.list-item {
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; margin-bottom: 9px;
  background: #fff;
}
.list-item .top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.list-item .meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.pts { font-weight: 700; font-size: 16px; white-space: nowrap; }
.pts.minus { color: var(--red); } .pts.plus { color: var(--green); }

/* Dai thong bao: mot vien mau ben trai la du nhan ra, khong can to ca khoi */
.banner {
  padding: 11px 14px; border-radius: 10px; margin-bottom: 12px; font-size: 14px;
  border: 1px solid transparent; border-left-width: 4px;
}
.banner.info { background: #eef4fa; border-color: var(--navy-line); border-left-color: var(--navy); color: var(--navy-dark); }
.banner.warn { background: #fdf6ea; border-color: #f0dcb8; border-left-color: var(--amber); color: #7a4c06; }
.banner.error { background: #fdefed; border-color: #f2ccc7; border-left-color: var(--red); color: #8e2019; }
.banner.ok { background: #edf7f1; border-color: #c6e4d3; border-left-color: var(--green); color: #125b33; }
.banner a { color: inherit; font-weight: 600; }

.evidence { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); margin-top: 8px; }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; }

/* Man hinh dang nhap */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 18px;
  background: linear-gradient(160deg, var(--navy) 0%, #123f66 60%, #0a2c4a 100%); }
.login-card { background: #fff; border-radius: 16px; padding: 26px 22px; width: 100%; max-width: 400px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.login-card h1 { font-size: 19px; margin: 0 0 2px; text-align: center; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 18px; }

/* Toast */
.toast-area { position: fixed; left: 12px; right: 12px; bottom: 74px; z-index: 60; display: flex;
  flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #23303f; color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 14px;
  max-width: 520px; box-shadow: var(--shadow); }
.toast.error { background: var(--red); } .toast.ok { background: var(--green); }
@media (min-width: 861px) { .toast-area { bottom: 20px; } }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,32,.55); z-index: 70; display: flex;
  align-items: flex-end; justify-content: center; padding: 0; }
.modal {
  background: #fff; border-radius: 16px 16px 0 0; padding: 18px; width: 100%; max-width: 560px;
  max-height: 92vh; overflow-y: auto;
}
@media (min-width: 700px) {
  .modal-bg { align-items: center; padding: 20px; }
  .modal { border-radius: 16px; }
}
.modal h2 { margin: 0 0 12px; font-size: 17px; }
.modal-actions { display: flex; gap: 9px; margin-top: 16px; }
.modal-actions button { flex: 1; }

/* Nhap nhanh cho Co do (muc 5.5) */
.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 9px 14px;
  font-size: 14px; cursor: pointer; font-weight: 500; color: var(--text);
}
.chip.sel { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip.minus.sel { background: var(--red); border-color: var(--red); }
.chip.plus.sel { background: var(--green); border-color: var(--green); }
.chip-group-title { font-size: 12px; text-transform: uppercase; color: var(--muted); margin: 12px 0 6px; }

/* Cot "Phan cong cham" - the ten lop va o "+" bo vua du be ngang */
.assign-cell { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.assign-cell .tag { white-space: nowrap; padding: 4px 9px; }
.assign-cell .rm { color: inherit; text-decoration: none; font-weight: 700; margin-left: 3px; }
.assign-cell select.add {
  width: auto; min-width: 44px; padding: 4px 6px; font-size: 13px; font-weight: 700;
  color: var(--navy); border-style: dashed; cursor: pointer;
}
.assign-cell select.add:disabled { opacity: .45; cursor: not-allowed; }

/* Bang xep hang cong khai (chieu tivi) */
.public-wrap { max-width: 1100px; margin: 0 auto; padding: 18px; }
.public-head { text-align: center; margin-bottom: 16px; }
.public-head h1 { margin: 0 0 4px; color: var(--navy); font-size: 24px; }
.rank-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; background: #fff;
  border: 1px solid var(--line); border-radius: 11px; margin-bottom: 8px; }
.rank-no { width: 42px; height: 42px; border-radius: 50%; background: #eef2f7; color: var(--navy);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px; flex: none; }
.rank-row.top1 .rank-no { background: #f1c40f; color: #614a02; }
.rank-row.top2 .rank-no { background: #cfd6dd; }
.rank-row.top3 .rank-no { background: #e0a878; color: #4a2c0c; }
.rank-name { flex: 1; font-weight: 600; }
.rank-name small { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; }
.rank-score { font-size: 19px; font-weight: 700; color: var(--navy); }
body.tv { background: #08243d; }
body.tv .public-wrap { max-width: none; }
body.tv .public-head h1, body.tv .public-head p { color: #fff; }
body.tv .rank-row { background: rgba(255,255,255,.96); padding: 16px 20px; font-size: 20px; }
body.tv .rank-score { font-size: 26px; }

@media print {
  .topbar, .sidebar, .tabbar, .no-print { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 0; }
}
