:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #e3e5e9;
  --text: #1a1d23;
  --muted: #6b7280;
  --accent: #2f6fed;
  --accent-hover: #2559c4;
  --accent-soft: #e8f0fe;
  --bubble-user: #2f6fed;
  --bubble-user-text: #ffffff;
  --bubble-bot: #ffffff;
  --bubble-bot-text: #1a1d23;
  --bubble-bot-border: #e3e5e9;
  --danger: #c0392b;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #16181d;
    --panel: #1e2127;
    --border: #2c303a;
    --text: #eceef1;
    --muted: #9aa0aa;
    --accent: #5b8def;
    --accent-hover: #7aa2f2;
    --accent-soft: #23304a;
    --bubble-user: #5b8def;
    --bubble-user-text: #0d1117;
    --bubble-bot: #262a32;
    --bubble-bot-text: #eceef1;
    --bubble-bot-border: #2c303a;
    --danger: #ff6b5e;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button {
  font-family: inherit;
}

.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Sidebar ---------- */

.sidebar {
  width: 272px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 14px;
  gap: 10px;
  overflow-y: auto;
  transition: transform 0.2s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 8px;
}

.sidebar-brand .brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-brand .brand-name {
  font-weight: 600;
  font-size: 15px;
}

.sidebar-close {
  display: none;
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s ease;
}

.new-chat-btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.conversation-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-item .icon {
  width: 15px;
  height: 15px;
  color: var(--muted);
  flex-shrink: 0;
}

.conversation-item:hover {
  background: var(--bg);
}

.conversation-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.conversation-item.active .icon {
  color: var(--accent);
}

.conversation-empty {
  color: var(--muted);
  font-size: 12px;
  padding: 10px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
  text-transform: uppercase;
}

#username-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
}

.logout-btn:hover {
  background: var(--bg);
  color: var(--danger);
}

.login-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
}

.login-link:hover {
  background: var(--accent-soft);
}

.sidebar-backdrop {
  display: none;
}

/* ---------- Chat main ---------- */

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

.chat-topbar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.menu-toggle {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 6px;
  display: flex;
}

.chat-topbar .brand-name {
  font-weight: 600;
  font-size: 14px;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.empty-state {
  margin: auto;
  text-align: center;
  max-width: 480px;
  color: var(--muted);
}

.empty-state .empty-icon {
  width: 44px;
  height: 44px;
  color: var(--accent);
  margin-bottom: 12px;
}

.empty-state h2 {
  color: var(--text);
  font-size: 18px;
  margin: 0 0 6px;
}

.empty-state p {
  margin: 0 0 18px;
  font-size: 13px;
}

.suggestion-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.suggestion-chip {
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.suggestion-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.message-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 78%;
}

.message-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-row.assistant {
  align-self: flex-start;
}

.message-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}

.message-row.user .message-avatar {
  background: var(--bubble-user);
}

.message-row.assistant .message-avatar {
  background: var(--accent);
}

.message-avatar .icon {
  width: 15px;
  height: 15px;
}

.message-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.message-row.user .message-content {
  align-items: flex-end;
}

.message-row.assistant .message-content {
  align-items: flex-start;
}

.message-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.5;
  font-size: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
  box-shadow: var(--shadow);
}

.message-row.user .message-bubble {
  background: var(--bubble-user);
  color: var(--bubble-user-text);
  border-bottom-right-radius: 4px;
}

.message-row.assistant .message-bubble {
  background: var(--bubble-bot);
  color: var(--bubble-bot-text);
  border: 1px solid var(--bubble-bot-border);
  border-bottom-left-radius: 4px;
}

