/* ===== 本地字体（Inter / JetBrains Mono，原 Google Fonts，F13 self-host） ===== */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/inter-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/inter-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/inter-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/inter-latin-700-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('../fonts/inter-latin-800-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/jetbrains-mono-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/jetbrains-mono-latin-500-normal.woff2') format('woff2');
}

/* ============================================================
   LoopV Chat 管理平台 — 明亮极简风
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #fafafa;
  --bg-card: #ffffff;
  --bg-input: #f3f4f6;
  --bg-hover: #f3f4f6;
  --border: #e5e7eb;
  --text: #1a1a2e;
  --text-dim: #6b7280;
  --accent: #6366f1;
  --accent-light: #8b5cf6;
  --accent-glow: rgba(99, 102, 241, 0.16);
  --grad: linear-gradient(135deg, #6366f1, #8b5cf6);
  --danger: #ef4444;
  --danger-soft: #fee2e2;
  --success: #22c55e;
  --success-soft: #dcfce7;
  --warn: #f97316;
  --warn-soft: #ffedd5;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 16px 48px rgba(20, 20, 50, 0.14);
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
}

html,
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100%;
}

body {
  overflow-x: hidden;
  overflow-y: auto;
}

.hidden {
  display: none !important;
}

::selection {
  background: rgba(99, 102, 241, 0.2);
}

::-webkit-scrollbar {
  width: 6px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

button {
  font-family: inherit;
  cursor: pointer;
}

svg {
  display: block;
}

/* ============================================================
   认证视图
   ============================================================ */
.auth-view {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
  overflow-y: auto;
  z-index: 50;
}

.auth-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 720px;
  height: 720px;
  transform: translate(-50%, -50%);
  background: radial-gradient(
    circle at 50% 40%,
    rgba(139, 92, 246, 0.09) 0%,
    rgba(99, 102, 241, 0.05) 38%,
    transparent 70%
  );
  pointer-events: none;
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 32px 32px;
  box-shadow: var(--shadow);
  animation: auth-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes auth-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-logo {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  border-radius: 16px;
  background: var(--grad);
  color: #fff;
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.32);
}

.auth-title {
  font-size: 24px;
  font-weight: 800;
  text-align: center;
  letter-spacing: -0.02em;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-subtitle {
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  margin: 6px 0 24px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 7px;
}

.field .optional {
  font-weight: 400;
  color: #9ca3af;
  font-size: 12px;
}

.field input {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.field input::placeholder {
  color: #9ca3af;
}

.field input:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.auth-error {
  min-height: 20px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--danger);
  line-height: 1.4;
  word-break: break-word;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--grad);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.12s, box-shadow 0.18s, opacity 0.18s;
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.28);
}
.btn-primary svg {
  width: 16px;
  height: 16px;
}

.btn-primary:hover {
  box-shadow: 0 8px 22px rgba(99, 102, 241, 0.38);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
}

/* ============================================================
   管理视图
   ============================================================ */
.admin-view {
  min-height: 100vh;
  background: var(--bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-left {
  min-width: 0;
}

.logo {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-sub {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-dim);
  -webkit-text-fill-color: var(--text-dim);
  margin-left: 4px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.me-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.me-avatar {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: var(--grad);
}

.me-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.me-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.btn-icon {
  background: none;
  border: none;
  padding: 8px;
  border-radius: 9px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.btn-icon svg {
  width: 20px;
  height: 20px;
}
.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* ============================================================
   内容区
   ============================================================ */
.content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

/* 统计卡片 */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: transform 0.16s, box-shadow 0.16s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.08);
}

.stat-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-icon svg {
  width: 24px;
  height: 24px;
}

.ic-users {
  background: rgba(99, 102, 241, 0.12);
  color: #6366f1;
}

.ic-messages {
  background: rgba(139, 92, 246, 0.12);
  color: #8b5cf6;
}

.ic-recalled {
  background: rgba(249, 115, 22, 0.12);
  color: #f97316;
}

.ic-deleted {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}

.stat-info {
  min-width: 0;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--text);
}

.stat-label {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 3px;
}

/* 标签页 */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-input);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 16px;
  width: fit-content;
}

.tab {
  border: none;
  background: transparent;
  padding: 9px 22px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dim);
  transition: all 0.18s;
}

.tab.active {
  background: var(--bg-card);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* 面板 */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

/* ============================================================
   邀请码设置
   ============================================================ */
.panel-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.settings-panel {
  margin-bottom: 16px;
}

.settings-body {
  padding: 18px 20px;
}

.settings-desc {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 8px;
}

/* 开关行 */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  cursor: pointer;
}

