/* ==========================================================================
   MAC Company Trip — Dashboard (admin.css)
   --------------------------------------------------------------------------
   Brand: đỏ #E31E24 → cam #FF6A2C (gradient cho hành động chính).
   Nền: page #F5F5F7 · panel #FFFFFF · subtle #FAFAFC · text #111827 · muted #667085.
   Type scale : 10 / 11 / 12 / 13 / 14 / 16 / 18 / 20 / 24 / 30 px
   Font weight: 500 (meta nhẹ) · 600 (điều khiển, nav) · 700 (nút, tiêu đề) · 800 (eyebrow, chip)
   Spacing    : 4 / 8 / 12 / 16 / 24 / 32 · radius panel 12–14, control 10–12, touch ≥ 40–44px
   Cấu trúc   : tokens → layout → components → login → loader → theme hardening → responsive
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens & nền tảng
   -------------------------------------------------------------------------- */
.mac-admin-app {
  --r: #e31e24;
  --o: #ff6a2c;
  --grad: linear-gradient(135deg, var(--r) 0%, #f04423 55%, var(--o) 100%);
  --ink: #111827;
  --ink-soft: #344054;
  --ink-mid: #475467;
  --muted: #667085;
  --faint: #98a2b3;
  --page: #f5f5f7;
  --panel: #ffffff;
  --soft: #fafafc;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --brand-border: #fed7cc;
  --brand-soft: #fff4f0;
  --brand-softer: #fff8f5;
  --brand-tint: #fff6f2;
  --danger: #b42318;
  --danger-strong: #d92d20;
  --danger-border: #fecdca;
  --danger-soft: #fef3f2;
  --success: #067647;
  --success-soft: #ecfdf3;
  --success-border: #abefc6;
  --warn: #93370d;
  --warn-soft: #fffaeb;
  --warn-border: #fedf89;
  --info: #175cd3;
  --info-soft: #eff8ff;
  --info-border: #b2ddff;
  --shadow-card: 0 1px 3px rgba(16, 24, 40, 0.05);
  --shadow-btn: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-grad: 0 7px 18px rgba(227, 30, 36, 0.2);
  --focus-ring: 3px solid rgba(227, 30, 36, 0.18);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

.mac-admin-wrap {
  margin: 0 0 0 -20px;
}

.mac-admin-wrap.mac-admin-public {
  margin: 0;
}

.mac-admin-app *,
.mac-admin-app *::before,
.mac-admin-app *::after {
  box-sizing: border-box;
}

.mac-admin-app button,
.mac-admin-app input,
.mac-admin-app select {
  font: inherit;
}

.mac-admin-app button:focus-visible,
.mac-admin-app a:focus-visible,
.mac-admin-app select:focus-visible,
.mac-admin-app input:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

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

/* --------------------------------------------------------------------------
   2. Layout: sidebar + nội dung
   -------------------------------------------------------------------------- */
.ma-layout {
  display: grid;
  min-height: calc(100vh - 32px);
  grid-template-columns: 236px minmax(0, 1fr);
  background: var(--page);
}

.ma-side {
  position: sticky;
  top: 32px;
  display: flex;
  height: calc(100vh - 32px);
  flex-direction: column;
  padding: 22px 16px;
  border-right: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px);
}

.ma-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 20px;
  border-bottom: 1px solid var(--border);
}

.ma-brand img {
  width: 90px;
  height: auto;
}

.ma-brand strong {
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 700;
}

.ma-brand small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.ma-side nav {
  display: grid;
  gap: 5px;
  margin-top: 24px;
}

.ma-side button,
.ma-side > a {
  display: flex;
  min-height: 44px;
  align-items: center;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease;
}

.ma-side button:hover,
.ma-side > a:hover {
  color: var(--ink);
  background: var(--soft);
}

.ma-side button.active {
  color: var(--r);
  background: var(--brand-soft);
  box-shadow: inset 0 0 0 1px var(--brand-border);
}

.ma-side > a {
  margin-top: auto;
}

.ma-side-links {
  display: grid;
  gap: 4px;
  margin-top: auto;
}

.ma-side-links a {
  display: flex;
  min-height: 40px;
  align-items: center;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.ma-side-links a:hover {
  color: var(--ink);
  background: var(--soft);
}

/* Nút "Áp dữ liệu demo" — chỉ super admin thấy, đặt kín cuối sidebar nên để thật trầm. */
.ma-side-links .ma-side-secret {
  display: flex;
  min-height: 36px;
  align-items: center;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  opacity: 0.5;
  transition: background-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.ma-side-links .ma-side-secret:hover,
.ma-side-links .ma-side-secret:focus-visible {
  color: var(--ink);
  background: var(--soft);
  opacity: 0.9;
}

.ma-side-logout {
  margin-top: 8px;
  min-height: 44px;
}

.ma-content {
  min-width: 0;
  width: 100%;
  max-width: 1500px;
  padding: 28px clamp(20px, 3vw, 44px) 56px;
}

.ma-content > section + section,
.ma-content > section + div,
.ma-content > div + section {
  margin-top: 16px;
}

/* Topbar của mỗi tab */
.ma-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

/* Eyebrow đỏ chữ in hoa — dùng chung cho topbar, panel head, khối dữ liệu */
.ma-top small,
.ma-panel header small,
.ma-art-block-head small,
.ma-data > section > small {
  color: var(--r);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.ma-top h1 {
  margin: 4px 0 0;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.035em;
}

.ma-top button {
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-btn);
}

.ma-top button:hover {
  border-color: var(--border-strong);
  background: var(--soft);
}

.ma-top button.is-loading {
  color: var(--muted);
  cursor: wait;
}

.ma-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ma-top .ma-reset-trigger {
  border-color: var(--danger-border);
  color: var(--danger);
  background: #fff;
}

.ma-top .ma-reset-trigger:hover {
  border-color: #f97066;
  background: var(--danger-soft);
}

/* Toast thông báo */
.ma-alert {
  position: fixed;
  z-index: 99;
  top: 48px;
  right: 24px;
  max-width: 420px;
  padding: 12px 16px;
  border: 1px solid var(--success-border);
  border-radius: 12px;
  color: var(--success);
  background: var(--success-soft);
  box-shadow: 0 14px 36px rgba(16, 24, 40, 0.15);
}

.ma-alert.error {
  border-color: var(--danger-border);
  color: var(--danger);
  background: var(--danger-soft);
}

/* --------------------------------------------------------------------------
   3. Nút bấm
   -------------------------------------------------------------------------- */

/* Nút trung tính + link dạng nút (mặc định của .ma-data a và .ma-primary) */
.ma-data a,
.ma-primary {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  margin-top: 9px;
  padding: 0 15px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-btn);
}

.ma-data a:hover,
.ma-primary:hover {
  border-color: var(--border-strong);
  background: var(--soft);
}

/* Biến thể gradient cho hành động chính */
.ma-data .ma-primary,
.ma-modal-actions .ma-primary,
.ma-staff-form .ma-primary,
.ma-check-card button.ma-primary,
.ma-gate button.ma-primary,
#ma-team-add .ma-primary {
  margin-top: auto;
  border: 0;
  color: #fff;
  background: var(--grad);
  box-shadow: var(--shadow-grad);
}

.ma-data .ma-primary:hover:not(:disabled),
.ma-modal-actions .ma-primary:hover:not(:disabled),
.ma-staff-form .ma-primary:hover:not(:disabled),
.ma-check-card button.ma-primary:hover:not(:disabled),
.ma-gate button.ma-primary:hover:not(:disabled),
#ma-team-add .ma-primary:hover:not(:disabled) {
  border-color: transparent;
  background: var(--grad);
  filter: brightness(1.06);
  box-shadow: 0 6px 14px rgba(227, 30, 36, 0.25);
}

.ma-modal-actions .ma-primary,
.ma-check-card button.ma-primary,
#ma-team-add .ma-primary {
  margin-top: 0;
}

#ma-team-add .ma-primary {
  flex: 0 0 auto;
}

.ma-staff-form .ma-primary,
.ma-exempt-form .ma-primary {
  justify-self: start;
}

.ma-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ma-primary input {
  display: none;
}

/* Đồng bộ transition cho mọi nút/ô nhập tương tác */
.ma-panel button,
.ma-check-card button,
.ma-round-head button,
.ma-top-actions button,
.ma-subnav button,
.ma-side nav button,
.ma-side-links a,
.ma-people-actions button,
.ma-award-presets button,
.ma-award-teams button,
.ma-duration input,
.ma-game-row select {
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.ma-panel button.is-loading {
  cursor: wait;
  opacity: 0.68;
}

/* --------------------------------------------------------------------------
   4. Panel & thống kê nhanh
   -------------------------------------------------------------------------- */
.ma-grid {
  display: grid;
  grid-template-columns: minmax(480px, 1.4fr) minmax(280px, 0.7fr);
  gap: 16px;
}

.ma-panel {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow-card);
}

.ma-panel > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.ma-panel h2 {
  margin: 3px 0 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.ma-panel > header > b {
  padding: 6px 9px;
  border: 1px solid var(--brand-border);
  border-radius: 999px;
  color: var(--r);
  background: var(--brand-tint);
  font-size: 11px;
  letter-spacing: 0.09em;
}

.ma-panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.ma-panel .ma-board-table {
  margin: 12px 16px 16px;
}

.ma-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.ma-stats article {
  display: grid;
  gap: 6px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.04);
}

.ma-stats span {
  color: var(--muted);
  font-size: 13px;
}

.ma-stats strong {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

/* Subnav trong tab (ví dụ Văn nghệ) */
.ma-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}

