/* ==========================================================================
   Check tương tác — dùng lại token + component của July CONTROL (style.css /
   admin.css). File này chỉ bổ sung layout riêng của trang: grid 2 cột, danh
   sách box, segmented, stepper, badge xếp hạng, avatar, thanh tương tác.
   ========================================================================== */

/* ---------- Layout 2 cột ---------- */

.checktt-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.checktt-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hidden { display: none !important; }

/* ---------- Status line dưới tiêu đề ---------- */

#statusLine {
  display: flex;
  align-items: center;
  gap: 7px;
}

#statusLine.loading .status-dot { background: var(--warning); }
#statusLine.error .status-dot { background: var(--danger); }

/* ---------- Switch tự làm mới ---------- */

.ctt-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  padding: 0 4px;
}

.ctt-switch input { position: absolute; opacity: 0; pointer-events: none; }

.ctt-switch-track {
  position: relative;
  width: 34px;
  height: 19px;
  flex-shrink: 0;
  border-radius: 9999px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  transition: background 150ms ease, border-color 150ms ease;
}

.ctt-switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 150ms ease, background 150ms ease;
}

.ctt-switch input:checked + .ctt-switch-track {
  background: var(--primary-bg);
  border-color: var(--primary);
}

.ctt-switch input:checked + .ctt-switch-track::after {
  transform: translateX(15px);
  background: var(--primary);
}

.ctt-switch-label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ---------- Danh sách box ---------- */

.boxlist-card {
  position: sticky;
  top: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 120px);
}

.ctt-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  background: var(--primary-bg);
  color: var(--primary);
  font-size: 11px;
  font-weight: 510;
  white-space: nowrap;
}

.search-input-wrap { position: relative; margin-bottom: 12px; }

/* admin.css đặt .search-input-wrap { flex: 1 } cho filter-bar NGANG —
   trong card dọc (drawer box list) nó làm ô tìm kiếm giãn cao chiếm nửa drawer.
   Khóa lại chiều cao tự nhiên. */
.boxlist-card .search-input-wrap { flex: 0 0 auto; min-width: 0; }

.search-input-wrap .search-input {
  width: 100%;
  padding: 9px 34px 9px 34px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-hover);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 130ms ease;
  appearance: none;
  -webkit-appearance: none;
}

.search-input-wrap .search-input::placeholder { color: var(--text-muted); }

.search-input-wrap .search-input:focus {
  border-color: var(--primary);
}

.search-input-wrap .search-input::-webkit-search-cancel-button { display: none; }

.search-input-wrap .input-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  display: none;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
}

.search-input-wrap .input-clear:hover { color: var(--text); }
.search-input-wrap .input-clear svg,
.search-input-wrap .input-clear i { width: 13px; height: 13px; }

.search-input-wrap .search-input:not(:placeholder-shown) ~ .input-clear { display: inline-flex; }

.box-list {
  flex: 1;
  min-height: 180px;
  overflow-y: auto;
  margin: 0 -6px;
  padding: 0 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--elev-border) transparent;
}

.box-list::-webkit-scrollbar { width: 6px; }
.box-list::-webkit-scrollbar-thumb { background: var(--elev-border); border-radius: 9999px; }

.box-item {
  width: 100%;
  margin-bottom: 4px;
  padding: 10px 11px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 130ms ease, border-color 130ms ease;
}

.box-item:hover { background: var(--surface-hover); }

.box-item.active {
  background: var(--primary-bg);
  border-color: color-mix(in srgb, var(--primary) 40%, transparent);
}

.box-avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface-hover);
  border: 1px solid var(--border);
}

.box-item.active .box-avatar {
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  border-color: transparent;
}

/* Ảnh avatar phủ kín khung, giữ tỷ lệ — không bao giờ bị méo */
.box-avatar img,
.member-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}

.box-item-text { flex: 1; min-width: 0; }