.switch-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.switch {
  position: relative;
  flex-shrink: 0;
  width: 42px;
  height: 24px;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .slider {
  position: absolute;
  inset: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.switch .slider::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 2px;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}

.switch input:checked + .slider {
  background: var(--grad);
  border-color: transparent;
}

.switch input:checked + .slider::before {
  transform: translateY(-50%) translateX(18px);
}

.switch input:focus-visible + .slider {
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* 邀请码输入行 */
.invite-code-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0 20px;
}

.invite-code-row label {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}

.invite-code-row input {
  flex: 1;
  max-width: 320px;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.invite-code-row input::placeholder {
  color: #9ca3af;
}

.invite-code-row input:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ============================================================
   文档管理
   ============================================================ */
/* 加载失败提示区 */
.docs-fail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 30px 20px;
  text-align: center;
}

.docs-fail-text {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.6;
}

/* 文档列表 */
.docs-list {
  margin-top: 8px;
}

.doc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--border);
  transition: opacity 0.18s;
}

.doc-row:last-child {
  border-bottom: none;
}

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

.doc-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.doc-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.18s;
}

/* 开关关闭（文档隐藏）时标题降为次要色，强化开关反馈 */
.doc-row.doc-hidden .doc-title {
  color: var(--text-dim);
}

.doc-group-badge {
  flex-shrink: 0;
  padding: 2px 9px;
  background: var(--bg-input);
  color: #9ca3af;
  font-size: 12px;
  font-weight: 500;
}

.doc-meta {
  margin-top: 5px;
  font-size: 12px;
  color: #9ca3af;
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 底部保存栏 */
.docs-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.docs-dirty {
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
}

.docs-actions .btn-primary {
  padding: 10px 18px;
}

.batch-count {
  font-size: 13px;
  color: var(--text-dim);
}
.batch-count.active {
  color: var(--accent);
  font-weight: 600;
}

/* 筛选栏 */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.filter-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-item label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
}

.filter-item input,
.filter-item select {
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  min-width: 150px;
  height: 38px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.filter-item input[type="datetime-local"] {
  min-width: 190px;
}

.filter-item input::placeholder {
  color: #9ca3af;
}

.filter-item input:focus,
.filter-item select:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.filter-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* ============================================================
   消息状态多选 chip
   ============================================================ */
.filter-note {
  margin-left: 6px;
  font-weight: 400;
  color: #9ca3af;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.chip {
  position: relative;
  display: inline-flex;
  cursor: pointer;
}

.chip .chip-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.chip-face {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-input);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  user-select: none;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.chip:hover .chip-face {
  border-color: #d1d5db;
  background: var(--bg-hover);
  color: var(--text);
}

.chip-input:checked + .chip-face {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.08);
  color: var(--accent);
  font-weight: 600;
}

.chip-input:focus-visible + .chip-face {
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.chip-dot-normal {
  background: #22c55e;
}

.chip-dot-user-recall {
  background: #9ca3af;
}

.chip-dot-admin-recall {
  background: #f97316;
}

.chip-dot-deleted {
  background: #ef4444;
}

/* ============================================================
   表格
   ============================================================ */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ============================================================
   消息表：列表内滚动 + 表头吸顶
   ============================================================ */
/* 仅消息表的滚动容器：固定视口相关高度，只滚动消息行，筛选栏/分页栏在容器外 */
.table-wrap.table-scroll {
  max-height: calc(100vh - 300px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* border-collapse: separate 规避 Safari 下 sticky 表头背景失效的 bug */
#panel-messages table {
  border-collapse: separate;
  border-spacing: 0;
}

#panel-messages thead {
  background: transparent;
}

#panel-messages thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-input);
}

/* 非滚动列表的“末行去边框”规则会让滚动列表底部少一条分隔线，这里补回，保证行分隔视觉连续 */
#panel-messages tbody tr:last-child td {
  border-bottom: 1px solid var(--border);
}

