/* 管理后台 — 深色极光主题 */
:root {
  --bg-deep: #0c0a1d;
  --bg-main: #12102a;
  --sidebar: rgba(18, 16, 42, 0.92);
  --panel: rgba(30, 27, 58, 0.85);
  --panel-border: rgba(139, 92, 246, 0.12);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #a78bfa;
  --accent-dim: rgba(167, 139, 250, 0.15);
  --cyan: #22d3ee;
  --cyan-dim: rgba(34, 211, 238, 0.12);
  --danger: #fb7185;
  --danger-bg: rgba(251, 113, 133, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

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

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* 背景氛围 */
.admin-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(139, 92, 246, 0.25), transparent 50%),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(34, 211, 238, 0.12), transparent 45%),
    radial-gradient(ellipse 50% 30% at 50% 100%, rgba(167, 139, 250, 0.08), transparent 50%);
}

.admin-shell {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100vh;
}

/* —— 登录页 —— */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0;
}

.login-shell {
  display: grid;
  width: 100%;
  max-width: 960px;
  margin: auto;
  min-height: 520px;
  border-radius: calc(var(--radius) + 6px);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--panel-border);
}

@media (max-width: 720px) {
  .login-shell { grid-template-columns: 1fr; min-height: auto; margin: 16px; border-radius: var(--radius); }
}

.login-visual {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 40px 36px;
  background: linear-gradient(145deg, #312e81 0%, #1e1b4b 45%, #0f172a 100%);
  position: relative;
  overflow: hidden;
}

.login-visual::before {
  content: "";
  position: absolute;
  inset: -20%;
  background: radial-gradient(circle at 30% 20%, rgba(167, 139, 250, 0.35), transparent 55%);
  pointer-events: none;
}

.login-visual h2 {
  position: relative;
  margin: 0 0 10px;
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-visual p {
  position: relative;
  margin: 0;
  color: rgba(226, 232, 240, 0.75);
  font-size: 14px;
  max-width: 280px;
  line-height: 1.6;
}

.login-visual .deco {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 120px;
  height: 120px;
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.2), rgba(167, 139, 250, 0.15));
  border: 1px solid rgba(255, 255, 255, 0.08);
  transform: rotate(8deg);
}