.box-name {
  display: block;
  font-size: 13px;
  font-weight: 510;
  letter-spacing: -0.011em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.box-sub {
  display: block;
  margin-top: 1px;
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ctt-skeleton-group { display: flex; flex-direction: column; gap: 10px; padding: 4px 2px; }
.ctt-skeleton-group .skeleton-line { border-radius: 8px; animation: skeletonPulse 1.4s ease infinite; }

/* ---------- Thread head ---------- */

.thread-head { padding: 2px 2px 0; }

.thread-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.thread-title-row h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 510;
  letter-spacing: -0.015em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-avatar {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 10px;
  object-fit: cover;
  background: var(--surface-hover);
  border: 1px solid var(--border);
}

.thread-meta {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--text-muted);
}

.link-btn {
  padding: 0;
  border: none;
  background: none;
  color: var(--primary);
  font-size: 12.5px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.link-btn i {
  font-size: 13px;
  line-height: 1;
}

.link-btn:hover { text-decoration: underline; }

/* ---------- Stats ---------- */

/* 6 thẻ thống kê xếp 3 trên + 3 dưới — tránh ép 6 cột làm số liệu tràn card */
.stats-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* Nhãn dài (Ứng viên locmem) tự lùi thành ... thay vì tràn ra ngoài card */
.stat-card-top { gap: 8px; }
.stat-card-top .label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Control card ---------- */

.control-card {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.control-group { display: flex; align-items: center; gap: 10px; }
.control-spacer { flex: 1; }
.control-actions { display: flex; align-items: center; gap: 8px; }

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-hover);
}

.seg-btn {
  padding: 5px 13px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 400;
  cursor: pointer;
  transition: background 130ms ease, color 130ms ease;
}

.seg-btn:hover { color: var(--text); }

.seg-btn.active {
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 510;
}

.stepper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-hover);
  overflow: hidden;
}

.stepper button {
  width: 32px;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  transition: background 130ms ease, color 130ms ease;
}

.stepper button:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }

.stepper input {
  width: 54px;
  padding: 7px 2px;
  border: none;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 510;
  text-align: center;
  outline: none;
  appearance: textfield;
  -moz-appearance: textfield;
}

.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- Locmem card (Web → Bot) ---------- */

.locmem-card {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-color: color-mix(in srgb, var(--danger) 30%, var(--border));
}

.locmem-main { min-width: 0; }

.locmem-main code {
  display: inline-block;
  margin-top: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--danger-bg);
  color: var(--danger);
  font-family: var(--mono);
  font-size: 12.5px;
}

.locmem-main p {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 12px;
  max-width: 520px;
}

.bot-status {
  display: none;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 2px;
  color: var(--text-muted);
  font-size: 12px;
}

.bot-status.show { display: flex; }

.cmd-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 510;
  white-space: nowrap;
}

.cmd-chip.pending { background: var(--warning-bg); color: var(--warning); }
.cmd-chip.sent { background: var(--success-bg); color: var(--success); }
.cmd-chip.failed,
.cmd-chip.expired { background: var(--danger-bg); color: var(--danger); }

/* ---------- Table card ---------- */

.table-card { padding: 0; overflow: hidden; }

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

.member-search { flex: 1; min-width: 200px; max-width: 300px; margin-bottom: 0; }

.ctt-select-wrap { position: relative; }

.ctt-select-wrap .ctt-select-arrow {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.ctt-select-wrap select {
  padding: 8px 32px 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-hover);
  color: var(--text-secondary);
  font-size: 12.5px;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 130ms ease, color 130ms ease;
}

.ctt-select-wrap select:hover,
.ctt-select-wrap select:focus { border-color: var(--primary); color: var(--text); }

.ctt-select-wrap select option { background: var(--surface); color: var(--text); }

.row-count { margin-left: auto; }

.table-scroll {
  max-height: calc(100vh - 320px);
  min-height: 220px;
  overflow: auto;
  border: none;
  border-radius: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--elev-border) transparent;
}

.table-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--elev-border); border-radius: 9999px; }

.table-scroll .data-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
}

thead th.col-active { color: var(--primary); font-weight: 510; }

tbody td.col-active { color: var(--primary); font-weight: 510; }

/* Cột số căn phải + chữ số cùng bề rộng để các hàng thẳng hàng */
.data-table thead th.col-count,
.data-table tbody td.col-count {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

tbody tr.low-user { background: var(--danger-bg); }
tbody tr.low-user:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); }

/* Rank */

.th-rank, .td-rank { width: 56px; text-align: center !important; }