.ma-subnav button {
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.ma-subnav button:hover {
  color: var(--ink);
  background: var(--soft);
}

.ma-subnav button.active {
  color: var(--r);
  background: var(--brand-soft);
  box-shadow: inset 0 0 0 1px var(--brand-border);
}

/* --------------------------------------------------------------------------
   5. Lượt vote văn nghệ (rounds)
   -------------------------------------------------------------------------- */
.ma-rounds {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.ma-round {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--soft);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.ma-round.open {
  border-color: #f3a893;
  background: #fffaf8;
  box-shadow: inset 3px 0 var(--o);
}

.ma-round.closed {
  background: #f8fafc;
}

.ma-round.closed .ma-slots {
  opacity: 0.62;
}

.ma-round-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.ma-round-head > span {
  display: grid;
}

.ma-round-head small {
  color: var(--r);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.ma-round-head strong {
  margin-top: 2px;
  font-size: 14px;
}

.ma-round-head button {
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  color: #fff;
  background: #1d2939;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.ma-round-head button:hover {
  background: #101828;
}

.ma-round-head button.danger {
  background: var(--r);
}

.ma-round-head button.reopen {
  border: 1px solid var(--border-strong);
  color: var(--ink-soft);
  background: var(--panel);
}

.ma-round-head button.reopen:hover {
  border-color: #f3a893;
  color: var(--r);
  background: var(--brand-softer);
}

.ma-round-head button:disabled {
  opacity: 0.58;
  cursor: wait;
}

.ma-round-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.ma-slots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.ma-slots > div {
  display: grid;
  min-width: 0;
  gap: 5px;
  padding: 12px;
  border: 1px solid #eaecf0;
  border-radius: 10px;
  background: var(--panel);
}

.ma-slots small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.ma-slots strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ma-slots select {
  width: 100%;
  min-height: 36px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: 14px;
}

.ma-slots em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

/* Danh sách kết quả lượt (danh sách phiếu theo lượt) */
.ma-result {
  display: flex;
  min-height: 64px;
  align-items: center;
  gap: 11px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.ma-result:last-of-type {
  border-bottom: 0;
}

.ma-result i {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--brand-border);
  border-radius: 9px;
  color: var(--r);
  background: var(--brand-tint);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.ma-result span {
  display: grid;
  min-width: 0;
  flex: 1;
}

.ma-result span strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ma-result span small {
  color: var(--muted);
  font-size: 12px;
}

.ma-result > b {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.ma-results > p {
  margin: 0;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  background: var(--soft);
  font-size: 12px;
}

/* --------------------------------------------------------------------------
   6. Tổng quan: biểu đồ + lịch sử
   -------------------------------------------------------------------------- */
.ma-overview-stack {
  display: grid;
  gap: 16px;
}

.ma-chart-panel > header {
  padding: 18px 20px 0;
  border-bottom: 0;
}

.ma-chart {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  padding: 12px 20px 24px;
}

.ma-chart-col {
  display: grid;
  min-height: 280px;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
  text-align: center;
}

.ma-chart-col strong {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.ma-chart-track {
  display: flex;
  height: 180px;
  align-items: flex-end;
  justify-content: center;
  border-radius: 12px 12px 6px 6px;
  background: var(--soft);
}

.ma-chart-track span {
  display: block;
  width: 100%;
  min-height: 6px;
  border-radius: 12px 12px 6px 6px;
  background: var(--grad);
}

.ma-chart-col.is-neg .ma-chart-track span {
  background: var(--danger-border);
}

.ma-chart-col figcaption {
  display: grid;
  gap: 2px;
}

.ma-chart-col figcaption b {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.ma-chart-col figcaption small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.ma-chart-col figcaption b,
.ma-chart-col figcaption small {
  overflow-wrap: anywhere;
}

.ma-history-table {
  max-height: 520px;
}

.ma-history-table td:last-child {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ma-history-table tr.is-clear td:last-child {
  color: var(--muted);
}

.ma-history-table tr.is-checkin td:last-child {
  color: var(--danger);
}

/* --------------------------------------------------------------------------
   7. Văn nghệ: khối live + màn trình chiếu kết quả (reveal)
   -------------------------------------------------------------------------- */
.ma-art-stack,
.ma-art-live {
  display: grid;
  gap: 16px;
}

.ma-art-live .ma-stats {
  margin-bottom: 0;
}

.ma-art-block {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow-card);
}

.ma-art-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--soft);
}

.ma-art-block-head h2 {
  margin: 2px 0 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.ma-art-block-head .ma-screen-link {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.ma-art-block .ma-reveal-grid {
  padding: 12px;
  gap: 12px;
}

.ma-art-block .ma-reveal-control,
.ma-art-block .ma-reveal-scoreboard {
  padding: 14px 16px;
  box-shadow: none;
}

.ma-art-block .ma-reveal-control > header,
.ma-art-block .ma-reveal-scoreboard > header {
  padding: 0 0 12px;
}

.ma-art-block .ma-panel h2 {
  font-size: 16px;
}

.ma-art-block .ma-reveal-intro {
  margin-top: 12px;
}

.ma-art-block .ma-reveal-actions {
  margin-top: 12px;
  gap: 6px;
}

.ma-art-block .ma-reveal-actions button {
  min-height: 52px;
  padding: 8px 12px;
  border-radius: 10px;
}

.ma-art-block .ma-reveal-actions button strong {
  font-size: 13px;
}

.ma-art-block .ma-reveal-actions button small {
  font-size: 11px;
}

.ma-art-ballots .ma-table {
  max-height: 280px;
}

.ma-screen-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border: 1px solid var(--brand-border);
  border-radius: 10px;
  color: var(--r);
  background: var(--brand-softer);
  font-weight: 700;
  text-decoration: none;
}

.ma-screen-link:hover {
  border-color: #fda29b;
  color: var(--danger);
  background: var(--brand-soft);
}

.ma-reveal-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.65fr);
  gap: 16px;
}

.ma-reveal-control,
.ma-reveal-scoreboard {
  padding: 24px;
}

.ma-reveal-top {
  align-items: flex-end;
}

.ma-reveal-status {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: var(--soft);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.ma-reveal-status i,
.ma-reveal-footer i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
}

.ma-reveal-status.rolling,
.ma-reveal-status.decoy {
  border-color: var(--warn-border);
  color: var(--warn);
  background: var(--warn-soft);
}

.ma-reveal-status.rolling i,
.ma-reveal-status.decoy i {
  background: #f79009;
  box-shadow: 0 0 0 4px rgba(247, 144, 9, 0.14);
}

.ma-reveal-status.third,
.ma-reveal-status.second {
  border-color: var(--danger-border);
  color: var(--danger);
  background: var(--brand-soft);
}

.ma-reveal-status.third i,
.ma-reveal-status.second i {
  background: var(--r);
  box-shadow: 0 0 0 4px rgba(227, 30, 36, 0.1);
}

.ma-reveal-status.final {
  border-color: var(--success-border);
  color: var(--success);
  background: var(--success-soft);
}

.ma-reveal-status.final i {
  background: #17b26a;
}

.ma-reveal-intro {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid #fee4e2;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand-softer), #fff);
}

.ma-reveal-intro strong {
  display: block;
  font-size: 14px;
}

.ma-reveal-intro p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.ma-reveal-actions {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.ma-reveal-warn {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--warn-border);
  border-radius: 12px;
  background: var(--warn-soft);
}

.ma-reveal-warn > span {
  display: grid;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: #f79009;
  font-size: 13px;
  font-weight: 800;
}

.ma-reveal-warn strong {
  display: block;
  color: var(--warn);
  font-size: 13px;
}

.ma-reveal-warn ul {
  margin: 4px 0 0;
  padding-left: 16px;
  color: var(--ink-mid);
  font-size: 12px;
  line-height: 1.55;
}

.ma-reveal-actions button {
  display: grid;
  min-height: 68px;
  grid-template-columns: 44px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-content: center;
  column-gap: 12px;
  padding: 10px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  color: var(--ink);
  background: var(--panel);
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.ma-reveal-actions button:hover:not(:disabled) {
  border-color: #fda29b;
  box-shadow: 0 8px 22px rgba(227, 30, 36, 0.08);
  transform: translateY(-1px);
}

.ma-reveal-actions button > span {
  display: grid;
  width: 44px;
  height: 44px;
  grid-row: 1 / 3;
  place-items: center;
  align-self: center;
  border-radius: 11px;
  color: var(--r);
  background: var(--brand-soft);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.ma-reveal-actions button strong {
  align-self: end;
  font-size: 14px;
}

.ma-reveal-actions button small {
  align-self: start;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.ma-reveal-actions .ma-reveal-start:not(:disabled) {
  border-color: #1d2939;
  color: #fff;
  background: #1d2939;
}

.ma-reveal-actions .ma-reveal-start:not(:disabled) > span {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.ma-reveal-actions .ma-reveal-start:not(:disabled) small,
.ma-reveal-actions .ma-reveal-final:not(:disabled) small {
  color: rgba(255, 255, 255, 0.76);
}

.ma-reveal-actions .ma-reveal-final:not(:disabled) {
  border-color: transparent;
  color: #fff;
  background: var(--grad);
  box-shadow: 0 10px 24px rgba(227, 30, 36, 0.18);
}

.ma-reveal-actions .ma-reveal-final:not(:disabled) > span {
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
}

.ma-reveal-actions button:disabled {
  border-color: var(--border);
  color: var(--faint);
  background: var(--soft);
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.72;
}

.ma-reveal-actions button.is-skipped:disabled {
  opacity: 0.34;
  filter: grayscale(0.7);
}

.ma-reveal-actions button:disabled > span {
  color: var(--faint);
  background: #eaecf0;
}

.ma-reveal-actions button.is-loading {
  cursor: wait;
}

.ma-reveal-footer {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
}

.ma-reveal-footer p {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.ma-reveal-footer button {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--ink-mid);
  background: var(--panel);
  font-weight: 700;
  cursor: pointer;
}

.ma-reveal-footer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.ma-reveal-footer button.is-warn {
  border-color: var(--warn-border);
  color: var(--warn);
  background: var(--warn-soft);
}

.ma-reveal-footer button:disabled {
  color: var(--faint);
  background: var(--soft);
  cursor: not-allowed;
}

.ma-reveal-scoreboard > div {
  display: grid;
  margin-top: 10px;
}

.ma-reveal-result {
  display: grid;
  min-height: 60px;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.ma-reveal-result:last-child {
  border-bottom: 0;
}

.ma-reveal-result > i {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  color: var(--r);
  background: var(--brand-soft);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.ma-reveal-result > span {
  display: grid;
  min-width: 0;
}

.ma-reveal-result > span strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ma-reveal-result > span small {
  color: var(--muted);
  font-size: 11px;
}

.ma-reveal-result > b {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}


/* --------------------------------------------------------------------------
   8. Bảng dữ liệu
   -------------------------------------------------------------------------- */

/* Bảng danh sách trong panel (phiếu bầu, nhân sự…) */
.ma-table {
  overflow: auto;
}

.ma-table table {
  width: 100%;
  min-width: 800px;
  border-collapse: collapse;
}

.ma-table th {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  background: var(--soft);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
}

.ma-table td {
  padding: 13px 14px;
  border-top: 1px solid #f0f1f3;
  font-size: 14px;
  vertical-align: middle;
}

.ma-table tbody tr:hover {
  background: #fcfcfd;
}

.ma-table td:first-child {
  display: grid;
}

.ma-table td small {
  color: var(--muted);
}

.ma-table tr.revoked {
  opacity: 0.55;
}

.ma-table .badge {
  display: inline-flex;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--success);
  background: var(--success-soft);
  font-size: 12px;
  font-weight: 700;
}

.ma-table .badge.revoked {
  color: var(--danger);
  background: var(--danger-soft);
}

.ma-table button {
  min-height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--r);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.ma-table button:hover {
  background: var(--brand-soft);
}

/* Chi tiết phiếu trong bảng (details/summary) */
.ma-ballot-detail {
  position: relative;
  min-width: 128px;
}

.ma-ballot-detail summary {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  gap: 8px;
  border-radius: 8px;
  color: var(--r);
  cursor: pointer;
  list-style: none;
}

.ma-ballot-detail summary::-webkit-details-marker {
  display: none;
}

.ma-ballot-detail summary strong {
  font-size: 18px;
}

.ma-ballot-detail summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.ma-ballot-detail summary:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

.ma-ballot-detail[open] > div {
  display: grid;
  min-width: 260px;
  gap: 8px;
  margin-top: 6px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--soft);
}

.ma-ballot-detail p {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  color: var(--ink-mid);
  font-size: 13px;
}

.ma-ballot-detail p b {
  color: var(--ink);
  font-size: 14px;
}

/* Bảng điểm / bảng nhân sự: cuộn ngang mobile, ghim cột đầu */
.ma-board-table,
.ma-people-table {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}

.ma-board-table table,
.ma-people-table table {
  width: 100%;
  border-collapse: collapse;
}

.ma-board-table table {
  min-width: 640px;
  table-layout: fixed;
}

.ma-board-table th,
.ma-people-table th,
.ma-board-table td,
.ma-people-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 13px;
}

.ma-board-table th,
.ma-board-table td {
  overflow-wrap: anywhere;
}

.ma-board-table tbody tr:hover td,
.ma-people-table tbody tr:hover td {
  background: var(--soft);
}

/* Ghim cột đầu bên trái khi cuộn ngang */
.ma-board-table th:first-child,
.ma-board-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  width: 180px;
  min-width: 180px;
  background: var(--panel);
  box-shadow: 1px 0 0 var(--border);
}

.ma-board-table thead th:first-child {
  z-index: 2;
}

.ma-board-table tbody tr:hover td:first-child {
  background: var(--soft);
}

/* Biến thể ghim thêm cột thứ 2 (bảng tổng kết: hạng + team) */
.ma-board-table.ma-pin-2 th:first-child,
.ma-board-table.ma-pin-2 td:first-child {
  width: 60px;
  min-width: 60px;
}

.ma-board-table.ma-pin-2 th:nth-child(2),
.ma-board-table.ma-pin-2 td:nth-child(2) {
  position: sticky;
  left: 56px;
  z-index: 1;
  width: 180px;
  min-width: 180px;
  background: var(--panel);
  box-shadow: 1px 0 0 var(--border);
}

.ma-board-table.ma-pin-2 thead th:nth-child(2) {
  z-index: 2;
}

.ma-board-table.ma-pin-2 tbody tr:hover td:nth-child(2) {
  background: var(--soft);
}

/* Biến thể bỏ sticky (bảng tài khoản quét QR) */
.ma-board-table.ma-no-sticky th:first-child,
.ma-board-table.ma-no-sticky td:first-child {
  position: static;
  width: auto;
  min-width: 0;
  box-shadow: none;
}

/* Header trạm 2 dòng: "Trạm N" + tên trạm nhỏ bên dưới */
.ma-board-table thead th small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  white-space: normal;
}

/* Dòng phụ trong ô bảng (TB phiếu văn nghệ) */
.ma-cell-sub {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

/* Ô tiến độ check-in theo trạm */
.ma-progress-cell {
  text-align: center;
  white-space: nowrap;
}

.ma-progress-cell strong {
  display: block;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.ma-progress-cell small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

/* --------------------------------------------------------------------------
   9. Tab Nhân sự & QR: khối dữ liệu, import CSV, modal QR
   -------------------------------------------------------------------------- */
.ma-data {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.ma-data > section {
  display: flex;
  min-height: 340px;
  flex-direction: column;
  align-items: flex-start;
  padding: 28px;
}

.ma-icon {
  display: grid;
  width: 48px;
  height: 48px;
  margin-bottom: 20px;
  place-items: center;
  border: 1px solid var(--brand-border);
  border-radius: 12px;
  color: var(--r);
  background: var(--brand-tint);
  font-size: 20px;
}

.ma-data h2 {
  margin: 6px 0 8px;
  font-size: 24px;
  letter-spacing: -0.025em;
}

.ma-data p {
  max-width: 515px;
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

/* Cảnh báo permalink / import thành công */
.ma-permalink-warning,
.ma-import-success {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--warn-border);
  border-radius: 12px;
  color: var(--warn);
  background: var(--warn-soft);
  font-size: 13px;
}

.ma-permalink-warning span,
.ma-import-success div {
  display: grid;
  flex: 1;
  gap: 3px;
}

.ma-permalink-warning a {
  color: inherit;
  font-weight: 700;
}

.ma-import-success {
  border-color: var(--success-border);
  color: var(--success);
  background: var(--success-soft);
}

.ma-import-success > span {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: #079455;
}

.ma-import-success small {
  color: #17875b;
}

/* Modal xem trước CSV */
.ma-file-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--soft);
}

.ma-file-summary > span {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  color: var(--r);
  background: var(--brand-soft);
  font-size: 10px;
  font-weight: 800;
}

.ma-file-summary > div {
  display: grid;
  min-width: 0;
}

.ma-file-summary strong,
.ma-file-summary small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ma-file-summary small {
  color: var(--muted);
  font-size: 13px;
}

.ma-import-warning,
.ma-import-ready {
  display: grid;
  gap: 4px;
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid var(--warn-border);
  border-radius: 10px;
  color: var(--warn);
  background: var(--warn-soft);
  font-size: 13px;
}

.ma-import-ready {
  border-color: var(--success-border);
  color: var(--success);
  background: var(--success-soft);
}

.ma-preview-count {
  margin: 14px 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.ma-preview-table {
  max-height: 300px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.ma-preview-table table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

.ma-preview-table th,
.ma-preview-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  text-align: left;
}

.ma-preview-table th {
  position: sticky;
  top: 0;
  color: var(--muted);
  background: var(--soft);
  font-size: 12px;
  text-transform: uppercase;
}

/* Overlay đang kiểm tra file import */
.ma-import-checking {
  position: fixed;
  z-index: 100001;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--ink);
  background: rgba(245, 245, 247, 0.86);
  backdrop-filter: blur(8px);
}

.ma-import-checking span {
  width: 22px;
  height: 22px;
  border: 3px solid var(--brand-border);
  border-top-color: var(--r);
  border-radius: 50%;
  animation: ma-spin 0.8s linear infinite;
}

/* Modal preview QR cá nhân */
.ma-qr-modal-preview {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin: 8px 0 16px;
  text-align: center;
}

.ma-qr-modal-preview canvas {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

/* --------------------------------------------------------------------------
   10. Modal & hộp thoại xác nhận
   -------------------------------------------------------------------------- */
.ma-modal {
  position: fixed;
  z-index: 100000;
  inset: 0;
  display: grid;
  padding: 24px;
  place-items: center;
  background: rgba(16, 24, 40, 0.52);
  backdrop-filter: blur(4px);
}

.ma-modal-card {
  width: min(100%, 840px);
  max-height: min(86vh, 760px);
  overflow: auto;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 28px 80px rgba(16, 24, 40, 0.28);
}

.ma-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.ma-modal-head small {
  color: var(--r);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.ma-modal-head h2 {
  margin: 4px 0 0;
  font-size: 24px;
}

.ma-modal-head button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
}

.ma-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.ma-modal-actions button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink-soft);
  font-weight: 700;
  cursor: pointer;
}

.ma-modal-actions .ma-primary {
  margin-top: 0;
}

.ma-modal-actions .ma-danger-button {
  border-color: var(--danger-strong);
  color: #fff;
  background: var(--danger-strong);
}

.ma-modal-actions .ma-danger-button:hover:not(:disabled) {
  border-color: var(--danger);
  background: var(--danger);
}

.ma-modal-actions .ma-danger-button:disabled {
  border-color: var(--danger-border);
  color: #fda29b;
  background: var(--danger-soft);
  cursor: not-allowed;
}

.ma-modal-actions .ma-danger-button.is-loading {
  cursor: wait;
}

/* Hộp thoại xác nhận gọn (confirmDialog) */
.ma-confirm-card {
  width: min(100%, 440px);
  padding: 20px;
  border-radius: 20px;
}

.ma-confirm-card .ma-modal-head {
  padding-bottom: 10px;
  border-bottom: 0;
}

.ma-confirm-card .ma-modal-head h2 {
  font-size: 20px;
}

.ma-confirm-card .ma-modal-head button {
  display: none;
}

.ma-confirm-card .ma-confirm-message,
.ma-confirm-card .ma-prompt-label {
  padding: 0 0 18px;
}

.ma-confirm-card .ma-modal-actions {
  margin-top: 0;
}

.ma-confirm-card .ma-modal-actions button {
  border-radius: 12px;
}

.ma-confirm-message {
  margin: 0;
  padding: 0 20px 18px;
  color: var(--ink-mid);
  font-size: 14px;
  line-height: 1.55;
}

/* Nhãn + ô nhập trong popup dạng prompt */
.ma-prompt-label {
  display: grid;
  gap: 6px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.ma-prompt-label input {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

/* Modal xung đột khi mở lượt vote */
.ma-round-conflict-modal {
  width: min(100%, 560px);
}

.ma-round-conflict-warning {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--warn-border);
  border-radius: 12px;
  color: #7a2e0e;
  background: var(--warn-soft);
}

.ma-round-conflict-warning > span {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: #dc6803;
  font-weight: 800;
}

.ma-round-conflict-warning strong {
  display: block;
  color: #7a2e0e;
  font-size: 14px;
}

.ma-round-conflict-warning p {
  margin: 4px 0 0;
  color: var(--warn);
  font-size: 13px;
  line-height: 1.55;
}

.ma-round-conflict-flow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--muted);
  background: var(--soft);
  font-size: 12px;
  font-weight: 700;
}

.ma-round-conflict-flow span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ma-round-conflict-flow i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
}

.ma-round-conflict-flow .is-open {
  color: var(--danger);
}

.ma-round-conflict-flow .is-open i {
  background: var(--r);
  box-shadow: 0 0 0 3px #fee4e2;
}

.ma-round-conflict-flow b {
  color: var(--faint);
}

/* Modal đặt lại sự kiện */
.ma-reset-modal {
  width: min(100%, 580px);
}

.ma-reset-warning {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 18px 0 16px;
  padding: 14px;
  border: 1px solid var(--danger-border);
  border-radius: 12px;
  color: #912018;
  background: var(--danger-soft);
}

.ma-reset-warning > span {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--danger-strong);
  font-weight: 800;
}

.ma-reset-warning p {
  margin: 4px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.ma-reset-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0 0 0 22px;
  color: var(--ink-mid);
  font-size: 14px;
}

.ma-reset-confirm {
  display: grid;
  gap: 8px;
  margin-top: 20px;
  color: var(--ink-soft);
  font-weight: 700;
}

.ma-reset-confirm code {
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--danger);
  background: var(--danger-soft);
}

.ma-reset-confirm input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Modal thêm nhân sự / cấp quyền */
.ma-person-modal {
  width: min(100%, 560px);
}

.ma-person-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.ma-person-form .ma-span-2 {
  grid-column: 1 / -1;
}

.ma-person-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.ma-person-form input,
.ma-person-form select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.ma-person-form select {
  padding-right: 40px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 16px;
  appearance: none;
  -webkit-appearance: none;
}

.ma-person-form input:focus,
.ma-person-form select:focus {
  border-color: var(--r);
  outline: 2px solid rgba(227, 30, 36, 0.18);
  outline-offset: 1px;
}

.ma-field-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.ma-person-form .ma-modal-actions {
  grid-column: 1 / -1;
  margin-top: 6px;
}

.ma-grant-summary {
  display: grid;
  gap: 2px;
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--soft);
}