.login-panel {
  background: var(--panel);
  backdrop-filter: blur(12px);
  padding: 40px 36px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

@media (min-width: 721px) {
  .login-shell { grid-template-columns: 1fr 1fr; }
}

.login-card-inner { width: 100%; max-width: 340px; margin: 0 auto; }

.login-panel h1 {
  margin: 0 0 6px;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-panel .lead {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 13px;
}

.error {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  color: #fecdd3;
  font-size: 13px;
}

.login-panel label {
  display: block;
  margin-top: 16px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.login-panel input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
  background: rgba(15, 23, 42, 0.6);
  color: var(--text);
  font-size: 15px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-panel input:focus {
  outline: none;
  border-color: rgba(167, 139, 250, 0.45);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.login-panel .btn.primary {
  width: 100%;
  margin-top: 24px;
  padding: 12px;
  font-size: 15px;
}

/* —— 按钮 —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  text-decoration: none;
  color: var(--text);
  background: rgba(148, 163, 184, 0.15);
  transition: background 0.2s, transform 0.15s;
}

.btn:hover { background: rgba(148, 163, 184, 0.22); }
.btn:active { transform: scale(0.98); }

.btn.primary {
  background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.btn.primary:hover {
  filter: brightness(1.06);
}

.btn.primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  filter: none;
  transform: none;
}

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

.btn.danger {
  background: var(--danger-bg);
  color: #fecdd3;
  border: 1px solid rgba(251, 113, 133, 0.25);
}

.btn.danger:hover { background: rgba(251, 113, 133, 0.22); }

.btn-ghost {
  color: var(--accent);
  background: transparent;
  padding: 6px 10px;
  font-size: 13px;
}

.btn-ghost:hover { background: var(--accent-dim); }

/* —— 侧栏 —— */
.admin-sidebar {
  width: 252px;
  flex-shrink: 0;
  padding: 16px;
}

.sidebar-inner {
  height: 100%;
  min-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 20px 14px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 20px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--panel-border);
  margin-bottom: 8px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #8b5cf6, #22d3ee);
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.4);
  flex-shrink: 0;
}

.brand-text {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.admin-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
  border: 1px solid transparent;
}

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

.nav-item.active {
  color: var(--text);
  background: linear-gradient(90deg, var(--accent-dim), transparent);
  border-color: rgba(167, 139, 250, 0.2);
}

.nav-ico {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-ico-svg {
  width: 20px;
  height: 20px;
  opacity: 0.92;
}

.nav-item.active .nav-ico-svg {
  opacity: 1;
  color: var(--accent);
}

.sidebar-foot {
  padding: 16px 8px 8px;
  border-top: 1px solid var(--panel-border);
  margin-top: auto;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 0 6px;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  flex-shrink: 0;
}

.user-meta { min-width: 0; }
.user-name { display: block; font-size: 13px; font-weight: 600; color: var(--text); }
.user-role { font-size: 11px; color: var(--muted); }

.btn-logout {
  display: block;
  text-align: center;
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--panel-border);
  transition: color 0.2s, border-color 0.2s;
}

.btn-logout:hover {
  color: var(--danger);
  border-color: rgba(251, 113, 133, 0.3);
}

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

.admin-main {
  flex: 1;
  padding: 20px 24px 32px;
  overflow: auto;
}

.main-inner {
  max-width: 1100px;
  margin: 0 auto;
}

/* —— 页面标题 —— */
.page-head {
  margin-bottom: 24px;
}

.page-head h2 {
  margin: 0 0 6px;
  font-size: clamp(1.35rem, 2.5vw, 1.55rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-head .muted,
.muted {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.page-head-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.breadcrumb {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumb a:hover { text-decoration: underline; }

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

.stat-card {
  position: relative;
  padding: 22px 20px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  overflow: hidden;
}

.stat-card::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: 80px;
  background: radial-gradient(circle, var(--accent-dim), transparent 70%);
  pointer-events: none;
}

.stat-card .stat-ico {
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.stat-ico-svg {
  width: 26px;
  height: 26px;
  color: var(--accent);
  opacity: 0.95;
}

.stat-card .num {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  background: linear-gradient(135deg, #e2e8f0, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-card .lbl {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

/* —— 面板与表格 —— */
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 4px 0 0;
  overflow: hidden;
}

.panel-hd {
  padding: 18px 22px 12px;
  border-bottom: 1px solid var(--panel-border);
}

.panel-hd h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

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

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

.data-table th,
.data-table td {
  padding: 14px 20px;
  text-align: left;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
}

.data-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.data-table tbody tr {
  transition: background 0.15s;
}

.data-table tbody tr:hover {
  background: rgba(167, 139, 250, 0.05);
}

.data-table tr:last-child td { border-bottom: none; }

.data-table a {
  color: var(--cyan);
  text-decoration: none;
  font-weight: 500;
}

.data-table a:hover { text-decoration: underline; }

.ellipsis {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag {
  display: inline-block;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.15);
  color: var(--muted);
}

.tag.ok {
  background: var(--cyan-dim);
  color: var(--cyan);
}

/* —— 设置表单 —— */
.form-grid {
  display: grid;
  grid-template-columns: minmax(100px, 160px) 1fr;
  gap: 16px 20px;
  align-items: start;
  padding: 20px 22px 24px;
  max-width: 640px;
}

.form-grid label {
  color: var(--muted);
  padding-top: 10px;
  font-size: 13px;
  font-weight: 500;
}

.form-grid input,
.form-grid textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
  background: rgba(15, 23, 42, 0.5);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}

.form-grid textarea { min-height: 88px; resize: vertical; }

.form-grid input:focus,
.form-grid textarea:focus {
  outline: none;
  border-color: rgba(167, 139, 250, 0.4);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-actions {
  grid-column: 1 / -1;
  padding-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.legal-note {
  margin: 20px 0 0;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.65;
  color: var(--muted);
  background: rgba(148, 163, 184, 0.06);
  border: 1px dashed var(--panel-border);
}

.ok-banner {
  margin-bottom: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--cyan-dim);
  color: var(--cyan);
  font-size: 13px;
}

.small {
  font-size: 12px;
  line-height: 1.65;
  color: var(--muted);
  padding: 16px 22px 20px;
}

/* —— 会话接待 —— */
.chat-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.chat-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.link-copy {
  width: min(380px, 100%);
  min-width: 200px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
  background: rgba(15, 23, 42, 0.5);
  color: var(--muted);
  font-size: 12px;
  font-family: ui-monospace, monospace;
}

.chat-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  min-height: 420px;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  border-radius: var(--radius);
  background: rgba(12, 10, 29, 0.65);
  border: 1px solid var(--panel-border);
  scroll-behavior: smooth;
}

.bubble {
  max-width: min(85%, 560px);
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 14px 14px 14px 6px;
}

.bubble.out {
  margin-left: auto;
  border-radius: 14px 14px 6px 14px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.35), rgba(139, 92, 246, 0.2));
  border: 1px solid rgba(167, 139, 250, 0.35);
}

.bubble.in {
  margin-right: auto;
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid var(--panel-border);
  border-radius: 14px 14px 14px 6px;
}

.bubble .meta {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}

.bubble .text {
  line-height: 1.5;
  word-break: break-word;
  font-size: 14px;
}

.chat-input {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  align-items: flex-end;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--panel-border);
}

.chat-input textarea {
  flex: 1;
  resize: vertical;
  min-height: 48px;
  max-height: 160px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
  background: rgba(15, 23, 42, 0.5);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}

.chat-input textarea:focus {
  outline: none;
  border-color: rgba(167, 139, 250, 0.4);
}

.pad { padding: 20px; }

/* —— 响应式 —— */
@media (max-width: 900px) {
  .admin-shell { flex-direction: column; }
  .admin-sidebar {
    width: 100%;
    padding: 12px 12px 0;
  }
  .sidebar-inner {
    min-height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 12px 14px;
  }
  .brand {
    border-bottom: none;
    margin-bottom: 0;
    padding: 4px 8px;
    flex: 1;
    min-width: 140px;
  }
  .admin-nav {
    flex: 2;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 4px;
    justify-content: flex-end;
  }
  .nav-item {
    padding: 8px 12px;
    font-size: 13px;
  }
  .nav-ico { width: 24px; height: 24px; }
  .sidebar-foot {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 12px;
    margin-top: 8px;
    border-top: 1px solid var(--panel-border);
  }
  .btn-logout { flex: 0 0 auto; padding: 8px 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid label { padding-top: 0; }
  .chat-wrap { height: calc(100vh - 260px); }
}