/* Page header H1 */
.page-header h1 {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
}
.page-header h1 i[class*="ri-"] {
  width: 24px !important;
  height: 24px !important;
  font-size: 24px !important;
  line-height: 1 !important;
  margin: 0 !important;
  vertical-align: middle !important;
}

/* Rank */

.th-rank, .td-rank { width: 56px; text-align: center !important; }

.rank-chip {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 3px !important;
  min-width: 28px !important;
  height: 24px !important;
  padding: 0 6px !important;
  border-radius: 6px !important;
  font-size: 11.5px !important;
  font-weight: 700 !important;
  color: var(--text-muted);
  background: var(--surface-hover);
  border: 1px solid var(--border);
  line-height: 1 !important;
  vertical-align: middle !important;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.rank-chip .rank-trophy {
  width: 12px !important;
  height: 12px !important;
  font-size: 12px !important;
  line-height: 1 !important;
  margin: 0 !important;
}

.rank-1 {
  background: linear-gradient(135deg, #f59e0b, #d97706) !important;
  color: #ffffff !important;
  border-color: rgba(245, 158, 11, 0.5) !important;
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.4) !important;
  font-weight: 700 !important;
}

.rank-2 {
  background: linear-gradient(135deg, #94a3b8, #64748b) !important;
  color: #ffffff !important;
  border-color: rgba(148, 163, 184, 0.5) !important;
  box-shadow: 0 2px 10px rgba(148, 163, 184, 0.35) !important;
  font-weight: 700 !important;
}

.rank-3 {
  background: linear-gradient(135deg, #d97706, #92400e) !important;
  color: #ffffff !important;
  border-color: rgba(217, 119, 6, 0.5) !important;
  box-shadow: 0 2px 10px rgba(217, 119, 6, 0.35) !important;
  font-weight: 700 !important;
}

/* Locmem badges */
.locmem-pill {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 4px !important;
  padding: 3px 8px !important;
  border-radius: 999px !important;
  font-size: 11.5px !important;
  font-weight: 600 !important;
  line-height: 1 !important;
  vertical-align: middle !important;
}
.locmem-pill i[class*="ri-"] {
  width: 12px !important;
  height: 12px !important;
  font-size: 12px !important;
  line-height: 1 !important;
  margin: 0 !important;
}
.locmem-pill.yes {
  background: rgba(239, 68, 68, 0.16);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}
.locmem-pill.no {
  background: rgba(16, 185, 129, 0.13);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.28);
}

/* Copy UID button */
.copy-uid-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 4px !important;
  line-height: 1 !important;
  vertical-align: middle !important;
}
.copy-uid-btn i[class*="ri-"] {
  width: 12px !important;
  height: 12px !important;
  font-size: 12px !important;
  line-height: 1 !important;
  margin: 0 !important;
}

/* Stat card colorful icon wraps */
.stat-icon-wrap {
  width: 38px !important;
  height: 38px !important;
  border-radius: 10px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease;
}

.stat-icon-wrap i[class*="ri-"],
.stat-icon-wrap svg {
  width: 19px !important;
  height: 19px !important;
  font-size: 19px !important;
  line-height: 1 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin: 0 !important;
  padding: 0 !important;
  vertical-align: middle !important;
}

.stat-card:hover .stat-icon-wrap {
  transform: translateY(-2px) scale(1.08);
}

.stat-icon--purple {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.22), rgba(124, 58, 237, 0.12));
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.32);
  box-shadow: 0 4px 16px rgba(168, 85, 247, 0.25);
}
.stat-icon--blue {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.22), rgba(14, 165, 233, 0.12));
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.32);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.25);
}
.stat-icon--amber {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.22), rgba(234, 88, 12, 0.12));
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.32);
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.25);
}
.stat-icon--emerald {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.22), rgba(20, 184, 166, 0.12));
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.32);
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.25);
}
.stat-icon--indigo {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.22), rgba(139, 92, 246, 0.12));
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.32);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.25);
}
.stat-icon--rose {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.22), rgba(244, 63, 94, 0.12));
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.32);
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.25);
}