.ma-grant-summary strong {
  color: var(--ink);
  font-size: 14px;
}

.ma-grant-summary small {
  color: var(--muted);
  font-size: 12px;
}

/* --------------------------------------------------------------------------
   11. Quản lý team
   -------------------------------------------------------------------------- */
.ma-team-manager {
  margin-top: 16px;
  padding: 24px;
}

.ma-team-manager > header {
  align-items: end;
}

.ma-team-manager header p {
  max-width: 640px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

#ma-team-add {
  min-width: min(100%, 420px);
}

#ma-team-add label,
.ma-team-edit label {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-mid);
  font-size: 12px;
  font-weight: 700;
}

#ma-team-add > div {
  display: flex;
  gap: 8px;
}

#ma-team-add input,
.ma-team-edit input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
}

.ma-team-list {
  display: grid;
  gap: 8px;
  margin-top: 20px;
}

.ma-team-list article {
  display: grid;
  grid-template-columns: 52px minmax(180px, 1fr) minmax(190px, auto) auto;
  align-items: end;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--soft);
}

.ma-team-number {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 10px;
  color: var(--r);
  background: var(--brand-soft);
  font-weight: 800;
}

.ma-team-meta {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 8px;
}

.ma-team-meta span {
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--ink-mid);
  background: #eaecf0;
  font-size: 12px;
  font-weight: 600;
}