.message-row.pending .message-bubble {
  padding: 14px;
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing-bounce 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.message-error {
  color: var(--danger);
}

.message-actions {
  display: flex;
  gap: 2px;
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.message-row:hover .message-actions,
.message-actions:focus-within {
  opacity: 1;
}

.message-row.pending .message-actions {
  display: none;
}

.message-action-btn {
  width: 26px;
  height: 26px;
  border: none;
  background: none;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.message-action-btn .icon {
  width: 14px;
  height: 14px;
}

.message-action-btn:hover:not(:disabled) {
  background: var(--bg);
  color: var(--text);
}

.message-action-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.message-action-btn.copied {
  color: #1a9e5c;
}

@media (hover: none) {
  .message-actions {
    opacity: 1;
  }
}

.message-sources {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.message-token-info {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}

.message-row.user .message-token-info {
  color: rgba(255, 255, 255, 0.75);
}

.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
}

.message-row.user .source-chip {
  background: rgba(255, 255, 255, 0.15);
  color: var(--bubble-user-text);
  border-color: transparent;
}

.source-chip .icon {
  width: 11px;
  height: 11px;
}

.source-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 2px;
  padding: 2px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.source-action-btn:hover {
  background: rgba(0, 0, 0, 0.08);
}

.message-row.user .source-action-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.source-action-btn .icon {
  width: 12px;
  height: 12px;
}

.model-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 24px 0;
  font-size: 12px;
  color: var(--muted);
}

.model-select {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

.chat-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 24px 18px;
  background: var(--bg);
}

.chat-form-inner {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px 8px 8px 16px;
  box-shadow: var(--shadow);
  max-width: 780px;
  margin: 0 auto;
  width: 100%;
}

.chat-form textarea {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  padding: 6px 0;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  max-height: 160px;
}

.chat-form textarea::placeholder {
  color: var(--muted);
}

.send-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.mic-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.mic-btn:hover:not(:disabled) {
  background: var(--bg);
  color: var(--text);
}

.mic-btn.recording {
  color: #fff;
  background: var(--danger);
  animation: mic-pulse 1.4s ease-in-out infinite;
}

.mic-btn.transcribing {
  opacity: 0.6;
  cursor: wait;
}

.mic-btn:disabled {
  cursor: wait;
}

@keyframes mic-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(192, 57, 43, 0.45);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(192, 57, 43, 0);
  }
}

/* ---------- Auth pages ---------- */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-wrap {
  width: 100%;
  max-width: 380px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.auth-brand .brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}

.auth-wrap h1 {
  font-size: 17px;
  margin: 0;
  text-align: center;
}

.auth-wrap form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.auth-field label {
  font-size: 12px;
  color: var(--muted);
}

.auth-wrap input {
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease;
}

.auth-wrap input:focus {
  border-color: var(--accent);
}

.auth-wrap button {
  padding: 11px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  margin-top: 4px;
  transition: background 0.15s ease;
}

.auth-wrap button:hover:not(:disabled) {
  background: var(--accent-hover);
}

.auth-wrap button:disabled {
  opacity: 0.6;
  cursor: default;
}

.auth-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 16px;
}

.auth-toggle {
  margin-top: 16px;
  font-size: 13px;
  text-align: center;
  color: var(--muted);
}

.auth-toggle a {
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
  font-weight: 500;
}

.auth-toggle a:hover {
  text-decoration: underline;
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .chat-topbar {
    display: flex;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    transform: translateX(-100%);
    box-shadow: 0 0 0 rgba(0, 0, 0, 0);
  }

  .layout.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.15);
  }

  .sidebar-close {
    display: flex;
  }

  .layout.sidebar-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 15;
  }

  .message-row {
    max-width: 92%;
  }

  .chat-form {
    padding: 10px 12px 14px;
  }
}

/* Sidebar: link Quản trị (chỉ hiện với admin) */
.admin-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  border-radius: 6px;
}

.admin-link:hover {
  background: var(--bg);
  color: var(--text);
}

/* Trang /admin.html — form nạp tài liệu */
.admin-page {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.admin-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.admin-back {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}

.admin-back:hover {
  color: var(--accent);
}

.admin-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  padding: 32px 16px 60px;
}

