/* =============================================================
   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: #0f4c81;
  --navy-dark: #0b3a63;
  --red: #c0392b;
  --green: #1e8449;
  --amber: #b9770e;
  --bg: #f4f6f9;
  --card: #fff;
  --line: #dfe4ea;
  --text: #1f2733;
  --muted: #6b7684;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .06);
}

* { 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: var(--navy); color: #fff; padding: 10px 14px;
  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; }
.topbar .sub { display: block; font-size: 12px; opacity: .82; font-weight: 400; }
.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;
}
.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:hover { background: #eef2f7; }
.sidebar a.active { background: var(--navy); color: #fff; font-weight: 600; }
.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: 14px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 10px; font-size: 16px; }
.card h3 { margin: 0 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; }
.page-title { font-size: 20px; margin: 0 0 4px; }
.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: 12px 14px; }
.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 var(--line); border-radius: 9px;
  background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #a8c5e5; border-color: var(--navy); }
textarea { min-height: 80px; resize: vertical; }
.field { margin-bottom: 12px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

button, .btn {
  border: 0; border-radius: 9px; padding: 10px 16px; cursor: pointer; font-weight: 600;
  background: var(--navy); color: #fff; text-decoration: none; display: inline-block; text-align: center;
}
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: #eef2f7; color: var(--navy); }
.btn-danger { background: var(--red); }
.btn-green { background: var(--green); }
.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: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
td.n, th.n { text-align: center; }
tbody tr:hover { background: #fafbfc; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 600;
  background: #eef2f7; color: var(--navy);
}
.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); }

.banner { padding: 11px 13px; border-radius: 10px; margin-bottom: 12px; font-size: 14px; }
.banner.info { background: #e8f1fa; color: var(--navy-dark); }
.banner.warn { background: #fdf3e2; color: var(--amber); }
.banner.error { background: #fdecea; color: var(--red); }
.banner.ok { background: #e6f4ea; color: var(--green); }

.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; }
}