.ma-team-meta .scheduled {
  color: var(--success);
  background: var(--success-soft);
}

.ma-team-meta .unscheduled {
  color: var(--warn);
  background: var(--warn-soft);
}

.ma-team-actions {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 6px;
}

.ma-team-actions button {
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--ink-soft);
  background: var(--panel);
  font-weight: 700;
  cursor: pointer;
}

.ma-team-actions button.danger {
  border-color: var(--danger-border);
  color: var(--danger);
}

.ma-team-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   12. Tab Check-in: cổng, trạm, cửa sổ, miễn check-in, tài khoản quét QR
   -------------------------------------------------------------------------- */

/* Cổng văn nghệ */
.ma-gate header {
  align-items: flex-start;
}

.ma-gate p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.ma-gate.is-on {
  border-color: var(--success-border);
}

.ma-gate.is-off header h2 {
  color: var(--muted);
}

.ma-gate-status {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.ma-gate.is-on .ma-gate-status {
  color: #065f46;
  background: var(--success-soft);
}

.ma-gate.is-off .ma-gate-status {
  color: var(--warn);
  background: var(--warn-soft);
}

.ma-gate #ma-gate {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

/* Nút Bật cổng là hành động chính: gradient liền khối, không viền tóc. */
.ma-gate #ma-gate.ma-primary { border: 0; }

.ma-gate button.danger {
  color: var(--danger);
  border-color: var(--danger-border);
  background: var(--danger-soft);
}

.ma-gate button.danger:hover:not(:disabled) {
  border-color: #f97066;
  background: #fee4e2;
}

/* Lưới thẻ trạm */
.ma-check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.ma-check-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}

.ma-check-card.open {
  border-color: #f3a893;
  background: #fffaf8;
}

.ma-check-card.closed {
  background: var(--soft);
}

.ma-check-card small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.ma-check-card h2 {
  margin: 0;
  font-size: 18px;
}

.ma-check-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.ma-check-card .ma-check-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.ma-check-card button {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  cursor: pointer;
  font-weight: 700;
}

.ma-check-card button:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--soft);
}

.ma-check-card button.danger {
  color: var(--danger);
  border-color: var(--danger-border);
  background: var(--danger-soft);
}

.ma-check-card button.danger:hover:not(:disabled) {
  border-color: #f97066;
  background: #fee4e2;
}

.ma-check-fixed {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  padding: 0 12px;
  border-radius: 999px;
  color: #065f46;
  background: var(--success-soft);
  font-size: 13px;
  font-weight: 700;
}

/* Badge cửa sổ check-in của team */
.ma-window-badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ma-window-badge.live {
  color: var(--info);
  background: var(--info-soft);
  border: 1px solid var(--info-border);
}

.ma-window-badge.locked {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
}

.ma-window-badge.idle {
  color: var(--ink-mid);
  background: #f9fafb;
  border: 1px solid var(--border);
}

/* Form miễn check-in */
.ma-exempt-form {
  display: grid;
  gap: 12px;
  padding: 16px 20px 20px;
}

.ma-exempt-form label {
  display: grid;
  gap: 6px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}

.ma-exempt-form select,
.ma-exempt-form input {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}

/* Lọc danh sách nhân sự */
.ma-people-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.ma-people-filter select,
.ma-people-filter input {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
}

.ma-people-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* Chữ ghi chú trong ô thao tác phải cùng trục giữa với nút, không lệch lên đầu ô. */
.ma-people-actions .ma-cell-sub {
  display: inline-block;
  margin-top: 0;
  line-height: 3.4;
}

.ma-people-actions button {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.ma-people-actions button:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--soft);
}

.ma-people-panel {
  margin-top: 16px;
}

.ma-people-panel > header {
  justify-content: flex-start;
}

.ma-people-header-copy {
  min-width: 0;
  width: 100%;
}

.ma-people-header-copy > p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.ma-people-header-copy .ma-panel-actions {
  justify-content: flex-start;
  margin-top: 12px;
}

.ma-people-header-copy .ma-primary {
  margin-top: 0;
}

.ma-people-body {
  padding: 16px 20px 20px;
}

.ma-person-email,
.ma-person-team {
  overflow-wrap: anywhere;
}

.ma-person-status span {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--success);
  background: var(--success-soft);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

/* Form chọn tài khoản quét QR */
.ma-staff-form {
  display: grid;
  gap: 12px;
  padding: 16px 20px 20px;
}