.admin-form {
  width: 100%;
  max-width: 640px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.admin-tab {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.admin-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.admin-row {
  display: flex;
  gap: 16px;
}

.admin-row .admin-field {
  flex: 1;
  min-width: 0;
}

.admin-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-field label {
  font-size: 13px;
  color: var(--muted);
}

.admin-field input,
.admin-field textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

.admin-field input:focus,
.admin-field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.admin-submit-btn {
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.admin-submit-btn:hover {
  background: var(--accent-hover);
}

.admin-submit-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.admin-message {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
}

.admin-message-success {
  background: var(--accent-soft);
  color: var(--accent);
}

.admin-message-error {
  background: rgba(192, 57, 43, 0.12);
  color: var(--danger);
}

@media (max-width: 640px) {
  .admin-row {
    flex-direction: column;
    gap: 16px;
  }
}

.admin-list-section {
  width: 100%;
  max-width: 1400px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 20px 24px;
}

.admin-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.admin-list-header h2 {
  font-size: 16px;
  margin: 0;
}

.admin-refresh-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
}

.admin-refresh-btn:hover {
  background: var(--bg);
  color: var(--accent);
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  overflow-wrap: break-word;
}

/* ID, Nội bộ, Quyền, Số đoạn, Ngày nạp, actions: giá trị ngắn, giữ 1 dòng. Tiêu đề/Nguồn/License
   (nội dung dài, không kiểm soát được độ dài) được để mặc định wrap nhiều dòng thay vì ellipsis,
   để bảng luôn vừa chiều rộng màn hình máy tính, không cần cuộn ngang. */
.admin-doc-meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.admin-table th:nth-child(1),
.admin-table td:nth-child(1) {
  width: 5%;
  white-space: nowrap;
}

.admin-table th:nth-child(2),
.admin-table td:nth-child(2) {
  width: 19%;
}

.admin-table th:nth-child(3),
.admin-table td:nth-child(3) {
  width: 15%;
}

.admin-table th:nth-child(4),
.admin-table td:nth-child(4) {
  width: 18%;
}

.admin-table th:nth-child(5),
.admin-table td:nth-child(5) {
  width: 6%;
  white-space: nowrap;
}

.admin-table th:nth-child(6),
.admin-table td:nth-child(6) {
  width: 7%;
  white-space: nowrap;
}

.admin-table th:nth-child(7),
.admin-table td:nth-child(7) {
  width: 6%;
  white-space: nowrap;
}

.admin-table th:nth-child(8),
.admin-table td:nth-child(8) {
  width: 9%;
  white-space: nowrap;
}

.admin-table th:nth-child(9),
.admin-table td:nth-child(9) {
  width: 15%;
}

.admin-table th {
  color: var(--muted);
  font-weight: 600;
}

.admin-table-empty {
  text-align: center;
  color: var(--muted);
  white-space: normal;
}

.admin-delete-btn {
  padding: 5px 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--danger);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

.admin-delete-btn:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.admin-table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-edit-btn {
  padding: 5px 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--accent);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

.admin-edit-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.admin-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--muted);
}

.admin-pagination button {
  padding: 6px 14px;
}

.admin-pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.admin-dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 640px;
}

.admin-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.admin-dialog-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  max-height: 85vh;
  overflow-y: auto;
}

.admin-dialog-form h3 {
  margin: 0;
  font-size: 16px;
}

.admin-dialog-subheading {
  margin: 8px 0 -8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 14px;
}

.admin-manual-flag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  font-size: 11px;
  font-weight: normal;
  color: var(--muted);
}

.admin-manual-reset {
  padding: 1px 6px;
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.admin-manual-reset:hover {
  color: var(--text);
}

.admin-dialog-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.admin-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.admin-dialog-actions .admin-submit-btn {
  padding: 10px 20px;
}

/* ---------- Logo MTTQ ---------- */

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: contain;
  flex-shrink: 0;
}

.brand-logo-sm {
  width: 28px;
  height: 28px;
}

.brand-logo-lg {
  width: 72px;
  height: 72px;
}

/* ---------- Câu trả lời: in đậm + chú thích bấm được ---------- */

.message-bubble strong {
  font-weight: 700;
}

.cite-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin: 0 2px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  vertical-align: 1px;
  cursor: pointer;
}

.cite-chip:hover {
  background: var(--accent);
  color: #fff;
}

.cite-demo {
  cursor: default;
}

.cite-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.cite-modal[hidden] {
  display: none;
}