/* Empty state animated glow icon */
.empty-icon-wrap.modern-pulse {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.22), rgba(147, 51, 234, 0.22));
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 16px;
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.25);
  animation: floatIcon 3s ease-in-out infinite;
}
@keyframes floatIcon {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* Refresh spin animation */
.spin-anim {
  animation: spin 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Member cell */

.th-member { position: sticky; left: 0; z-index: 6; background: var(--surface); }
.th-member, .td-member { min-width: 200px; max-width: 260px; }

.td-member {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
}

tbody tr:hover .td-member { background: var(--surface); }

tr.low-user .td-member {
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
}

.member-wrap { display: flex; align-items: center; gap: 9px; min-width: 0; }

.member-avatar {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface-hover);
  border: 1px solid var(--border);
}

.member-info { min-width: 0; flex: 1; }

.member-name {
  display: block;
  font-size: 13px;
  font-weight: 510;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-bar {
  margin-top: 4px;
  height: 3px;
  border-radius: 9999px;
  background: var(--surface-hover);
  overflow: hidden;
}

.member-bar span {
  display: block;
  height: 100%;
  min-width: 2px;
  border-radius: 9999px;
  background: var(--primary);
  transition: width 400ms ease;
}

tr.low-user .member-bar span { background: var(--danger); }

/* UID + copy */

.td-uid {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-muted);
}

.copy-uid-btn {
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: color 130ms ease, border-color 130ms ease;
}

.copy-uid-btn:hover { color: var(--primary); border-color: var(--primary); }

.th-actions, .td-actions { width: 64px; text-align: right !important; }

.locmem-yes {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 11px;
  font-weight: 510;
}

.locmem-no { color: var(--text-muted); font-size: 12px; }

.no-results { padding: 32px 14px !important; text-align: center; color: var(--text-muted); white-space: normal !important; }

/* ---------- Empty state ---------- */

.empty-state { padding: 60px 24px; }

.empty-icon-wrap {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--primary-bg);
  color: var(--primary);
}

.empty-title { font-size: 16px; font-weight: 510; color: var(--text); }
.empty-sub { margin-top: 4px; font-size: 12.5px; color: var(--text-muted); }

/* ── Phân quyền & Sidebar Responsive ────────────────────────── */

body:not(.is-admin) .user-dropdown-container { display: none; }

.public-actions { display: none; }

body:not(.is-admin) .public-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Chức năng riêng Admin (nút yêu cầu bot lọc) */
.admin-only { display: none !important; }
body.is-admin .admin-only { display: block !important; }

/* ── Màn hình Desktop (>= 769px) ── */
@media (min-width: 769px) {
  /* Khách vãng lai: không có sidebar, nội dung full width */
  body:not(.is-admin):not(.is-renter) .sidebar {
    display: none !important;
  }
  body:not(.is-admin):not(.is-renter) .main-layout {
    margin-left: 0 !important;
  }
  body:not(.is-admin):not(.is-renter) .app-header {
    margin-left: 0 !important;
  }

  /* Admin đăng nhập: hiện sidebar admin desktop (tăng specificity để thắng
     quy định body.public-page .sidebar:not(.drawer-open) { display: none !important }
     trong style.css có specificity cao hơn) */
  body.public-page.is-admin .header-nav { display: none !important; }
  body.public-page.is-admin .user-dropdown-container { display: none !important; }
  body.public-page.is-admin .app-header { display: none !important; }
  body.public-page.is-admin .sidebar--admin { display: flex !important; }
  body.is-admin .sidebar:not(.sidebar--admin) { display: none !important; }
  body.public-page.is-admin .main-layout { margin-left: 248px !important; }

  /* Người thuê đăng nhập: hiện sidebar người thuê desktop */
  body.public-page.is-renter .sidebar--renter { display: flex !important; }
  body.is-renter .sidebar:not(.sidebar--renter) { display: none !important; }
  body.public-page.is-renter .main-layout { margin-left: 248px !important; }
  body.public-page.is-renter .app-header { margin-left: 248px !important; }
}

/* ── Màn hình Mobile / Tablet (<= 768px) ── */
@media (max-width: 768px) {
  body:not(.is-admin):not(.is-renter) .sidebar--admin,
  body:not(.is-admin):not(.is-renter) .sidebar--renter {
    display: none !important;
  }
  body.is-admin .sidebar:not(.sidebar--admin) {
    display: none !important;
  }
  body.is-renter .sidebar:not(.sidebar--renter) {
    display: none !important;
  }
  body .main-layout { margin-left: 0 !important; }
  body .app-header { margin-left: 0 !important; }
}