.ma-staff-form > label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.ma-staff-form select {
  width: 100%;
  min-height: 44px;
  padding: 0 40px 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 16px;
  appearance: none;
  -webkit-appearance: none;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

/* Lưới chọn team cho tài khoản quét QR: 3 cột desktop, 2 cột mobile */
.ma-staff-teams {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.ma-staff-teams label {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--soft);
}

/* Ô tên + email trong bảng tài khoản quét QR */
.ma-staff-cell {
  display: grid;
  gap: 2px;
}

.ma-staff-cell small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.ma-staff-passwords ul {
  margin: 8px 0 0;
  padding: 0 0 0 18px;
}

.ma-scanner-cta header {
  align-items: center;
}

/* --------------------------------------------------------------------------
   13. Tab Trò chơi lớn
   -------------------------------------------------------------------------- */
.ma-games-panel select {
  min-height: 40px;
  width: 100%;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  font-size: 13px;
}

.ma-games-panel .ma-games-total td {
  border-top: 2px solid var(--border);
  background: #f9fafb;
}

.ma-ladder {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 20px 20px;
}

.ma-ladder-chip {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f9fafb;
  color: var(--ink-mid);
  font-size: 13px;
  font-weight: 700;
}

.ma-ladder-chip.rank-1 {
  color: #93610b;
  border-color: #fde29b;
  background: #fef0c7;
}

.ma-ladder-chip.rank-2 {
  color: var(--ink-mid);
  border-color: var(--border-strong);
  background: #f2f4f7;
}

.ma-ladder-chip.rank-3 {
  color: var(--warn);
  border-color: #f9dbaf;
  background: #fdf2ec;
}

.ma-ladder-chip.rank-4 {
  color: var(--info);
  border-color: var(--info-border);
  background: var(--info-soft);
}

.ma-ladder-chip.rank-5 {
  color: var(--success);
  border-color: var(--success-border);
  background: var(--success-soft);
}

.ma-ladder-chip.rank-6 {
  color: var(--faint);
  border-color: var(--border);
  background: #fff;
}

.ma-game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.ma-game-card header {
  align-items: center;
}

.ma-game-max {
  padding: 4px 10px;
  border-radius: 999px;
  color: var(--muted);
  background: #f9fafb;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.ma-game-rows {
  display: grid;
  gap: 10px;
  padding: 16px 20px 20px;
}

.ma-game-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ma-game-team {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.ma-game-team b {
  color: var(--ink);
}

.ma-game-row select {
  min-height: 40px;
  max-width: 170px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  font-size: 13px;
}

.ma-game-row select:hover {
  border-color: var(--border-strong);
}

.ma-game-points {
  min-width: 44px;
  text-align: right;
  color: var(--faint);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.ma-game-points.rank-1 {
  color: #93610b;
}

.ma-game-points.rank-2 {
  color: var(--ink-mid);
}

.ma-game-points.rank-3 {
  color: var(--warn);
}

.ma-game-points.rank-4 {
  color: var(--info);
}

.ma-game-points.rank-5 {
  color: var(--success);
}

.ma-game-points.rank-6 {
  color: var(--faint);
}

.ma-rank-chip {
  display: inline-block;
  margin-right: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--ink-mid);
  background: #f2f4f7;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.ma-rank-chip.rank-1 {
  color: #93610b;
  background: #fef0c7;
}

.ma-rank-chip.rank-2 {
  background: #eaecf0;
}

.ma-rank-chip.rank-3 {
  color: var(--warn);
  background: #fdf2ec;
}

.ma-rank-chip.rank-4 {
  color: var(--info);
  background: var(--info-soft);
}

.ma-rank-chip.rank-5 {
  color: var(--success);
  background: var(--success-soft);
}

.ma-rank-chip.rank-6 {
  color: var(--faint);
  background: #f9fafb;
}

/* --------------------------------------------------------------------------
   14. Tab Thi đua (awards)
   -------------------------------------------------------------------------- */
.ma-award {
  display: grid;
  gap: 0;
  padding: 0;
}

.ma-award-step {
  min-width: 0;
  padding: 20px;
}

.ma-award-step + .ma-award-step {
  border-top: 1px solid var(--border);
}

.ma-award-step h2 {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
}

.ma-award-step-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.ma-award-cat-actions {
  display: flex;
  gap: 8px;
}

.ma-award-cat-actions button {
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--r);
  background: var(--panel);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.ma-award-cat-actions button:hover:not(:disabled) {
  background: var(--soft);
}

.ma-award-cat-actions button.is-danger {
  color: var(--danger);
  border-color: var(--danger-border);
  background: var(--danger-soft);
}

.ma-award-cat-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ma-award select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--ink);
  background: var(--panel);
}

.ma-award-teams,
.ma-award-presets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.ma-award-teams {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ma-award-teams button,
.ma-award-presets button,
.ma-award-custom button {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--r);
  background: var(--panel);
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.ma-award-teams button {
  display: grid;
  align-content: center;
  gap: 2px;
}

.ma-award-teams button small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.ma-award-teams button:hover:not(:disabled):not(.is-selected),
.ma-award-presets button:hover:not(:disabled):not(.is-selected),
.ma-award-custom button:hover:not(:disabled):not(.is-selected) {
  border-color: var(--brand-border);
  background: var(--brand-softer);
}

.ma-award-teams button.is-selected,
.ma-award-presets button.is-selected {
  border: 0;
  color: #fff;
  background: var(--grad);
}

.ma-award-teams button.is-selected small {
  color: rgba(255, 255, 255, 0.86);
}

.ma-award-presets button.is-minus:not(.is-selected) {
  color: var(--danger);
}

.ma-award-presets button.is-zero {
  color: var(--ink-mid);
}

.ma-award-presets button.is-zero.is-selected {
  color: #fff;
  background: var(--ink-mid);
}

/* v1.9.15: trạng thái hạng mục thi đua (hoàn tất / đang chấm / trùng hạng) + cột Điểm Thi đua. */
.ma-thidua-summary .ma-thidua-formula {
  display: inline-flex;
  max-width: min(100%, 620px);
  min-height: 32px;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--ink-mid);
  background: var(--soft);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}