.cite-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.cite-dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 640px;
  max-height: min(80vh, 640px);
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.cite-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.cite-badge {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.cite-head h3 {
  flex: 1;
  margin: 0;
  font-size: 15px;
  line-height: 1.4;
  font-weight: 600;
}

.cite-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 6px;
  display: flex;
}

.cite-close:hover {
  background: var(--bg);
  color: var(--text);
}

.cite-body {
  padding: 16px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.cite-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px;
}

.cite-actions:not(:empty) {
  padding: 12px 16px 14px;
  border-top: 1px solid var(--border);
}

.cite-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}

.cite-action:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- Xóa lịch sử hội thoại ---------- */

.conversation-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-delete {
  flex-shrink: 0;
  display: flex;
  padding: 3px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
}

.conversation-delete .icon {
  width: 14px;
  height: 14px;
  color: inherit;
}

.conversation-item:hover .conversation-delete,
.conversation-delete:focus-visible {
  opacity: 1;
}

.conversation-delete:hover {
  background: var(--panel);
  color: var(--danger);
}

@media (hover: none) {
  .conversation-delete {
    opacity: 1;
  }
}

.clear-all-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.clear-all-btn[hidden] {
  display: none;
}

.clear-all-btn:hover {
  background: var(--bg);
  color: var(--danger);
}

.guide-link {
  margin-top: auto;
}

.guide-link + .sidebar-footer {
  margin-top: 0;
}

/* ---------- Ghi chú dưới ô nhập ---------- */

.chat-disclaimer {
  max-width: 780px;
  width: 100%;
  margin: -6px auto 0;
  padding: 0 24px 12px;
  text-align: center;
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}

.chat-disclaimer a {
  color: var(--muted);
  text-decoration: underline;
  white-space: nowrap;
}

.chat-disclaimer a:hover {
  color: var(--accent);
}

@media (max-width: 860px) {
  .chat-disclaimer {
    padding: 0 14px 10px;
  }
}

/* ---------- Trang hướng dẫn ---------- */

.guide-main {
  align-items: stretch;
  gap: 18px;
  max-width: 760px;
  margin: 0 auto;
}

.guide-main {
  counter-reset: guide-step;
}

.guide-section {
  counter-increment: guide-step;
  padding: 20px 22px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 14px;
  line-height: 1.65;
}

.guide-section h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.guide-section h2::before {
  content: counter(guide-step) ". ";
}

.guide-section[hidden] {
  display: none;
}

.guide-section p {
  margin: 0 0 10px;
}

.guide-section p:last-child,
.guide-section ul:last-child {
  margin-bottom: 0;
}

.guide-section ul {
  margin: 0;
  padding-left: 20px;
}

.guide-section li {
  margin-bottom: 6px;
}

.guide-section kbd {
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg);
  font-size: 12px;
}

/* ---------- Quản lý người dùng ---------- */

.admin-topbar-link {
  margin-left: auto;
}

.users-heading {
  margin: 0;
  font-size: 16px;
}

.users-section {
  max-width: 900px;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.users-table th,
.users-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}

.users-table th {
  color: var(--muted);
  font-weight: 600;
}

.users-table th:nth-child(1),
.users-table td:nth-child(1),
.users-table th:nth-child(5),
.users-table td:nth-child(5) {
  white-space: nowrap;
}

.users-role {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}

