/* Sao Phát Biểu — giao diện */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8f0;
  --border-strong: #cfd7e3;
  --text: #1c2333;
  --muted: #667085;
  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-50: #eef2ff;
  --star: #f59e0b;
  --star-600: #d97706;
  --star-50: #fff8e6;
  --ok: #16a34a;
  --ok-600: #15803d;
  --ok-50: #eafaf0;
  --warn: #d97706;
  --warn-50: #fff4e0;
  --danger: #dc2626;
  --danger-600: #b91c1c;
  --danger-50: #fdeeee;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 14px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 24px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; font-size: .92em; }
[hidden] { display: none !important; }
/* iPhone/Android: bấm nhanh liên tiếp (điểm danh, +1 sao) không bị hiểu là "chạm đúp để phóng to" màn hình.
   Vẫn cuộn và chụm 2 ngón để phóng to bình thường. */
html, body, a, button, summary, label, input, select, textarea, [role="button"], .att-grid, .teams { touch-action: manipulation; }
:focus-visible { outline: 3px solid rgba(79, 70, 229, .45); outline-offset: 2px; }

.container { max-width: 1320px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 560px; margin: 0 auto; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.mt { margin-top: 14px; }
.error { color: var(--danger); }
.inline { display: inline; margin: 0; }
.big-icon { font-size: 44px; line-height: 1; margin-bottom: 8px; }

/* ------------------------------------------------------------ thanh trên cùng */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 750; font-size: 17px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 11px;
  background: linear-gradient(140deg, #fcd34d, #f59e0b 55%, #ea580c);
  color: #fff; font-size: 20px;
  box-shadow: 0 3px 10px rgba(245, 158, 11, .35);
}
.brand-text small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.mainnav { display: flex; gap: 4px; }
.mainnav a {
  padding: 7px 12px; border-radius: 999px; color: var(--muted); font-weight: 600;
}
.mainnav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.mainnav a.active { background: var(--primary-50); color: var(--primary); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.top-clock {
  font-variant-numeric: tabular-nums; font-weight: 700;
  padding: 5px 10px; border-radius: 999px; background: var(--ok-50); color: var(--ok-600);
}
.top-clock.warn { background: var(--warn-50); color: var(--warn); }
.top-clock.danger { background: var(--danger-50); color: var(--danger); }
.page-board .top-clock { display: none; }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  width: 36px; height: 36px; font-size: 16px; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.conn-dot { width: 10px; height: 10px; border-radius: 50%; background: #cbd5e1; flex: none; }
.conn-dot[data-status="online"] { background: var(--ok); box-shadow: 0 0 0 3px rgba(22, 163, 74, .18); }
.conn-dot[data-status="offline"] { background: var(--danger); animation: blink 1s steps(2) infinite; }
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--text); padding: 3px 10px 3px 3px; border-radius: 999px; }
.user-chip:hover { background: var(--surface-2); text-decoration: none; }
.avatar {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 14px; flex: none;
}
.avatar-leader { background: var(--star-600); }
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-meta b { font-size: 14px; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta small { font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------ nút & biểu mẫu */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn-lg { min-height: 46px; padding: 0 20px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-success:hover { background: var(--ok-600); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-600); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-50); }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: #475467; }
.field > span em { font-weight: 400; color: var(--muted); font-style: normal; }
.field small { color: var(--muted); font-size: 12px; }
input, select, textarea {
  font: inherit; color: var(--text);
  width: 100%; min-height: 40px; padding: 8px 11px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: #fff;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--primary); flex: none; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.check span { padding-top: 1px; }
.help { margin: 0; font-size: 13px; color: var(--muted); }
.row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: start; }
.span-all { grid-column: 1 / -1; }
.align-end { align-self: end; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head h3 { margin: 0; }
.flash {
  padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 12px;
  background: var(--ok-50); color: var(--ok-600); border: 1px solid #bbe7c9; font-weight: 500;
}
.flash-error { background: var(--danger-50); color: var(--danger-600); border-color: #f5c2c2; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
  white-space: nowrap; vertical-align: middle;
}
.tag-leader { background: var(--star-50); color: var(--star-600); border-color: #fde3a7; }
.tag-teacher { background: var(--primary-50); color: var(--primary); border-color: #d9dcfb; }
.tag-mine { background: var(--primary); color: #fff; border-color: var(--primary); }
.tag-live { background: var(--ok-50); color: var(--ok-600); border-color: #bbe7c9; }

/* ------------------------------------------------------------ thanh tiết học */
.lesson-bar {
  position: sticky; top: 8px; z-index: 30;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 18px 12px; margin-bottom: 14px;
}
.lesson-bar.is-idle { position: relative; top: 0; }
.lesson-bar.is-active { border-color: #b7e4c7; background: linear-gradient(180deg, #f0fbf4, #fff 70%); }
.lb-main { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.lb-info { min-width: 0; }
.lb-status {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted);
}
.lb-dot { width: 10px; height: 10px; border-radius: 50%; background: #94a3b8; }
.is-active .lb-status { color: var(--ok-600); }
.is-active .lb-dot { background: var(--ok); animation: pulse 1.6s infinite; }
.lb-title { font-size: 21px; margin: 3px 0 2px; overflow-wrap: anywhere; }
.lb-meta { color: var(--muted); font-size: 13.5px; }
.lb-clock-wrap { text-align: right; flex: none; }
.lb-clock {
  font-size: 46px; font-weight: 800; line-height: 1; letter-spacing: .01em;
  font-variant-numeric: tabular-nums; color: var(--ok-600);
}
.lb-clock.warn { color: var(--warn); }
.lb-clock.danger { color: var(--danger); animation: blink 1s steps(2) infinite; }
.lb-clock.idle { color: #c3cad6; font-size: 32px; letter-spacing: .08em; }
.lb-clock-label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.lb-progress { height: 5px; margin-top: 12px; border-radius: 999px; background: #e7ebf1; overflow: hidden; }
.lb-progress span { display: block; height: 100%; width: 0; background: var(--ok); border-radius: inherit; transition: width .9s linear; }
.is-idle .lb-progress span { transition: none; }
.lb-progress span.warn { background: var(--warn); }
.lb-progress span.danger { background: var(--danger); }
.lb-controls {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px;
  margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border);
}
div.lb-controls { align-items: center; }
.lb-controls .field.grow { flex: 1 1 220px; }
.lb-controls .w-sm { width: 130px; }
.chips { display: flex; gap: 6px; padding-bottom: 2px; }
.chip {
  min-height: 40px; min-width: 46px; padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: 999px; background: #fff;
  font: inherit; font-weight: 600; cursor: pointer;
}
.chip:hover { background: var(--surface-2); }
.chip.active { background: var(--primary-50); border-color: var(--primary); color: var(--primary); }

.hint {
  margin: 0 0 14px; padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--star-50); border: 1px solid #fde3a7; color: #7a4a00;
}

/* ------------------------------------------------------------ bảng sao */
.board { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; align-items: start; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.section-head h2 { margin: 0; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-size: 13px; color: var(--muted); }
.legend-star { color: var(--star); }
.teams { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.team {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.team.mine { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50), var(--shadow); }
.team.loose { border-style: dashed; }
.team-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.team-title { min-width: 0; }
.team-head h3 { margin: 0; font-size: 16.5px; }
.team-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-score { text-align: right; flex: none; line-height: 1.1; }
.t-lesson-wrap { display: inline-flex; align-items: baseline; gap: 2px; color: var(--star-600); }
.t-lesson { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.t-lesson-wrap i, .m-count i { font-style: normal; }
.t-total { display: block; font-size: 12px; color: var(--muted); }
.members { list-style: none; margin: 0; padding: 4px 6px 6px; }
.member {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--radius-sm);
}
.member + .member { border-top: 1px solid #f0f3f7; }
.member.is-me { background: var(--primary-50); }
.member.star-hit { animation: star-hit 1.8s ease-out; }
.members .empty { padding: 12px 8px; color: var(--muted); font-size: 14px; }
.m-main { min-width: 0; }
.m-sub .tag { margin-right: 6px; padding: 0 6px; font-size: 11px; }
.m-name {
  padding: 0; border: 0; background: none;
  font: inherit; font-weight: 650; color: var(--text); text-align: left; cursor: pointer;
  overflow-wrap: anywhere;
}
.m-name:hover { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.m-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.m-sub b { color: #475467; }
.m-count {
  display: inline-flex; align-items: baseline; justify-content: flex-end; gap: 1px;
  min-width: 42px; font-size: 21px; font-weight: 800; color: var(--star);
  font-variant-numeric: tabular-nums;
}
.m-count.zero { color: #cfd6e1; }
.bump { display: inline-block; animation: bump .55s ease; }
.btn-star {
  min-height: 40px; padding: 0 13px; border-radius: 999px;
  border: 1px solid #f7b733; background: linear-gradient(180deg, #fde68a, #fbbf24);
  color: #5b3a00; font: inherit; font-weight: 800; white-space: nowrap; cursor: pointer;
  box-shadow: 0 2px 0 #e2a21f; transition: transform .06s, box-shadow .06s, filter .15s;
}
.btn-star:hover { filter: brightness(1.04); }
.btn-star:active { transform: translateY(2px); box-shadow: 0 0 0 #e2a21f; }
.btn-star:disabled { filter: grayscale(1); opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-star.off-lesson { background: #fff; border-style: dashed; box-shadow: none; }
.empty-state { text-align: center; padding: 34px 18px; grid-column: 1 / -1; }

/* cột bên: xếp hạng + hoạt động */
.board-side { display: flex; flex-direction: column; gap: 16px; }
.board-side .card { margin: 0; padding: 16px; }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.seg button {
  border: 0; background: none; font: inherit; font-size: 13px; font-weight: 600;
  padding: 4px 12px; border-radius: 999px; color: var(--muted); cursor: pointer;
}
.seg button.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(16, 24, 40, .12); }
.sub-head { margin: 16px 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.rank { list-style: none; margin: 0; padding: 0; }
.rank li { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.rank li + li { border-top: 1px solid #f0f3f7; }
.rank .empty { color: var(--muted); font-size: 14px; }
.r-pos { width: 26px; text-align: center; font-size: 18px; flex: none; }
.r-no { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 700; }
.r-name { flex: 1 1 auto; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-name small { font-weight: 500; }
.r-bar { flex: 0 0 34%; height: 8px; border-radius: 999px; background: #eef1f5; overflow: hidden; }
.r-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #fcd34d, #f59e0b); transition: width .5s ease; }
.r-val { min-width: 30px; text-align: right; font-variant-numeric: tabular-nums; }

.feed { list-style: none; margin: 0; padding: 0; max-height: 460px; overflow-y: auto; }
.feed li { display: flex; align-items: flex-start; gap: 10px; padding: 8px 2px; }
.feed li + li { border-top: 1px solid #f0f3f7; }
.feed .empty { color: var(--muted); font-size: 14px; display: block; }
.feed-item.new { animation: feed-in .6s ease; }
.f-icon { color: var(--star); font-size: 18px; line-height: 1.2; }
.f-body { flex: 1 1 auto; min-width: 0; }
.f-line { overflow-wrap: anywhere; }
.f-meta { font-size: 12.5px; color: var(--muted); }
.btn-undo {
  flex: none; border: 1px solid var(--border); background: #fff; color: var(--danger);
  font: inherit; font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; cursor: pointer;
}
.btn-undo:hover { background: var(--danger-50); border-color: #f5c2c2; }
.btn-undo:disabled { opacity: .5; }

/* hộp chi tiết học sinh */
.dialog {
  width: min(520px, calc(100vw - 24px)); max-height: min(640px, calc(100vh - 40px));
  padding: 0; border: 0; border-radius: var(--radius); box-shadow: var(--shadow-lg); color: var(--text);
}
.dialog::backdrop { background: rgba(15, 23, 42, .45); }
#studentDialogBody { padding: 20px 20px 16px; }
#studentDialogBody h2 { margin: 0 32px 2px 0; }
.dialog-close { position: absolute; top: 10px; right: 10px; margin: 0; }
.dialog-close button {
  width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--surface-2);
  font-size: 16px; cursor: pointer; color: var(--muted);
}
.dialog-close button:hover { background: var(--border); color: var(--text); }
.d-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.d-stats div { background: var(--star-50); border: 1px solid #fde3a7; border-radius: var(--radius-sm); padding: 10px 12px; }
.d-stats b { display: block; font-size: 26px; color: var(--star-600); line-height: 1.1; }
.d-stats span { font-size: 12.5px; color: var(--muted); }
.d-list { max-height: 330px; }

/* ------------------------------------------------------------ thông báo nổi */
/* Máy tính: góc dưới bên phải (không che đồng hồ); mới nhất nằm dưới cùng. */
.toasts {
  position: fixed; right: 12px; bottom: 12px; z-index: 1000;
  display: flex; flex-direction: column-reverse; gap: 8px;
  width: min(350px, calc(100vw - 24px)); pointer-events: none;
}
.toast {
  pointer-events: auto; cursor: pointer;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 13px; border-radius: 12px;
  background: #fff; border: 1px solid var(--border); border-left: 5px solid var(--primary);
  box-shadow: var(--shadow-lg);
  animation: toast-in .35s cubic-bezier(.2, .9, .3, 1.25);
}
.toast.out { animation: toast-out .3s ease forwards; }
.toast-star { border-left-color: var(--star); background: linear-gradient(90deg, #fffaf0, #fff 60%); }
.toast-ok { border-left-color: var(--ok); }
.toast-warn { border-left-color: var(--warn); }
.toast-error { border-left-color: var(--danger); }
.toast-icon { font-size: 22px; line-height: 1.1; }
.toast-star .toast-icon { animation: spin-pop .7s ease; }
.toast-title { font-weight: 600; overflow-wrap: anywhere; }
.toast-text { font-size: 13px; color: var(--muted); margin-top: 2px; }


/* ------------------------------------------------------------ trang quản lý / lịch sử */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.page-head h1 { margin-bottom: 4px; }
.page-head p { margin: 0; }
.subnav { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.subnav a { padding: 4px 11px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 26px; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 13px; }
.stat-star b { color: var(--star-600); }
.tip { border-color: #d9dcfb; background: linear-gradient(180deg, var(--primary-50), #fff 80%); }
.tip ol { margin: 0; padding-left: 20px; }
.tip li + li { margin-top: 4px; }
section.card { scroll-margin-top: 12px; }
section.card > h2 { margin-bottom: 12px; }
.roster-group { margin-top: 18px; }
.roster-group h3 { font-size: 15px; margin-bottom: 6px; }
.roster { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.roster li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 7px 12px; }
.roster li + li { border-top: 1px solid var(--border); }
.r-name { font-weight: 600; }
.roster .r-name { flex: 1 1 auto; }
.r-stars { color: var(--star-600); font-weight: 700; font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }
.team-admin, .list { list-style: none; margin: 14px 0 0; padding: 0; }
.team-admin li, .list-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  padding: 10px 0; border-top: 1px solid var(--border);
}
.team-rename input { width: 180px; }
.list-row input { width: 170px; min-height: 34px; }
.add-box { margin-top: 12px; }
.add-box summary { cursor: pointer; font-weight: 600; color: var(--primary); padding: 6px 0; }
.add-box form { margin-top: 10px; }
.danger-zone { border-color: #f5d0d0; }
.danger-box { border: 1px dashed #f0b4b4; border-radius: var(--radius-sm); padding: 14px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.danger-box h3, .danger-box p { margin: 0; }
.info { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.info dt { color: var(--muted); }
.info dd { margin: 0; font-weight: 600; }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; align-items: end; margin-bottom: 14px; }
.filter-actions { display: flex; gap: 8px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.tabs a { padding: 9px 14px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th { text-align: left; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 2px solid var(--border); white-space: nowrap; }
.table td { padding: 9px 10px; border-bottom: 1px solid #eef1f5; vertical-align: middle; }
.table tbody tr:hover { background: var(--surface-2); }
.table .empty { text-align: center; color: var(--muted); padding: 24px; }
.table th.right, .table td.right { text-align: right; }
.w-rank { width: 64px; text-align: center; font-size: 17px; }
.w-bar { width: 38%; min-width: 160px; }
.bar-cell { display: flex; align-items: center; gap: 10px; }
.bar { flex: 1; height: 9px; border-radius: 999px; background: #eef1f5; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #fcd34d, #f59e0b); }
.bar-cell b { min-width: 28px; text-align: right; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; }

/* đăng nhập */
.auth-wrap { display: grid; place-items: center; min-height: calc(100vh - 140px); padding: 12px 0; }
.auth-card { width: min(400px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 26px; }
.auth-card.auth-wide { width: min(520px, 100%); }
.auth-card h1 { margin: 0; }
.auth-card > p { margin: -8px 0 0; }
.auth-logo {
  display: grid; place-items: center; width: 54px; height: 54px; border-radius: 16px;
  background: linear-gradient(140deg, #fcd34d, #f59e0b 55%, #ea580c); color: #fff; font-size: 30px;
  box-shadow: 0 6px 16px rgba(245, 158, 11, .35);
}
.auth-alt { text-align: center; font-size: 14px; }

/* ------------------------------------------------------------ hiệu ứng */
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .45); }
  70% { box-shadow: 0 0 0 9px rgba(22, 163, 74, 0); }
  100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}
@keyframes blink { 50% { opacity: .45; } }
@keyframes star-hit {
  0% { background-color: rgba(253, 230, 138, 1); box-shadow: 0 0 0 3px rgba(252, 211, 77, 1); }
  100% { background-color: rgba(253, 230, 138, 0); box-shadow: 0 0 0 3px rgba(252, 211, 77, 0); }
}
@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.45); }
  100% { transform: scale(1); }
}
@keyframes feed-in {
  from { background: #fff4d6; transform: translateY(-6px); opacity: .4; }
  to { background: transparent; transform: none; opacity: 1; }
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(30px) scale(.97); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out { to { opacity: 0; transform: translateX(30px); } }
@keyframes spin-pop {
  0% { transform: scale(.3) rotate(-90deg); }
  70% { transform: scale(1.25) rotate(10deg); }
  100% { transform: scale(1) rotate(0); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* ------------------------------------------------------------ màn hình nhỏ */
@media (max-width: 1080px) {
  .board { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .user-meta { display: none; }
  .user-chip { padding: 3px; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .container { padding: 12px; }
  .topbar { padding: 8px 12px; gap: 6px 10px; }
  .brand { font-size: 16px; }
  .brand-text small { display: none; }
  .mainnav { order: 10; width: 100%; overflow-x: auto; }
  .mainnav a { padding: 6px 12px; }
  .lesson-bar { top: 4px; padding: 10px 12px 10px; }
  .lb-title { font-size: 17px; }
  .lb-meta { display: none; }
  .is-idle .lb-meta { display: block; }
  .lb-clock { font-size: 34px; }
  .lb-clock.idle { font-size: 24px; }
  .lb-clock-label { font-size: 11px; }
  .lb-controls .w-sm { width: 110px; }
  .lb-controls .btn-lg { width: 100%; }
  .chips { flex-wrap: wrap; }
  .teams { grid-template-columns: minmax(0, 1fr); }
  .team-head { padding: 10px 12px; }
  .member { padding: 6px 4px; gap: 8px; }
  .btn-star { padding: 0 12px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 14px; }
  /* Điện thoại: thông báo gọn ở trên cùng (đè lên thanh đồng hồ, không che các nút +1). */
  .toasts { top: 6px; bottom: auto; left: 8px; right: 8px; width: auto; flex-direction: column; gap: 6px; }
  .toast { padding: 8px 10px; gap: 8px; border-radius: 10px; }
  .toast-icon { font-size: 18px; }
  .toast-body { min-width: 0; }
  .toast-title { font-size: 14px; }
  .toast-text { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .filters .f-wide, .filter-actions { grid-column: 1 / -1; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; }
  .tabs a { white-space: nowrap; padding: 9px 12px; }
  .table td { white-space: nowrap; }
}

/* ------------------------------------------------------------ tài khoản nhóm (trang quản lý) */
.account-team { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.account-team h3 { font-size: 15px; margin-bottom: 4px; }
.account-team .list-row { border-top: 0; padding: 6px 0; }
.account-team .list-row input { width: 150px; min-height: 34px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: start; }
.account-new { margin-top: 8px; }
@media (max-width: 760px) { .grid-4 { grid-template-columns: minmax(0, 1fr); } }

/* ------------------------------------------------------------ danh sách lớp học (trang chủ) */
.cc-code {
  display: inline-block; padding: 2px 10px; border-radius: 8px;
  background: var(--primary); color: #fff; font-weight: 800; letter-spacing: .02em;
}
.class-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.class-card {
  position: relative; display: flex; flex-direction: column; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; transition: transform .15s, box-shadow .15s;
}
.class-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.class-card.live { border-color: #9ddfb3; background: linear-gradient(180deg, #effbf3, #fff 55%); }
.cc-link { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.class-card a.btn { position: relative; z-index: 2; }
.class-card header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.class-card .cc-code { font-size: 20px; padding: 3px 12px; }
.cc-subject { margin-top: 6px; font-size: 17px; font-weight: 700; }
.cc-stars { display: inline-flex; align-items: baseline; gap: 2px; color: var(--star-600); }
.cc-stars b { font-size: 26px; font-variant-numeric: tabular-nums; }
.cc-stars i { font-style: normal; }
.cc-status { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 4px; }
.cc-badge {
  display: inline-flex; align-items: center; gap: 7px; padding: 3px 11px; border-radius: 999px;
  font-size: 12.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
  background: var(--ok-50); color: var(--ok-600);
}
.cc-badge .lb-dot { background: var(--ok); animation: pulse 1.6s infinite; }
.cc-badge.idle { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.cc-clock { font-size: 30px; font-weight: 800; color: var(--ok-600); font-variant-numeric: tabular-nums; line-height: 1; }
.cc-clock.warn { color: var(--warn); }
.cc-clock.danger { color: var(--danger); }
.cc-lesson { font-weight: 600; overflow-wrap: anywhere; }
.cc-meta { font-size: 13px; color: var(--muted); }
.class-card footer {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  margin-top: auto; padding-top: 10px; border-top: 1px solid #eef1f5; font-size: 13px; color: var(--muted);
}
.cc-actions { display: inline-flex; align-items: center; gap: 6px; }
.cc-go { color: var(--primary); font-weight: 700; }

/* đầu trang bảng sao của một lớp */
.class-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 12px; }
.class-title { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; }
.class-head .btn { margin-left: auto; }
.back-link { font-weight: 600; }
.class-admin-list .cc-code { font-size: 14px; }

/* ------------------------------------------------------------ tab Lớp học + biểu mẫu lớp */
.admin-class-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.admin-class-card {
  display: flex; flex-direction: column; gap: 6px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; transition: transform .15s, box-shadow .15s, border-color .15s;
}
.admin-class-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--primary); }
.admin-class-card.live { border-color: #9ddfb3; }
.acc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.admin-class-card .cc-code { font-size: 18px; }
.admin-class-card .cc-subject { margin-top: 2px; }
.acc-line { font-size: 13.5px; color: #475467; }
.acc-foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; margin-top: auto;
  padding-top: 10px; border-top: 1px solid #eef1f5; font-size: 13px; color: var(--muted);
}
.add-class-bar { display: flex; justify-content: center; margin: 22px 0 8px; }
.cc-sched { margin-top: 4px; font-size: 13px; color: #475467; }
.class-sched { flex-basis: 100%; order: 3; }

.dialog-wide { width: min(640px, calc(100vw - 24px)); }
.class-form { display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.class-form h2 { margin: 0; }
#info > .class-form { padding: 0; }
.sessions { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px 14px; margin: 0; }
.sessions legend { padding: 0 6px; font-size: 13px; font-weight: 600; color: #475467; }
.session-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.session-row { display: grid; grid-template-columns: minmax(110px, 1.2fr) minmax(0, 1fr) auto minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.session-empty { margin: 0 0 8px; }
.form-error { margin: 0; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--danger-50); color: var(--danger-600); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
@media (max-width: 480px) {
  .session-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .session-row select { grid-column: 1 / -1; }
  .session-row > span { display: none; }
}

/* ------------------------------------------------------------ cài đặt lớp: từng nhóm */
.group-card { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 14px; overflow: hidden; scroll-margin-top: 12px; }
.group-card.loose { border-style: dashed; }
.group-card.just-changed { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
.group-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  padding: 12px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.group-title h3 { margin: 0 0 2px; font-size: 16.5px; }
.group-title h3 .muted { font-size: 14px; font-weight: 500; }
.group-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.group-table { font-size: 14.5px; }
.group-table td, .group-table th { padding: 7px 14px; }
/* Tên + nhãn nhóm trưởng xuống dòng riêng, không đẩy cột số sao ra ngoài màn hình */
.group-table td.st-name { white-space: normal; overflow-wrap: anywhere; width: 100%; }
.st-role { margin-top: 3px; }
.st-user { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.w-no { width: 44px; }
.star-num { color: var(--star-600); font-variant-numeric: tabular-nums; }
.warn-text { color: var(--warn); font-weight: 600; }
.leader-now { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--star-50); border: 1px solid #fde3a7; }
.leader-now input:not([type=checkbox]) { width: 160px; min-height: 34px; }
.dialog .class-form .stack { gap: 12px; }
.dialog-danger { border-top: 1px dashed var(--border); padding-top: 10px; }
.add-class-bar { gap: 10px; flex-wrap: wrap; }
@media (max-width: 640px) {
  .group-actions { width: 100%; }
  .group-actions .btn { flex: 1 1 auto; }
}

/* quyền bấm sao chéo */
.targets { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px 10px; margin: 0; display: flex; flex-direction: column; gap: 6px; background: #fff; }
.targets legend { padding: 0 6px; font-size: 13px; font-weight: 600; color: #475467; }
.targets .help { margin: 2px 0 0; }
.target-names { color: var(--primary); }
.team.target { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50), var(--shadow); }
.team.mine-own { opacity: .92; }
.team-markers { font-size: 12px; color: var(--muted); }


/* ------------------------------------------------------------ hỏi Có/Không trước khi cộng sao */
.confirm-dialog { width: min(420px, calc(100vw - 24px)); text-align: center; }
.confirm-dialog h2 { font-size: 21px; }
.confirm-dialog p { margin: -6px 0 0; }
.confirm-star { font-size: 44px; line-height: 1; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.confirm-actions .btn { min-height: 52px; }
.ask-dialog h2 { font-size: 19px; line-height: 1.4; overflow-wrap: anywhere; }
.ask-dialog.ask-fallback { box-shadow: 0 0 0 100vmax rgba(15, 23, 42, .45);  position: fixed; inset: 0; margin: auto; z-index: 3000; height: fit-content; }

/* ------------------------------------------------------------ popup chúc mừng */
.cheer {
  position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center;
  pointer-events: none; background: rgba(15, 23, 42, .28); animation: cheer-fade .25s ease;
}
.cheer.out { animation: cheer-fade-out .35s ease forwards; }
.cheer-card {
  position: relative; text-align: center; padding: 26px 40px 24px; min-width: min(420px, calc(100vw - 32px));
  max-width: calc(100vw - 32px); border-radius: 24px; background: linear-gradient(180deg, #fffbeb, #fff 65%);
  border: 3px solid #fbbf24; box-shadow: 0 24px 60px rgba(245, 158, 11, .35), 0 8px 24px rgba(16, 24, 40, .2);
  animation: cheer-pop .6s cubic-bezier(.2, 1.4, .4, 1);
}
.cheer-star {
  font-size: 84px; line-height: 1; color: #f59e0b; text-shadow: 0 6px 18px rgba(245, 158, 11, .45);
  animation: cheer-spin 1.1s ease-out;
}
.cheer-title { margin-top: 6px; font-size: 20px; font-weight: 700; color: #b45309; }
.cheer-name { margin-top: 2px; font-size: 34px; font-weight: 800; color: var(--text); overflow-wrap: anywhere; }
.cheer-plus { margin-top: 4px; font-size: 26px; font-weight: 800; color: var(--star-600); }
.cheer-meta { margin-top: 8px; font-size: 14px; color: var(--muted); }
.cheer-confetti { position: absolute; inset: 0; overflow: hidden; }
.cheer-confetti i {
  position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px; opacity: .9;
  animation-name: cheer-fall; animation-timing-function: linear; animation-fill-mode: forwards;
}
@keyframes cheer-fade { from { opacity: 0; } }
@keyframes cheer-fade-out { to { opacity: 0; } }
@keyframes cheer-pop { 0% { transform: scale(.4); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes cheer-spin { 0% { transform: scale(.2) rotate(-180deg); } 70% { transform: scale(1.2) rotate(15deg); } 100% { transform: none; } }
@keyframes cheer-fall { to { transform: translateY(110vh) rotate(720deg); } }
@media (max-width: 640px) {
  .cheer-card { padding: 20px 18px; }
  .cheer-name { font-size: 26px; }
  .cheer-star { font-size: 64px; }
}

.sound-hint {
  position: fixed; left: 12px; bottom: 12px; z-index: 900; padding: 9px 14px; border-radius: 999px;
  border: 1px solid #fde3a7; background: var(--star-50); color: #7a4a00; font: inherit; font-size: 13.5px;
  font-weight: 600; cursor: pointer; box-shadow: var(--shadow);
}


/* ------------------------------------------------------------ menu tài khoản */
.user-menu { position: relative; }
.user-menu > summary { list-style: none; cursor: pointer; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu .caret { color: var(--muted); font-size: 12px; }
.user-menu[open] > summary { background: var(--surface-2); }
.user-menu .menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 220px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  padding: 6px; display: flex; flex-direction: column;
}
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; display: flex; flex-direction: column; }
.menu-head small { color: var(--muted); }
.user-menu .menu a, .user-menu .menu button {
  display: block; width: 100%; text-align: left; padding: 9px 10px; border-radius: 8px; border: 0;
  background: none; font: inherit; color: var(--text); cursor: pointer;
}
.user-menu .menu a:hover, .user-menu .menu button:hover { background: var(--surface-2); text-decoration: none; }
.user-menu .menu form { margin: 0; }
.user-menu .menu button { color: var(--danger); }

.cheer-names { font-size: 26px; line-height: 1.3; }

/* ------------------------------------------------------------ trang lớp: tab Bảng sao / Điểm danh */
.view-tabs { display: flex; gap: 4px; margin: 0 0 14px; border-bottom: 1px solid var(--border); }
.view-tabs button {
  border: 0; background: none; font: inherit; font-size: 15.5px; font-weight: 700; color: var(--muted);
  padding: 10px 16px; border-bottom: 3px solid transparent; margin-bottom: -1px; cursor: pointer;
}
.view-tabs button:hover { color: var(--text); }
.view-tabs button[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.tab-count { margin-left: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--ok-50); color: var(--ok-600); }
.tab-count:empty { display: none; }

/* ------------------------------------------------------------ điểm danh */
.att-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 8px 16px; margin-bottom: 10px; }
.att-status { margin-bottom: 6px; }
.att-live { color: var(--ok-600); font-weight: 700; }
.att-live .lb-dot { display: inline-block; vertical-align: middle; background: var(--ok); animation: pulse 1.6s infinite; }
.att-counts { display: flex; flex-wrap: wrap; gap: 8px; }
.att-count { padding: 3px 12px; border-radius: 999px; font-size: 13.5px; border: 1px solid var(--border); background: #fff; }
.att-count b { font-size: 16px; margin-right: 3px; }
.att-count.present { background: #dcfce7; border-color: #86efac; color: #166534; }
.att-count.late { background: #fef3c7; border-color: #fcd34d; color: #92400e; }
.att-count.absent { color: var(--muted); }
.att-count.total { background: var(--primary-50); border-color: #c7d2fe; color: var(--primary); }
.att-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: middle; }
.dot.present { background: #22c55e; }
.dot.late { background: #f59e0b; }
.dot.absent { background: #cbd5e1; }
.att-hint { margin-bottom: 10px; }

/* --s: tỉ lệ co giãn, attendance.js chỉnh để cả lớp vừa một màn hình lớn */
.att-grid {
  --s: 1;
  display: grid; align-items: start;
  grid-template-columns: repeat(auto-fill, minmax(calc(210px * var(--s)), 1fr));
  gap: calc(10px * var(--s)); font-size: calc(14px * var(--s));
}
.att-team {
  background: var(--surface); border: 1px solid var(--border); border-radius: calc(12px * var(--s));
  padding: calc(8px * var(--s)); box-shadow: var(--shadow);
}
.att-team.mine { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50), var(--shadow); }
.att-team.full { border-color: #86efac; }
.att-team header { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; margin-bottom: calc(6px * var(--s)); }
.att-team h3 { margin: 0; font-size: 1.1em; }
.att-team-count { font-weight: 800; color: var(--ok-600); }
.att-list { display: flex; flex-direction: column; gap: calc(4px * var(--s)); }
.att-item {
  display: flex; align-items: center; gap: .4em; width: 100%; text-align: left;
  font: inherit; font-size: 1em; padding: .35em .55em; border-radius: .5em;
  border: 1px solid var(--border); background: var(--surface-2); color: #64748b;
}
button.att-item { cursor: pointer; }
button.att-item:hover { border-color: var(--primary); }
button.att-item:disabled { opacity: .6; cursor: progress; }
.att-item.present { background: #dcfce7; border-color: #86efac; color: #14532d; }
.att-item.late { background: #fef3c7; border-color: #fcd34d; color: #78350f; }
.att-mark { flex: none; width: 1.1em; text-align: center; font-weight: 900; color: #16a34a; }
.att-item.late .att-mark { color: #d97706; }
.att-name { flex: 1 1 auto; min-width: 0; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-meta { flex: none; min-width: 3.6em; text-align: right; font-size: .82em; opacity: .85; font-variant-numeric: tabular-nums; }
/* Màn hình lớn: xếp nhóm theo cột kiểu báo (các cột cao đều nhau) để dùng hết chiều cao màn hình */
.att-grid.fixed { display: block; column-count: var(--cols); column-gap: calc(10px * var(--s)); }
.att-grid.fixed .att-team { break-inside: avoid; margin-bottom: calc(10px * var(--s)); box-shadow: none; }
.att-lead {
  flex: none; font-size: .7em; font-weight: 800; padding: 0 .45em; border-radius: 999px;
  color: var(--star-600); background: var(--star-50); border: 1px solid #fde3a7;
}
.att-you { font-weight: 500; font-size: .85em; color: var(--muted); }
.att-item.att-new { animation: att-pop 1.2s ease-out; }
@keyframes att-pop {
  0% { transform: scale(1.06); box-shadow: 0 0 0 4px rgba(34, 197, 94, .5); }
  100% { transform: none; box-shadow: none; }
}
/* Màn hình lớn (tab Điểm danh, Bảng sao vừa màn hình): thanh tiết học gọn lại để dành chỗ cho danh sách */
@media (min-width: 900px) {
  :is(body.view-attendance, body.fit-stars) .lesson-bar { padding: 10px 18px 8px; margin-bottom: 10px; }
  :is(body.view-attendance, body.fit-stars) .lb-meta, :is(body.view-attendance, body.fit-stars) .lb-progress { display: none; }
  :is(body.view-attendance, body.fit-stars) .lb-clock { font-size: 34px; }
  :is(body.view-attendance, body.fit-stars) .lb-title { font-size: 18px; margin: 0; }
  :is(body.view-attendance, body.fit-stars) .class-sched { display: none; }
  :is(body.view-attendance, body.fit-stars) .container { max-width: 1840px; }
  :is(body.view-attendance, body.fit-stars) .class-head { margin-bottom: 8px; }
  :is(body.view-attendance, body.fit-stars) .view-tabs { margin-bottom: 8px; }
  :is(body.view-attendance, body.fit-stars) .view-tabs button { padding: 7px 14px; }
  :is(body.view-attendance, body.fit-stars) .att-head { margin-bottom: 6px; }
  :is(body.view-attendance, body.fit-stars) .att-status { margin-bottom: 4px; }
}
/* Bảng sao vừa một màn hình lớn (board.js tính --board-h, --cols và zoom) */
.board.fit { height: var(--board-h); grid-template-columns: minmax(0, 1fr) 320px; }
.board.fit .board-main { min-height: 0; overflow: hidden; }
.board.fit .teams { grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); align-items: start; }
.board.fit .board-side { height: 100%; min-height: 0; gap: 12px; }
.board.fit .board-side .card { padding: 12px 14px; min-height: 0; }
.board.fit .board-side .card:first-child { flex: 0 1 auto; overflow-y: auto; }
.board.fit .board-side .card:last-child { flex: 1 1 0; display: flex; flex-direction: column; }
.board.fit .feed { max-height: none; flex: 1 1 auto; min-height: 0; }
body.fit-stars .hint { margin-bottom: 8px; }

.cc-att { font-size: 13.5px; color: var(--ok-600); }

/* Khách xem Điểm danh: chỉ còn nhóm + tên sinh viên; nút ✕ ở góc phải để quay về Bảng sao */
.att-close {
  display: none; place-items: center; width: 44px; height: 44px; padding: 0; border-radius: 50%;
  border: 1px solid var(--border); background: #fff; color: #475467; font: inherit; font-size: 20px; line-height: 1;
  cursor: pointer; box-shadow: var(--shadow);
}
.att-close:hover { background: var(--surface-2); color: var(--text); border-color: #cbd5e1; }
body.att-kiosk .topbar, body.att-kiosk .class-head, body.att-kiosk .lesson-bar,
body.att-kiosk .view-tabs, body.att-kiosk .container > .flash { display: none !important; }
body.att-kiosk .container { max-width: none; }
body.att-kiosk #viewAttendance { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: start; }
body.att-kiosk #attGrid { grid-column: 1; grid-row: 1; }
body.att-kiosk .att-close { display: grid; grid-column: 2; grid-row: 1; position: sticky; top: 12px; }

/* chỉ dành cho trình đọc màn hình */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