.ma-thidua-summary .ma-thidua-summary-copy {
  margin: 0;
  padding: 14px 20px 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.ma-thidua-status {
  display: inline-block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.ma-thidua-status.is-complete {
  color: var(--success);
}

.ma-thidua-status.is-duplicate {
  color: #b54708;
}

.ma-thidua-cat-chip {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  margin-left: 10px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--soft);
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
}

.ma-award-cat-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.ma-award-cat-row select {
  flex: 1 1 220px;
}

.ma-thidua-unscored {
  color: #98a2b3;
  font-weight: 600;
}

.ma-thidua-score-meta {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.ma-award-teams button:disabled,
.ma-award-presets button:disabled,
.ma-award-custom button:disabled,
.ma-award-custom input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ma-award-custom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 10px;
  margin-top: 12px;
}

.ma-award-custom input {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}

.ma-award-current {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.ma-cat-empty {
  margin: 0;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   15. Tổng điểm 4 trụ cột (thẻ lớn đầu tab Tổng quan)
   -------------------------------------------------------------------------- */
.ma-total-teams {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.ma-total-card {
  display: grid;
  gap: 4px;
  min-height: 132px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.04);
}

.ma-total-card small {
  color: var(--r);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.ma-total-card h2 {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.ma-total-card strong {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.ma-total-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

/* --------------------------------------------------------------------------
   16. Ô nhập thời gian inline (phút tự đóng)
   -------------------------------------------------------------------------- */
.ma-duration {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.ma-duration input {
  width: 64px;
  min-height: 40px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ma-duration input:hover {
  border-color: var(--border-strong);
}

.ma-duration input:focus {
  outline: 2px solid #f3a893;
  outline-offset: 1px;
}

/* --------------------------------------------------------------------------
   17. Trạng thái lỗi tải dữ liệu
   -------------------------------------------------------------------------- */
.ma-load-error {
  width: min(520px, calc(100% - 32px));
  margin: 64px auto;
  padding: 24px;
  border: 1px solid var(--danger-border);
  border-radius: 14px;
  color: var(--danger);
  background: var(--danger-soft);
  text-align: center;
}

.ma-load-error strong {
  font-size: 20px;
}

.ma-load-error p {
  color: #7a271a;
}

.ma-load-error button {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  background: var(--r);
  font-weight: 700;
  cursor: pointer;
}

@keyframes ma-spin {
  to { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   18. Đăng nhập dashboard (.ma-login + #ma-admin-login)
   -------------------------------------------------------------------------- */
.ma-login *,
.ma-login *::before,
.ma-login *::after {
  box-sizing: border-box;
}

.ma-login {
  --r: #e31e24;
  --o: #ff6a2c;
  --grad: linear-gradient(135deg, var(--r) 0%, #f04423 55%, var(--o) 100%);
  --ink: #111827;
  --muted: #667085;
  --page: #f5f5f7;
  --panel: #ffffff;
  --border: #e4e7ec;
  box-sizing: border-box;
  width: min(100%, 440px);
  margin: 48px auto;
  padding: 32px 24px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 20px 55px rgba(16, 24, 40, 0.08);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.4;
}

.ma-login img {
  display: block;
  width: 112px;
  height: auto;
}

.ma-login-kicker {
  margin: 16px 0 0;
  color: var(--r);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.ma-login h1 {
  margin: 8px 0 12px;
  color: var(--ink);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
}

.ma-login p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
}

.ma-login label {
  display: block;
  margin: 0 0 8px;
  color: #344054;
  font-size: 13px;
  font-weight: 600;
}

.ma-login-email {
  display: flex;
  min-height: 44px;
  margin: 0 0 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fafafc;
}

.ma-login-email input {
  min-width: 0;
  flex: 1;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--ink);
}

.ma-login-domain {
  display: flex;
  align-items: center;
  margin: 0 !important;
  border-left: 1px solid var(--border);
}

.ma-login-domain select {
  min-height: 42px;
  max-width: 196px;
  padding: 0 28px 0 12px;
  border: 0;
  border-radius: 0;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' stroke='%23667085' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 10px center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
}

.ma-login-domain select:focus-visible {
  outline: 3px solid rgba(227, 30, 36, 0.18);
  outline-offset: -3px;
}

.ma-login input[type="password"] {
  width: 100%;
  min-height: 44px;
  margin: 0 0 16px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fafafc;
  color: var(--ink);
}

.ma-login .ma-primary {
  width: 100%;
  min-height: 44px;
}

.ma-login .ma-primary[disabled] {
  opacity: 0.56;
}

.ma-login-error {
  margin: 0 0 12px !important;
  color: #b42318;
}

.ma-side-logout {
  min-height: 44px;
  margin-top: 8px;
}

/* Mobile: logout luôn hiện, không bị nav đẩy trôi. */
@media (max-width: 960px) {
  .ma-side {
    gap: 8px;
  }

  .ma-side-logout {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    margin: 0 0 0 auto;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
    color: var(--ink-soft);
    white-space: nowrap;
  }
}

@media (max-width: 560px) {
  .ma-login {
    width: calc(100% - 24px);
    margin: 16px auto;
    padding: 24px 16px;
  }
}

/* Theme-proof cho form đăng nhập dựng trong trang theme (shortcode). */
#ma-admin-login .ma-login-email {
  border: 1px solid var(--border) !important;
  background: #fafafc !important;
  box-shadow: none !important;
}

#ma-admin-login .ma-login-email input,
#ma-admin-login .ma-login-email input:hover,
#ma-admin-login .ma-login-email input:focus {
  border: 0 !important;
  outline: none;
  background: transparent !important;
  box-shadow: none !important;
  color: #111827 !important;
}

#ma-admin-login input[type="password"] {
  border: 1px solid var(--border) !important;
  background: #fafafc !important;
  box-shadow: none !important;
  color: #111827 !important;
}

#ma-admin-login .ma-login-email:focus-within,
#ma-admin-login input[type="password"]:focus {
  border-color: #e31e24 !important;
  box-shadow: 0 0 0 3px rgba(227, 30, 36, 0.16) !important;
}

#ma-admin-login .ma-primary,
#ma-admin-login .ma-primary:hover,
#ma-admin-login .ma-primary:focus,
#ma-admin-login .ma-primary:active {
  border: 0 !important;
  color: #fff !important;
  background: linear-gradient(135deg, #e31e24 0%, #f04423 55%, #ff6a2c 100%) !important;
  box-shadow: 0 7px 18px rgba(227, 30, 36, 0.22) !important;
  font-weight: 700;
}

#ma-admin-login .ma-primary:hover {
  filter: brightness(1.06);
}

#ma-admin-login .ma-primary:active {
  filter: brightness(0.96);
}

#ma-admin-login .ma-primary[disabled],
#ma-admin-login .ma-primary[disabled]:hover {
  opacity: 0.56;
  filter: none;
}

/* --------------------------------------------------------------------------
   19. Loader bánh xe thương hiệu (dùng chung 3 nơi dựng dashboard)
   -------------------------------------------------------------------------- */
.mac-admin-loading {
  display: grid;
  justify-items: center;
  gap: 18px;
  padding: 72px 16px;
}

.mac-loader-wheel {
  position: relative;
  width: 120px;
  height: 120px;
}

.mac-loader-spoke {
  position: absolute;
  inset: 0;
  transform: rotate(var(--rot));
}

/* Bi nằm trên vành khuyên (đỉnh spoke đã xoay), pulse tuần tự tạo hiệu ứng đuổi. */
.mac-loader-ball {
  position: absolute;
  top: 0;
  left: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e31e24 0%, #ff6a2c 100%);
  box-shadow: 0 2px 8px rgba(227, 30, 36, 0.35);
  animation: mac-loader-ball 1.8s ease-in-out infinite;
  animation-delay: calc(var(--delay) * -1);
}

@keyframes mac-loader-ball {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(0.72);
    opacity: 0.25;
  }
}

.mac-admin-loading-text {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   20. Chế độ chỉ đọc
   -------------------------------------------------------------------------- */
.mac-admin-app.is-readonly .ma-reveal-actions,
.mac-admin-app.is-readonly .ma-reveal-footer button,
.mac-admin-app.is-readonly .ma-panel > header > b,
.mac-admin-app.is-readonly .ma-permalink-warning a {
  display: none !important;
}

/* --------------------------------------------------------------------------
   21. Hardening body.mac-admin-public-page — chống theme đè giao diện
   -------------------------------------------------------------------------- */
body.mac-admin-public-page {
  margin: 0 !important;
  padding: 0 !important;
  background: #f5f5f7 !important;
}

body.mac-admin-public-page .site-header,
body.mac-admin-public-page .site-footer,
body.mac-admin-public-page #masthead,
body.mac-admin-public-page #colophon,
body.mac-admin-public-page header.wp-block-template-part,
body.mac-admin-public-page footer.wp-block-template-part,
body.mac-admin-public-page .elementor-location-header,
body.mac-admin-public-page .elementor-location-footer,
body.mac-admin-public-page [data-elementor-type="header"],
body.mac-admin-public-page [data-elementor-type="footer"],
body.mac-admin-public-page .page-header,
body.mac-admin-public-page .entry-title,
body.mac-admin-public-page .wp-block-post-title {
  display: none !important;
}

body.mac-admin-public-page .site-main,
body.mac-admin-public-page .site-content,
body.mac-admin-public-page .page-content,
body.mac-admin-public-page .entry-content,
body.mac-admin-public-page .wp-block-post-content {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

body.mac-admin-public-page .mac-admin-app {
  color: #111827 !important;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
}

body.mac-admin-public-page .ma-layout {
  min-height: 100vh;
  min-height: 100svh;
}

body.mac-admin-public-page .ma-side {
  top: 0;
  height: 100vh;
  height: 100svh;
}

body.mac-admin-public-page .ma-panel {
  border: 1px solid #e4e7ec !important;
  border-radius: 14px !important;
  background: #fff !important;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.05) !important;
}

/* Nút trung tính — giữ nền trắng, viền chuẩn.
   KHÔNG áp cho tab sidebar/subnav (cần nền trong suốt + active đỏ)
   và không áp cho nút đặt lại sự kiện (cần màu danger). */
body.mac-admin-public-page .mac-admin-app .ma-primary,
body.mac-admin-public-page .ma-login .ma-primary,
body.mac-admin-public-page .ma-top-actions button:not(.ma-reset-trigger),
body.mac-admin-public-page .ma-people-actions button,
body.mac-admin-public-page .ma-award-presets button,
body.mac-admin-public-page .ma-award-teams button,
body.mac-admin-public-page .ma-check-card button,
body.mac-admin-public-page .ma-gate #ma-gate {
  font-family: inherit !important;
  font-size: 14px !important;
  border-radius: 12px !important;
  cursor: pointer !important;
}

body.mac-admin-public-page .ma-top-actions button:not(.ma-primary):not(.ma-reset-trigger),
body.mac-admin-public-page .ma-people-actions button:not(.ma-primary),
body.mac-admin-public-page .ma-check-card button:not(.ma-primary):not(.danger),
body.mac-admin-public-page .ma-gate #ma-gate:not(.ma-primary):not(.danger) {
  border: 1px solid #e4e7ec !important;
  background: #fff !important;
  color: #111827 !important;
  box-shadow: none !important;
}

/* Tab sidebar / subnav — không border, chữ xám; active đỏ mềm như bản gốc. */
body.mac-admin-public-page .ma-side nav button,
body.mac-admin-public-page .ma-subnav button {
  border: 0 !important;
  background: transparent !important;
  color: #667085 !important;
  box-shadow: none !important;
}

body.mac-admin-public-page .ma-side nav button:hover,
body.mac-admin-public-page .ma-subnav button:hover {
  color: #111827 !important;
  background: #fafafc !important;
}

body.mac-admin-public-page .ma-side nav button.active,
body.mac-admin-public-page .ma-subnav button.active {
  color: #e31e24 !important;
  background: #fff4f0 !important;
  box-shadow: inset 0 0 0 1px #fed7cc !important;
}

/* Nút đặt lại sự kiện — danger đỏ đậm, nổi bật như bản gốc. */
body.mac-admin-public-page .ma-reset-trigger {
  border: 1px solid #fecdca !important;
  color: #b42318 !important;
  background: #fff !important;
}

body.mac-admin-public-page .ma-reset-trigger:hover {
  border-color: #f97066 !important;
  background: #fef3f2 !important;
}

/* Nút nguy hiểm / reset trigger. */
body.mac-admin-public-page .ma-check-card button.danger,
body.mac-admin-public-page .ma-gate button.danger {
  color: #b42318 !important;
  border: 1px solid #fecdca !important;
  background: #fef3f2 !important;
}

/* Nút chính — gradient thương hiệu. */
body.mac-admin-public-page .mac-admin-app .ma-primary,
body.mac-admin-public-page .ma-login .ma-primary {
  border: 0 !important;
  color: #fff !important;
  background: linear-gradient(135deg, #e31e24 0%, #f04423 55%, #ff6a2c 100%) !important;
  font-weight: 700 !important;
}

/* Bảng. */
body.mac-admin-public-page .ma-board-table,
body.mac-admin-public-page .ma-people-table {
  border: 1px solid #e4e7ec !important;
  border-radius: 12px !important;
  background: #fff !important;
}

body.mac-admin-public-page .ma-board-table th,
body.mac-admin-public-page .ma-board-table td,
body.mac-admin-public-page .ma-people-table th,
body.mac-admin-public-page .ma-people-table td {
  border-color: #e4e7ec !important;
  color: #111827 !important;
  font-size: 12px !important;
}

/* Ô nhập liệu. */
body.mac-admin-public-page .mac-admin-app input,
body.mac-admin-public-page .mac-admin-app select {
  border: 1px solid #e4e7ec !important;
  background: #fff !important;
  color: #111827 !important;
  font-family: inherit !important;
}

/* Link sidebar. */
body.mac-admin-public-page .ma-side-links a,
body.mac-admin-public-page .ma-side > a {
  color: #475467 !important;
  font-weight: 600 !important;
  text-decoration: none !important;
}

/* --------------------------------------------------------------------------
   22. Responsive — gộp một chỗ, giảm dần breakpoint
   -------------------------------------------------------------------------- */
@media (max-width: 1180px) {
  .ma-total-teams {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .ma-chart {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .ma-award-teams,
  .ma-award-presets {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  .ma-layout {
    grid-template-columns: 1fr;
  }

  .ma-side {
    position: sticky;
    top: 32px;
    z-index: 100;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 10px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .ma-brand {
    display: none;
  }

  .ma-side nav {
    display: flex;
    margin: 0;
  }

  .ma-side > a {
    margin: 0 0 0 auto;
  }

  .ma-side-links {
    display: none;
  }

  .ma-grid,
  .ma-data,
  .ma-reveal-grid {
    grid-template-columns: 1fr;
  }

  .ma-team-manager > header {
    align-items: flex-start;
  }

  .ma-team-list article {
    grid-template-columns: 52px minmax(180px, 1fr) auto;
  }

  .ma-team-meta {
    grid-column: 2 / 3;
  }

  body.mac-admin-public-page .ma-side {
    height: auto;
  }

  .ma-side-logout {
    margin: 0 0 0 auto;
  }
}

@media (max-width: 900px) {
  .ma-check-grid {
    grid-template-columns: 1fr;
  }
}

/* Thanh tab nằm dưới admin bar (admin bar cao 46px từ 782px trở xuống). */
@media (max-width: 782px) {
  .ma-side {
    top: 46px;
  }
}

@media (max-width: 700px) {
  .ma-total-teams {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ma-chart {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding: 12px 12px 18px;
  }

  .ma-chart-col {
    min-height: 210px;
  }

  .ma-chart-track {
    height: 120px;
  }

  .ma-check-grid {
    grid-template-columns: 1fr;
  }

  .ma-panel > header {
    flex-wrap: wrap;
  }

  .ma-panel > header > a,
  .ma-panel > header > button {
    width: 100%;
    justify-content: center;
  }

  /* Mobile: cột team co đúng bằng tên đội dài nhất (width: 1px + nowrap =
     shrink-to-fit), khoảng trống còn lại dồn cho các cột số nên mọi bảng
     cùng nội dung team luôn thẳng hàng với nhau. */
  .ma-board-table table {
    table-layout: auto;
  }

  .ma-board-table th:first-child,
  .ma-board-table td:first-child {
    width: 1px;
    min-width: 0;
    white-space: nowrap;
  }

  /* Mobile: bảng tổng kết ẩn cột hạng, chỉ giữ cột team. */
  .ma-board-table.ma-pin-2 th:first-child,
  .ma-board-table.ma-pin-2 td:first-child {
    display: none;
  }

  .ma-board-table.ma-pin-2 th:nth-child(2),
  .ma-board-table.ma-pin-2 td:nth-child(2) {
    left: 0;
    width: 1px;
    min-width: 0;
    white-space: nowrap;
  }

  /* Mobile: nút màn hình trình chiếu xuống hàng như các nút khác. */
  .ma-art-block-head {
    flex-wrap: wrap;
  }

  .ma-art-block-head .ma-screen-link {
    width: 100%;
  }

  .ma-staff-teams {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* v1.9.16: mobile — nút QR cá nhân căn trái đồng bộ, tab Thi đua gọn khoảng cách. */
  .ma-panel-actions {
    justify-content: flex-start;
  }

  .ma-thidua-summary .ma-thidua-formula {
    width: 100%;
    white-space: normal;
    max-width: 100%;
    border-radius: 12px;
    overflow-wrap: anywhere;
  }

  .ma-thidua-summary > header {
    align-items: stretch;
    flex-direction: column;
  }

  .ma-thidua-summary .ma-thidua-summary-copy {
    padding: 12px 20px 20px;
  }

  .ma-award-cat-row .ma-thidua-cat-chip {
    width: 100%;
    margin-left: 0;
    border-radius: 12px;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .ma-award-step {
    padding: 16px 14px;
  }

  .ma-award-step-head {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .ma-award-cat-actions {
    margin-left: auto;
  }

  .ma-award-cat-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .ma-award-cat-row select {
    width: 100%;
    min-width: 0;
  }

  .ma-award-teams {
    grid-template-columns: 1fr;
  }

  .ma-award-presets {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
}

@media (max-width: 600px) {
  .mac-admin-wrap {
    margin-left: -10px;
  }

  .ma-content {
    padding: 18px 10px 40px;
  }

  .ma-side {
    overflow: auto;
    top: 0;
  }

  .ma-side button {
    white-space: nowrap;
  }

  .ma-side > a {
    display: none;
  }

  .ma-side-links {
    display: none;
  }

  .ma-top {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .ma-top-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .ma-top-actions button {
    flex: 1 1 150px;
  }

  .ma-top h1 {
    font-size: 24px;
  }

  .ma-screen-link {
    width: 100%;
  }

  .ma-reveal-control,
  .ma-reveal-scoreboard {
    padding: 18px;
  }

  .ma-reveal-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .ma-reveal-footer button {
    width: 100%;
  }

  .ma-stats {
    grid-template-columns: 1fr 1fr;
  }

  .ma-stats article:last-child {
    grid-column: 1 / -1;
  }

  .ma-slots {
    grid-template-columns: 1fr;
  }

  .ma-modal {
    padding: 10px;
  }

  .ma-modal-card {
    padding: 18px;
    border-radius: 14px;
  }

  .ma-modal-actions {
    flex-direction: column-reverse;
  }

  .ma-modal-actions button {
    width: 100%;
  }

  .ma-team-manager {
    padding: 18px;
  }

  #ma-team-add,
  #ma-team-add > div {
    width: 100%;
  }

  #ma-team-add > div {
    align-items: stretch;
    flex-direction: column;
  }

  .ma-team-list article {
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: start;
  }

  .ma-team-number {
    width: 40px;
    height: 40px;
  }

  .ma-team-meta,
  .ma-team-actions {
    grid-column: 2 / -1;
  }

  .ma-team-meta {
    min-height: 0;
    flex-wrap: wrap;
  }

  .ma-ballot-detail[open] > div {
    min-width: 220px;
  }

  .ma-round-controls {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }

  .ma-round-controls button {
    flex: 1 1 140px;
  }

  .ma-people-header-copy .ma-panel-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .ma-people-header-copy .ma-panel-actions button {
    width: 100%;
  }

  .ma-people-body {
    padding: 14px;
  }

  .ma-people-filter {
    display: grid;
    grid-template-columns: 1fr;
  }

  .ma-people-filter select,
  .ma-people-filter input {
    width: 100%;
    min-width: 0;
  }

  .ma-people-table {
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  .ma-people-table table,
  .ma-people-table tbody {
    display: block;
    width: 100%;
  }

  .ma-people-table thead {
    display: none;
  }

  .ma-people-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 12px;
    margin-bottom: 10px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--panel);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  }

  .ma-people-table td {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
    font-size: 13px;
  }

  .ma-people-table .ma-person-name,
  .ma-people-table .ma-person-email,
  .ma-people-table .ma-people-actions,
  .ma-people-table .ma-people-empty td {
    grid-column: 1 / -1;
  }

  .ma-people-table .ma-person-name strong {
    display: block;
    font-size: 15px;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }

  .ma-people-table .ma-person-email {
    color: var(--muted);
    overflow-wrap: anywhere;
  }

  .ma-people-table .ma-person-team {
    color: var(--ink-soft);
    font-weight: 600;
  }

  .ma-people-table .ma-person-status {
    justify-self: end;
  }

  .ma-people-table .ma-people-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 6px;
  }

  .ma-people-table .ma-people-actions button {
    min-width: 0;
    min-height: 44px;
    padding: 6px 8px;
    line-height: 1.25;
    white-space: normal;
  }

  .ma-people-table .ma-people-empty {
    display: block;
    color: var(--muted);
  }

  .ma-panel .ma-board-table {
    margin: 10px 10px 14px;
  }
}

@media (max-width: 560px) {
  .ma-person-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 430px) {
  .ma-chart {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ma-people-table .ma-people-actions {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mac-admin-app *,
  .mac-admin-app *::before,
  .mac-admin-app *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }

  .mac-loader-ball {
    animation: none;
  }
}

/* v1.10.0 — Phân xe + điểm danh trên xe.
   Chuẩn Premium: spacing 4/8/12/16/20/24, radius 10-12, touch target ≥ 40-44px,
   input/select/button đồng bộ token --border/--panel/--ink. */
.ma-bus-note {
  margin: 0;
  padding: 12px 20px 16px;
  color: var(--ink-soft);
  font-size: 13px;
}

.ma-bus-control .ma-reveal-actions { padding: 16px 20px 20px; }

tr.is-selected td { background: rgba(227, 30, 36, 0.05); }

[data-bus-manifest] {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  font: inherit;
  font-weight: 700;
  color: var(--r);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

[data-bus-manifest]:hover { background: rgba(227, 30, 36, 0.06); }

/* Tab chọn xe — manifest lúc nào cũng đủ 5 xe. */
.ma-bus-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 16px 20px 0;
}

.ma-bus-tabs button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.ma-bus-tabs button small {
  color: #667085;
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.ma-bus-tabs button.active {
  border-color: transparent;
  background: var(--grad);
  color: #fff;
}

.ma-bus-tabs button.active small { color: rgba(255, 255, 255, 0.82); }

.ma-bus-manifest .ma-bus-tools {
  padding: 0;
  border-top: 0;
}

.ma-bus-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

/* Hai ô tìm/thêm người luôn full-width, không làm lệch nhịp trong form. */
#ma-bus-any-query,
#ma-bus-manual {
  display: block;
  width: 100%;
}

/* Khoảng cách giữa các khối lớn trong tab Phân xe: 24px theo Premium scale. */
.ma-bus-control + .ma-bus-manifest,
.ma-bus-manifest + .ma-panel,
.ma-bus-control + .ma-panel {
  margin-top: 24px;
}

.ma-bus-tools input[type="search"],
.ma-bus-add input[type="search"],
.ma-bus-add input[type="text"],
.ma-guide-form input {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ma-bus-tools input[type="search"] { flex: 1; min-width: 160px; }

.ma-bus-add select,
.ma-guide-form select {
  width: 100%;
  min-height: 44px;
  padding: 0 40px 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 16px;
  appearance: none;
  -webkit-appearance: none;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
}

.ma-bus-tools input:focus,
.ma-bus-add input:focus,
.ma-bus-add select:focus,
.ma-guide-form input:focus,
.ma-guide-form select:focus {
  border-color: var(--border-strong, #98a2b3);
  outline: none;
  box-shadow: 0 0 0 3px rgba(227, 30, 36, 0.12);
}

.ma-bus-add {
  display: grid;
  gap: 24px;
  padding: 24px;
  border-top: 1px solid var(--border);
  background: transparent;
}

/* Mỗi nhóm thêm người: tiêu đề dính khối với ô tìm + danh sách tick (12px),
   các nhóm cách nhau 24px theo nhịp Premium của form cha. */
.ma-bus-add-group {
  display: grid;
  gap: 12px;
}

/* Nút chính tab Phân xe: gradient đỏ–cam trên mọi màn hình. */
.ma-bus-add .ma-primary,
#ma-rollcall-new {
  min-height: 44px;
  padding: 0 15px;
  border: 0;
  color: #fff;
  background: var(--grad);
  box-shadow: var(--shadow-grad);
  font-size: 14px;
  font-weight: 700;
}

.ma-guide-form {
  display: grid;
  gap: 12px;
  padding: 16px 20px 20px;
  border-top: 1px solid var(--border);
}

@media (min-width: 720px) and (max-width: 1024px) {
  /* Tablet: form HDV xếp 2 hàng cho khỏi nát ô nhập. */
  .ma-guide-form { grid-template-columns: 1fr 1fr; }
  .ma-guide-form .ma-primary { grid-column: 1 / -1; }
}

@media (min-width: 1025px) {
  .ma-guide-form { grid-template-columns: repeat(4, 1fr) auto; align-items: end; }
}

/* Cột thao tác bảng xe: nút cùng trục trái với tiêu đề cột, không lệch phải. */
.ma-bus-control td.ma-bus-actions { justify-content: flex-start; }

/* Select trong bảng trơn (đổi xe HDV, gán xe tự túc / chưa phân xe): đúng chuẩn select hệ thống. */
td select[data-guide-bus],
td select[data-self-assign],
td select[data-unassigned-assign] {
  width: 100%;
  min-width: 132px;
  max-width: 220px;
  min-height: 44px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 16px;
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

td select[data-guide-bus]:focus,
td select[data-self-assign]:focus,
td select[data-unassigned-assign]:focus {
  border-color: var(--border-strong, #98a2b3);
  outline: none;
  box-shadow: 0 0 0 3px rgba(227, 30, 36, 0.12);
}

/* Ô Đi kèm bảng TỰ TÚC: chip đếm + dropdown danh sách tên gọn đẹp. */
.ma-companions {
  position: relative;
  display: inline-block;
}

.ma-companions summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--soft);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.ma-companions summary::-webkit-details-marker { display: none; }

.ma-companions summary::after {
  content: "▾";
  color: var(--muted);
  font-size: 10px;
}

.ma-companions[open] summary {
  border-color: var(--brand-border, #f3b4b6);
  background: var(--brand-softer, #fdf1f1);
  color: var(--r);
}

.ma-companions-count { font-variant-numeric: tabular-nums; }

.ma-companions-pop {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  max-width: 320px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 12px 32px rgba(16, 24, 40, 0.14);
}

.ma-companions-pop ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 4px;
}

.ma-companions-pop li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--soft);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.ma-companions-pop li::before {
  content: "•";
  color: var(--r);
  font-weight: 800;
}

.ma-companions-none { color: var(--muted); }

.ma-guide-form label {
  display: grid;
  gap: 6px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}

/* Pick item luôn flex ngang: checkbox + tên trên một hàng. */
.ma-bus-add .ma-pick-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ma-bus-add .ma-primary,
.ma-guide-form .ma-primary { margin-top: 0; }

.ma-bus-add .ma-primary { justify-self: start; }

.ma-bus-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
}

.ma-bus-actions select {
  max-width: 116px;
  min-height: 44px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center / 14px;
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
}

/* Nút tick điểm danh nhanh trong manifest. */
.ma-roll-mini {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: #667085;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.ma-roll-mini.is-present {
  border-color: #75e0a7;
  background: #ecfdf3;
  color: #067647;
}

.ma-bus-filters {
  display: flex;
  gap: 6px;
}

.ma-bus-filters button {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.ma-bus-filters button.active {
  border-color: var(--r);
  background: rgba(227, 30, 36, 0.08);
  color: var(--r);
}

.ma-roll-list {
  list-style: none;
  margin: 0;
  padding: 4px 12px 12px;
  display: grid;
  gap: 6px;
}

.ma-roll-row {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  font: inherit;
  font-weight: 600;
  color: #344054;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.ma-roll-row.is-present {
  border-color: #75e0a7;
  background: #ecfdf3;
  color: #067647;
}

.ma-roll-divider {
  margin: 16px 16px 4px;
  color: #98a2b3;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.ma-bus-history {
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
}

.ma-bus-history small {
  color: #98a2b3;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.ma-bus-history ul {
  margin: 6px 0 0;
  padding-left: 16px;
  color: var(--ink-soft);
  font-size: 13px;
}

/* Header manifest: tiêu đề trái + công cụ phải thẳng hàng, mobile xếp dọc. */
.ma-bus-manifest > header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#ma-rollcall-new { margin-top: 0; }

@media (max-width: 720px) {
  .ma-bus-manifest > header { align-items: stretch; flex-direction: column; }
  .ma-bus-manifest .ma-bus-tools { width: 100%; }
}

/* Form thêm BTC/Hoa tiêu: chọn nhiều người cùng lúc. */
.ma-bus-add-head {
  display: grid;
  gap: 2px;
}

.ma-bus-add-head span {
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.ma-bus-add-head small {
  color: #667085;
  font-size: 12px;
}

.ma-bus-pick {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 10px;
  max-height: 264px;
  overflow-y: auto;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--soft, #fafafc);
}

.ma-pick-item {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

/* Số team đẩy về cuối hàng để cột #thẳng hàng, không dính sát tên người. */
.ma-pick-item small {
  margin-left: auto;
  color: #667085;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ma-pick-item:hover {
  border-color: var(--brand-border);
  background: var(--brand-softer);
}

.ma-pick-item:focus-within,
.ma-pick-item:has(input:checked) {
  border-color: var(--r);
  background: var(--brand-soft);
  box-shadow: 0 0 0 3px rgba(227, 30, 36, 0.1);
  color: var(--ink);
}

.ma-pick-item input {
  width: 18px;
  height: 18px;
  accent-color: var(--r);
}

.ma-pick-empty {
  margin: 0;
  color: #667085;
  font-size: 13px;
}

/* Nút xóa khỏi xe: rõ ràng, chạm thoải mái. */
.ma-bus-actions .danger {
  width: 44px;
  height: 44px;
  border: 1px solid #fecdca;
  border-radius: 12px;
  background: #fef3f2;
  color: #b42318;
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.ma-bus-actions .danger:hover { background: #fee4e2; }

.ma-cell-empty {
  color: #667085;
  font-size: 12.5px;
  font-weight: 500;
}

.ma-bus-ghost,
.ma-bus-ghost-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 15px;
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  text-decoration: none;
}

.ma-bus-ghost {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink-soft);
}

.ma-bus-ghost:hover { border-color: var(--border-strong, #98a2b3); }

.ma-bus-export-all {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.ma-bus-ghost.is-disabled {
  pointer-events: none;
  opacity: 0.48;
  cursor: not-allowed;
}

.ma-bus-ghost:focus-visible {
  outline: 3px solid rgba(227, 30, 36, 0.2);
  outline-offset: 2px;
}

.ma-bus-ghost-danger {
  border: 1px solid #fecdca;
  background: #fef3f2;
  color: #b42318;
}

.ma-bus-ghost-danger:hover { background: #fee4e2; }

/* Ô sức chứa tối đa mỗi xe: gọn trong ô bảng nhưng vẫn chạm thoải mái 44px. */
.ma-bus-control input[type="number"] {
  width: 76px;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ma-bus-control input[type="number"]:focus {
  border-color: var(--border-strong, #98a2b3);
  outline: none;
  box-shadow: 0 0 0 3px rgba(227, 30, 36, 0.12);
}

/* Mobile: bảng bus gọn, nút giữ font 14px đồng bộ toàn hệ thống. */
@media (max-width: 720px) {
  .ma-bus-control .ma-board-table table { min-width: 720px; }

  .ma-bus-export-all { justify-items: stretch; width: 100%; }

  .ma-bus-add { padding: 16px; }

  .ma-bus-add .ma-primary { width: 100%; }

  /* Manifest mobile: chỉ giữ Họ tên + tick + chuyển xe + xóa. */
  .ma-bus-manifest .ma-board-table table { min-width: 0; }

  .ma-bus-manifest .ma-board-table th:nth-child(2),
  .ma-bus-manifest .ma-board-table td:nth-child(2),
  .ma-bus-manifest .ma-board-table th:nth-child(3),
  .ma-bus-manifest .ma-board-table td:nth-child(3) {
    display: none;
  }
}
@media (max-width: 960px) {
  .ma-side nav {
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
  }

  .ma-side nav button { flex: 0 0 auto; }

  .ma-side-logout {
    flex: 0 0 auto;
    margin: 0 0 0 8px;
  }
}