.users-role-admin {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.users-select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

.users-dialog {
  max-width: 480px;
}

.admin-delete-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.admin-delete-btn:disabled:hover {
  background: var(--bg);
  color: var(--danger);
  border-color: var(--border);
}

/* ---------- Tra cứu văn bản (/tra-cuu.html) ---------- */

.search-main {
  gap: 20px;
  padding-top: 24px;
}

.search-form,
.search-answer,
.search-results {
  max-width: 1100px;
}

.search-user {
  font-size: 13px;
  color: var(--muted);
}

.search-ask {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.search-ask label {
  font-size: 14px;
  font-weight: 600;
}

.search-optional {
  font-weight: 400;
  color: var(--muted);
  font-size: 13px;
}

.search-ask textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  resize: vertical;
  min-height: 48px;
}

.search-ask textarea:focus,
.search-grid select:focus {
  outline: none;
  border-color: var(--accent);
}

.search-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.search-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.search-span-2 {
  grid-column: span 2;
}

.search-grid .users-select {
  width: 100%;
}

.search-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-model {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
  font-size: 13px;
  color: var(--muted);
}

.search-reset-btn {
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.search-reset-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.search-submit-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 28px;
}

.search-answer-head,
.search-results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.search-answer-head h2,
.search-summary {
  margin: 0;
  font-size: 16px;
}

.search-answer-body {
  margin-top: 12px;
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.search-thinking {
  color: var(--muted);
  font-style: italic;
}

.search-answer-sources-label {
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
}

.search-sort {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.search-sort .users-select {
  padding: 7px 10px;
  font-size: 13px;
}

.search-results.loading .search-list {
  opacity: 0.5;
}

.search-empty {
  background: var(--bg);
  color: var(--muted);
}

.search-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.search-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.search-item:last-child {
  border-bottom: none;
}

.search-item-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.search-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.search-meta {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  line-height: 1.6;
  text-align: left;
  overflow-wrap: anywhere;
}

button.search-meta {
  cursor: pointer;
}

button.search-meta:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.search-meta-label {
  color: var(--muted);
}

.search-item-snippet {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 6px 6px 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  overflow-wrap: anywhere;
}

.search-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.search-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
}

.search-action .icon {
  width: 14px;
  height: 14px;
}

.search-action:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.search-score {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}

.search-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
}

.search-pagination button {
  min-width: 36px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.search-pagination button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.search-pagination button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.search-pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.search-page-gap,
.search-page-info {
  font-size: 13px;
  color: var(--muted);
}

.search-page-info {
  margin-left: 8px;
}

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

@media (max-width: 560px) {
  .search-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .search-span-2 {
    grid-column: auto;
  }

  .search-model {
    width: 100%;
  }

  .search-submit-btn {
    flex: 1;
    justify-content: center;
  }

  .search-user {
    display: none;
  }
}

/* Ô chọn nhiều giá trị (loại văn bản, nguồn) trên trang tra cứu */
.multi-select-label {
  font-size: 13px;
  color: var(--muted);
}

.multi-select {
  position: relative;
}

.multi-select-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--muted);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.multi-select.has-value .multi-select-btn {
  color: var(--text);
  border-color: var(--accent);
}

.multi-select-btn:focus-visible,
.multi-select-btn[aria-expanded="true"] {
  outline: none;
  border-color: var(--accent);
}

.multi-select-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-select-panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  width: max(100%, 280px);
  max-width: calc(100vw - 32px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.16);
  display: flex;
  flex-direction: column;
}

.multi-select-panel[hidden] {
  display: none;
}

.multi-select-filter {
  margin: 8px 8px 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}

.multi-select-filter:focus {
  outline: none;
  border-color: var(--accent);
}

.multi-select-options {
  max-height: 280px;
  overflow-y: auto;
  padding: 6px 0;
}

.multi-select-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}

.multi-select-option[hidden] {
  display: none;
}

.multi-select-option:hover {
  background: var(--bg);
}

.multi-select-option input {
  margin: 0;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.multi-select-option span:first-of-type {
  flex: 1;
  min-width: 0;
}

.multi-select-count {
  color: var(--muted);
  font-size: 12px;
}

.multi-select-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  border-top: 1px solid var(--border);
}

.multi-select-foot button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

.multi-select-foot .multi-select-done {
  margin-left: auto;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.admin-field textarea {
  resize: vertical;
  line-height: 1.4;
}

/* ---------- Quản lý người dùng (tài khoản dùng chung mttquser) ---------- */
.users-shared-note {
  max-width: 900px;
  background: var(--accent-soft);
  color: var(--text);
}

.users-create {
  max-width: 900px;
}

.users-create summary {
  cursor: pointer;
}

.users-create-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 16px;
}

.users-label {
  font-size: 13px;
  font-weight: 500;
}

.users-roles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.users-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}

.users-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.users-filters input[type="search"] {
  flex: 1 1 220px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

.users-filters .users-select {
  flex: 0 1 200px;
  min-width: 0;
}

.users-total {
  color: var(--muted);
  font-weight: 400;
  font-size: 14px;
}

.users-name {
  font-weight: 500;
}

.users-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.users-table .users-role {
  margin: 0 4px 4px 0;
}

.users-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}