/* ============================================================
   消息分页栏
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.pagination-total {
  font-size: 13px;
  color: var(--text-dim);
}

.pagination-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.pagination-nav .btn-secondary {
  padding: 6px 14px;
  font-size: 13px;
}

.pagination-nav .btn-secondary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pagination-page {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
}

.pagination-page input[type="number"] {
  width: 60px;
  height: 30px;
  padding: 0 6px;
  text-align: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  -moz-appearance: textfield;
  appearance: textfield;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.pagination-page input[type="number"]::-webkit-outer-spin-button,
.pagination-page input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.pagination-page input[type="number"]:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-glow);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 880px;
}

thead {
  background: var(--bg-input);
}

th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 13px 16px;
  font-size: 14px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background 0.12s;
}

tbody tr:hover {
  background: var(--bg-hover);
}

tbody tr.row-deleted td {
  color: #9ca3af;
}

.col-id {
  width: 70px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 13px;
}

.col-actions {
  width: 170px;
  text-align: right;
}

.col-content {
  max-width: 320px;
}

.col-check {
  width: 40px;
  text-align: center;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #6366f1;
  vertical-align: middle;
}

/* 单元格内容 */
.cell-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.cell-avatar {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.cell-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cell-username {
  font-weight: 600;
}

.cell-dim {
  color: var(--text-dim);
}

.mono {
  font-family: var(--font-mono);
  font-size: 13px;
}

/* 徽章 */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-admin {
  background: rgba(99, 102, 241, 0.12);
  color: #6366f1;
}

.badge-test {
  background: rgba(6, 182, 212, 0.12);
  color: #0891b2;
}

.badge-user {
  background: var(--bg-input);
  color: var(--text-dim);
}

.badge-banned {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-active {
  background: var(--success-soft);
  color: #16a34a;
}

.badge-user-recall {
  background: var(--bg-input);
  color: #6b7280;
}

.badge-admin-recall {
  background: var(--warn-soft);
  color: #ea580c;
}

.badge-deleted {
  background: var(--danger-soft);
  color: var(--danger);
}

/* 消息类型图标 + 内容 */
.cell-type {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
}
.cell-type svg {
  width: 16px;
  height: 16px;
}

.msg-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.msg-preview-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 280px;
  min-width: 0;
  flex: 0 1 auto;
}

.msg-preview a {
  color: var(--accent);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-preview a:hover {
  text-decoration: underline;
}

.msg-preview.deleted {
  color: #9ca3af;
  font-style: italic;
}

/* 密码列 */
.password-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}

.password-value {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.02em;
}

.password-toggle {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 6px;
  transition: background 0.12s;
}
.password-toggle:hover {
  background: var(--bg-hover);
}

/* 操作按钮 */
.actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn-action {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.15s;
}

.btn-action:hover {
  border-color: #d1d5db;
  background: var(--bg-hover);
}

.btn-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-action.btn-danger {
  border-color: #fecaca;
  background: #fff;
  color: var(--danger);
}
.btn-action.btn-danger:hover:not(:disabled) {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.btn-action.btn-success {
  border-color: #bbf7d0;
  background: #fff;
  color: #16a34a;
}
.btn-action.btn-success:hover {
  border-color: var(--success);
  background: var(--success-soft);
}

.btn-action.btn-warn {
  border-color: #fed7aa;
  background: #fff;
  color: #ea580c;
}
.btn-action.btn-warn:hover {
  border-color: var(--warn);
  background: var(--warn-soft);
}

.action-none {
  color: #c0c2ce;
  font-size: 13px;
}

/* 空态与加载 */
.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 14px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ============================================================
   弹窗
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fade-in 0.18s ease-out;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.modal-head h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.modal h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.confirm-text {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 20px;
  word-break: break-word;
}

/* 确认弹窗标题居中（仅确认弹窗，不影响创建用户弹窗等） */
#confirm-modal h3 {
  text-align: center;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions button {
  flex: 1;
}

.btn-secondary {
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: #d1d5db;
}

.btn-danger {
  border: none;
  background: var(--danger);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: opacity 0.15s, transform 0.12s;
}
.btn-danger:hover {
  opacity: 0.9;
}
.btn-danger:active {
  transform: translateY(0);
}

/* 创建结果 */
.result-tip {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 14px;
}

.password-display {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 18px;
}

.password-display code {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--text);
  word-break: break-all;
  letter-spacing: 0.03em;
}

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: #fff;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 13px;
  max-width: 88vw;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 300;
  box-shadow: var(--shadow-lg);
  word-break: break-word;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: var(--danger);
}

.toast.success {
  background: var(--success);
}

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 640px) {
  .topbar {
    padding: 10px 14px;
  }
  .logo {
    font-size: 15px;
  }
  .logo-sub {
    font-size: 13px;
  }
  .me-name {
    max-width: 80px;
    font-size: 12px;
  }
  .badge-admin {
    display: none;
  }
  .content {
    padding: 16px 12px 40px;
  }
  .stats {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .stat-card {
    padding: 14px;
    gap: 12px;
  }
  .stat-icon {
    width: 40px;
    height: 40px;
  }
  .stat-value {
    font-size: 22px;
  }
  .tabs {
    width: 100%;
  }
  .tab {
    flex: 1;
    padding: 9px 0;
  }
  td,
  th {
    padding: 11px 12px;
  }
  .auth-card {
    padding: 28px 22px 24px;
  }
  .filter-bar {
    gap: 10px;
  }
  .settings-body {
    padding: 14px 16px;
  }
  .invite-code-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .invite-code-row input {
    max-width: none;
    width: 100%;
  }
  .filter-item {
    flex: 1 1 100%;
  }
  .filter-item input,
  .filter-item select,
  .filter-item input[type="datetime-local"] {
    width: 100%;
    min-width: 0;
  }
  .filter-actions {
    margin-left: 0;
    width: 100%;
  }
  .filter-actions button {
    flex: 1;
  }
  .panel-toolbar {
    flex-wrap: wrap;
  }

  /* 消息状态 chip 与分页栏窄屏适配：换行、全宽不溢出 */
  .chip-group {
    width: 100%;
  }
  .filter-note {
    display: block;
    margin-left: 0;
  }
  .pagination {
    padding: 10px 12px;
  }
  .pagination-nav {
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
  }
}