/* ── Responsive ────────────────────────────────────────────── */

@media (max-width: 1280px) {
  /* Vùng có sidebar boxlist chiếm chỗ: giảm nhẹ để số + nhãn luôn vừa card */
  .stat-card { padding: 18px 20px; }
  .stat-card .value { font-size: 28px; }
}

@media (max-width: 1100px) {
  .checktt-grid { grid-template-columns: minmax(0, 1fr); }
  .boxlist-card { position: static; max-height: 320px; }
}

@media (max-width: 900px) {
  .stats-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .control-spacer { display: none; }
  .control-actions { width: 100%; }
  .control-actions .btn { flex: 1 1 0; min-width: 0; }
  .locmem-card { flex-direction: column; align-items: stretch; }
  .locmem-actions .btn { width: 100%; }
  .row-count { margin-left: 0; }
  .table-scroll { max-height: none; }
  .ctt-switch-label { display: none; }

  /* Tablet hẹp: bỏ UID + Gần đây để bảng không cần cuộn ngang */
  .col-uid,
  .col-recent { display: none; }
}

/* ── Mobile (điện thoại) ───────────────────────────────────── */

@media (max-width: 767px) {
  .page-header { flex-direction: column; }
  .page-header > div:last-child { width: 100%; justify-content: space-between; }
  .thread-title-row h2 { font-size: 16px; white-space: normal; }
  .thread-avatar { width: 34px; height: 34px; border-radius: 9px; }

  /* Bộ điều khiển thống kê: xếp dọc, căn giữa, tab đều width */
  .control-card {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 14px 16px;
  }

  .control-group {
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
  }

  .seg { display: flex; width: 100%; }

  .seg-btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 7px 4px;
    white-space: nowrap;
  }

  .stepper { align-self: center; }

  /* Bộ lọc thành viên: tìm kiếm chiếm 1 hàng, 2 dropdown chia đôi hàng dưới */
  .table-tools { padding: 12px; row-gap: 8px; }
  .member-search { flex: 1 1 100%; min-width: 0; max-width: none; }
  .ctt-select-wrap { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .ctt-select-wrap select { width: 100%; min-width: 0; }
  .row-count { margin-left: auto; }

  /* Bảng gọn: chỉ giữ STT · Thành viên · cột số đang chọn · Copy */
  .col-uid,
  .col-recent,
  .col-locmem,
  .col-count:not(.col-active) { display: none; }

  .th-rank, .td-rank { width: 38px; }
  .th-member, .td-member { min-width: 148px; max-width: 210px; }
  .data-table thead th, .data-table tbody td { padding-left: 10px; padding-right: 10px; }

  .copy-uid-btn { padding: 3px 8px; }
  .th-actions, .td-actions { width: auto; padding-left: 4px; }

  /* Stat card gọn lại cho vừa 2 cột màn hình hẹp */
  .stat-card { padding: 14px 16px; }
  .stat-card .value { font-size: 24px; }
  .stat-icon-wrap { width: 30px; height: 30px; }
  .stat-icon-wrap svg, .stat-icon-wrap i { width: 16px; height: 16px; font-size: 16px; line-height: 1; }

  /* Chống tràn ngang do phần tử con bất kỳ */
  .control-card, .locmem-card, .table-tools { min-width: 0; }
}

/* Màn hình rất hẹp (≤420px): thu gọn thêm để bảng vừa khít không cần cuộn */
@media (max-width: 420px) {
  .th-member, .td-member { min-width: 104px; max-width: 140px; }
  .data-table thead th, .data-table tbody td { padding: 7px; }
  .copy-uid-btn { padding: 3px 6px; }
  .td-actions { padding: 7px 6px 7px 3px; }
  .member-avatar { width: 26px; height: 26px; font-size: 10px; }
  .seg-btn { font-size: 12px; padding: 7px 2px; }
  .stat-card { padding: 12px 14px; }
  .stat-card .value { font-size: 22px; }
  .stat-card .label { font-size: 11px; }
}