.users-status-on {
  background: var(--accent-soft);
  color: var(--accent);
}

.users-status-off {
  background: rgba(192, 57, 43, 0.12);
  color: var(--danger);
}

.users-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
}

.users-pager button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.users-temp-password {
  display: block;
  padding: 12px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 18px;
  letter-spacing: 1px;
  text-align: center;
  user-select: all;
}

.users-dialog .admin-field select:disabled {
  opacity: 0.6;
}

.auth-note {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin: 0 0 16px;
}

.users-section,
.users-shared-note,
.users-create {
  max-width: 1100px;
}

.users-table td:nth-child(1) {
  white-space: normal;
}

.users-table .admin-table-actions {
  flex-wrap: wrap;
}

/* ---------- Thống kê theo đơn vị (thong-ke.html) ---------- */
.stats-main {
  align-items: stretch;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  gap: 20px;
}

.stats-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.stats-presets {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.stats-preset {
  padding: 9px 12px;
  border: 0;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.stats-preset + .stats-preset {
  border-left: 1px solid var(--border);
}

.stats-preset.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.stats-date {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.stats-date input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.stats-filters .users-select {
  flex: 1 1 220px;
  max-width: 360px;
  min-width: 0;
}

.stats-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
  transition: opacity 0.15s;
}

.stats-loading {
  opacity: 0.5;
}

.stats-scope {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.stats-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.stats-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.stats-tile[hidden] {
  display: none;
}

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

.stats-tile-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
}

.stats-tile-note {
  font-size: 12px;
  color: var(--muted);
}

.stats-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 20px;
  min-width: 0;
}

.stats-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.stats-card-head .stats-card-title {
  margin: 0 auto 0 0;
}

.stats-card-title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
}

.stats-chart {
  width: 100%;
  overflow: hidden;
}

.stats-chart svg {
  display: block;
  max-width: 100%;
}

.stats-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.stats-baseline {
  stroke: var(--muted);
  stroke-width: 1;
}

.stats-axis {
  fill: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.stats-peak {
  fill: var(--text);
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
}

.stats-bar {
  fill: var(--accent);
}

.stats-bar.hover {
  fill: var(--accent-hover);
}

.stats-hit {
  fill: transparent;
  cursor: default;
  outline: none;
}

.stats-hit:focus-visible {
  stroke: var(--accent);
  stroke-width: 1;
}

.stats-tooltip {
  position: absolute;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.12);
  pointer-events: none;
  white-space: nowrap;
}

.stats-tooltip[hidden] {
  display: none;
}

.stats-tip-value {
  font-size: 14px;
  color: var(--text);
}

.stats-tip-label {
  font-size: 12px;
  color: var(--muted);
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.stats-table th,
.stats-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.stats-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stats-sort {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.stats-sort.active {
  color: var(--text);
}

.stats-link {
  color: var(--accent);
  text-decoration: none;
}

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

.stats-special {
  font-style: italic;
}

.stats-nowrap {
  white-space: nowrap;
  color: var(--muted);
}

.stats-bar-cell {
  min-width: 140px;
}

.stats-inline-value {
  display: inline-block;
  min-width: 36px;
}

.stats-inline-track {
  display: inline-block;
  vertical-align: middle;
  width: 90px;
  height: 8px;
  margin-left: 8px;
  border-radius: 4px;
  background: var(--accent-soft);
}

.stats-inline-bar {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
}

.stats-back {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.stats-footnote {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 640px) {
  .stats-card {
    padding: 14px;
  }
  .stats-tile-value {
    font-size: 24px;
  }
}

/* ---------- Quyền dùng model (cau-hinh-model.html) ---------- */
.modelperm-table th.modelperm-col,
.modelperm-table td.modelperm-cell {
  text-align: center;
  white-space: nowrap;
}

.modelperm-table td.modelperm-cell input {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.modelperm-table td.modelperm-cell input:disabled {
  cursor: not-allowed;
}

.modelperm-table tr.modelperm-sep td {
  border-bottom-width: 2px;
}

.modelperm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
