/* ========================================
   CPA Master - Admin Dashboard v3.0
   后台管理系统样式 - 移动端适配 + 全新页面
   ======================================== */

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

:root {
  /* Light theme */
  --bg-page: #F1F5F9;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F8FAFC;
  --bg-sidebar: #0F172A;
  --bg-sidebar-active: #1E293B;
  --bg-sidebar-hover: #1E293B;
  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --text-inverse: #F8FAFC;
  --text-sidebar: #CBD5E1;
  --text-sidebar-muted: #64748B;
  --border: #E2E8F0;
  --border-light: #F1F5F9;
  --primary: #4F46E5;
  --primary-light: #EEF2FF;
  --primary-dark: #3730A3;
  --accent: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.1);
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --sidebar-w: 240px;
  --sidebar-collapsed-w: 64px;
  --topbar-h: 60px;
}

[data-theme="dark"] {
  --bg-page: #0B1220;
  --bg-card: #131C2E;
  --bg-card-hover: #1A253C;
  --bg-sidebar: #060B16;
  --bg-sidebar-active: #1E293B;
  --bg-sidebar-hover: #131C2E;
  --text-primary: #F1F5F9;
  --text-secondary: #CBD5E1;
  --text-muted: #64748B;
  --text-sidebar: #CBD5E1;
  --text-sidebar-muted: #475569;
  --border: #1E293B;
  --border-light: #131C2E;
  --primary-light: rgba(79, 70, 229, 0.15);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ===== Layout ===== */
.admin-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  transition: grid-template-columns 0.3s ease;
}

.admin-layout.sidebar-collapsed {
  grid-template-columns: var(--sidebar-collapsed-w) 1fr;
}

/* ===== Sidebar ===== */
.admin-sidebar {
  background: var(--bg-sidebar);
  color: var(--text-sidebar);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
  z-index: 50;
}

/* Collapsed sidebar (desktop) */
.sidebar-collapsed .admin-sidebar {
  padding: 20px 8px;
}

.sidebar-collapsed .admin-logo-text-wrap,
.sidebar-collapsed .nav-text,
.sidebar-collapsed .nav-group-title,
.sidebar-collapsed .nav-badge,
.sidebar-collapsed .nav-badge-new,
.sidebar-collapsed .admin-footer {
  display: none !important;
}

.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 12px 8px;
}

.sidebar-collapsed .nav-icon {
  margin: 0 auto;
}

.sidebar-collapsed .admin-logo {
  justify-content: center;
  padding: 6px 4px 24px;
}

.admin-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 16px;
}

.admin-logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366F1, #4F46E5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  font-size: 16px;
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.4);
  flex-shrink: 0;
}

.admin-logo-text {
  font-weight: 700;
  color: #fff;
  font-size: 16px;
  line-height: 1.2;
}

.admin-logo-sub {
  font-size: 11px;
  color: var(--text-sidebar-muted);
  font-weight: 500;
}

.nav-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-sidebar-muted);
  padding: 12px 12px 6px;
  white-space: nowrap;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  cursor: pointer;
  color: var(--text-sidebar);
  font-weight: 500;
  transition: all 0.2s ease;
  margin-bottom: 2px;
  font-size: 14px;
  user-select: none;
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: #fff;
}

.nav-item.active {
  background: linear-gradient(135deg, #4F46E5, #6366F1);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

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

.nav-text {
  flex: 1;
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 700;
}

.nav-badge-new {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.admin-footer {
  margin-top: auto;
  padding: 16px 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  color: var(--text-sidebar-muted);
  white-space: nowrap;
}

/* ===== Sidebar Toggle Button ===== */
.sidebar-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
  background: var(--bg-page);
  color: var(--text-primary);
}

/* ===== Mobile Sidebar Overlay ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 40;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
  display: block;
  opacity: 1;
}

/* ===== Main Content ===== */
.admin-main {
  padding: 24px 32px;
  overflow-x: hidden;
  min-width: 0;
}

.admin-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  background: var(--bg-card);
  padding: 14px 20px;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  gap: 12px;
}

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

.topbar-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.topbar-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  background: var(--bg-page);
  border-radius: 30px;
  cursor: pointer;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366F1, #EC4899);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

/* ===== Dashboard Cards ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  border: 1px solid var(--border-light);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
}

.stat-card.success::before { background: var(--accent); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.danger::before { background: var(--danger); }

.stat-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.stat-card-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-card-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 16px;
  font-weight: 700;
}

.stat-card.success .stat-card-icon { background: rgba(16, 185, 129, 0.1); color: var(--accent); }
.stat-card.warning .stat-card-icon { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.stat-card.danger .stat-card-icon { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

.stat-card-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-card-trend {
  font-size: 12px;
  color: var(--accent);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-card-trend.down { color: var(--danger); }

/* ===== Grid Layouts ===== */
.grid-2 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.grid-2-equal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

/* ===== Panels ===== */
.admin-panel {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

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

.panel-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.panel-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===== Charts ===== */
.chart-container {
  position: relative;
  height: 280px;
  margin-top: 8px;
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

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

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

.admin-table thead th {
  text-align: left;
  padding: 12px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-page);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.admin-table thead th:first-child { border-radius: 8px 0 0 8px; }
.admin-table thead th:last-child { border-radius: 0 8px 8px 0; }

.admin-table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background 0.2s ease;
}

.admin-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.admin-table tbody td {
  padding: 12px 14px;
  color: var(--text-primary);
  vertical-align: middle;
  white-space: nowrap;
}

.admin-table tbody td .user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-table tbody td .user-info .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366F1, #EC4899);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

/* ===== Badges ===== */
.a-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.a-badge.primary { background: var(--primary-light); color: var(--primary); }
.a-badge.success { background: rgba(16, 185, 129, 0.12); color: var(--accent); }
.a-badge.warning { background: rgba(245, 158, 11, 0.12); color: var(--warning); }
.a-badge.danger { background: rgba(239, 68, 68, 0.12); color: var(--danger); }
.a-badge.neutral { background: var(--border-light); color: var(--text-secondary); }

.a-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ===== Buttons ===== */
.a-btn {
  padding: 8px 14px;
  border-radius: var(--r-md);
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  white-space: nowrap;
  min-height: 36px;
}

.a-btn-primary {
  background: var(--primary);
  color: #fff;
}

.a-btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.a-btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.a-btn-ghost:hover {
  background: var(--bg-page);
  color: var(--text-primary);
}

.a-btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

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

.a-btn-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent);
}

.a-btn-success:hover {
  background: var(--accent);
  color: #fff;
}

.a-btn-sm { padding: 5px 10px; font-size: 12px; min-height: 32px; }

/* ===== Activity List ===== */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}

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

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

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-title {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.4;
  word-break: break-word;
}

.activity-title .name { font-weight: 600; }

.activity-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===== Login Page ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 50%, #EC4899 100%);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.08) 0%, transparent 50%);
}

.login-card {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  border-radius: 24px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.2);
  position: relative;
  z-index: 1;
  animation: loginCardIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes loginCardIn {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 32px;
}

.login-logo-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, #4F46E5, #7C3AED);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  font-size: 24px;
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.4);
}

.login-title {
  text-align: center;
  font-size: 24px;
  font-weight: 800;
  color: #0F172A;
  margin-bottom: 6px;
}

.login-subtitle {
  text-align: center;
  font-size: 13px;
  color: #64748B;
  margin-bottom: 32px;
}

.login-form-group {
  margin-bottom: 16px;
}

.login-form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

.login-form-input {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid #E2E8F0;
  border-radius: 10px;
  font-size: 16px;
  color: #0F172A;
  background: #F8FAFC;
  transition: all 0.2s ease;
  font-family: inherit;
}

.login-form-input:focus {
  outline: none;
  border-color: #4F46E5;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.login-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #4F46E5, #7C3AED);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: inherit;
  margin-top: 8px;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
  min-height: 48px;
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.4);
}

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

.login-error {
  margin-top: 8px;
  padding: 10px 14px;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 8px;
  font-size: 13px;
  color: #DC2626;
  text-align: center;
}

.login-back {
  position: absolute;
  top: 20px;
  left: 20px;
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  transition: all 0.2s ease;
}

.login-back:hover {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* ===== Modals ===== */
.a-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: modalFade 0.2s ease;
}

.a-modal.show { display: flex; }

@keyframes modalFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.a-modal-content {
  background: var(--bg-card);
  border-radius: var(--r-xl);
  padding: 28px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.2);
  animation: modalSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlide {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.a-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}

.a-modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.a-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-page);
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.a-modal-close:hover {
  background: var(--danger);
  color: #fff;
}

.a-form-group {
  margin-bottom: 16px;
}

.a-form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.a-form-input,
.a-form-textarea,
.a-form-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-page);
  font-family: inherit;
  transition: all 0.2s ease;
  min-height: 42px;
}

.a-form-input:focus,
.a-form-textarea:focus,
.a-form-select:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.a-form-textarea {
  min-height: 80px;
  resize: vertical;
}

.a-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.a-form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border-light);
}

/* ===== Toggle Switch ===== */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  transition: 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* ===== Toggle Grid (Content Page) ===== */
.toggle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-page);
  border-radius: var(--r-md);
  border: 1px solid var(--border-light);
  transition: all 0.2s ease;
}

.toggle-item:hover {
  border-color: var(--primary);
}

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

.toggle-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.toggle-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===== Radio Group (Xianyu Page) ===== */
.radio-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.radio-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--bg-page);
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  min-height: 48px;
}

.radio-item:hover {
  border-color: var(--primary);
}

.radio-item input[type="radio"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}

.radio-item:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
}

.radio-label {
  font-weight: 500;
  color: var(--text-primary);
}

/* ===== Stats Config Grid ===== */
.stats-config-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

/* ===== Content List (FAQ / Announcements) ===== */
.content-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.content-list-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-page);
  border-radius: var(--r-md);
  border: 1px solid var(--border-light);
  transition: all 0.2s ease;
}

.content-list-item:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.content-list-body {
  flex: 1;
  min-width: 0;
}

.content-list-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  word-break: break-word;
}

.content-list-desc {
  font-size: 13px;
  color: var(--text-secondary);
  word-break: break-word;
}

.content-list-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ===== Xianyu Plan Row ===== */
.xianyu-plan-row {
  display: grid;
  grid-template-columns: 120px 100px 1fr 60px 80px;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg-page);
  border-radius: var(--r-md);
  border: 1px solid var(--border-light);
  margin-bottom: 12px;
  transition: all 0.2s ease;
}

.xianyu-plan-row:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.xianyu-plan-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
}

.xianyu-plan-price {
  color: var(--primary);
  font-weight: 700;
  font-size: 14px;
}

.xianyu-link-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-card);
  font-family: inherit;
  transition: all 0.2s ease;
  min-height: 38px;
}

.xianyu-link-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.xianyu-link-input.invalid {
  border-color: var(--danger);
}

.xianyu-preview-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 38px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.xianyu-preview-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ===== Monitor Page Styles ===== */

/* Live indicator */
.live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  color: var(--danger);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  animation: livePulse 1.5s infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

/* Activity Stream */
.activity-stream {
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.stream-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 8px;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.2s ease;
  animation: streamIn 0.3s ease;
}

@keyframes streamIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

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

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

.stream-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.stream-icon.page_view { background: rgba(79, 70, 229, 0.1); color: var(--primary); }
.stream-icon.question { background: rgba(16, 185, 129, 0.1); color: var(--accent); }
.stream-icon.purchase { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.stream-icon.search { background: rgba(236, 72, 153, 0.1); color: #EC4899; }
.stream-icon.action { background: rgba(139, 92, 246, 0.1); color: #8B5CF6; }
.stream-icon.error { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

.stream-content {
  flex: 1;
  min-width: 0;
}

.stream-text {
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-word;
}

.stream-text .highlight { font-weight: 600; }

.stream-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.activity-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* Purchase tracking item */
.purchase-track-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}

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

.purchase-track-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.purchase-track-count {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.purchase-track-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--warning);
}

/* Popular page item */
.page-rank-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}

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

.page-rank-num {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  background: var(--bg-page);
  color: var(--text-muted);
}

.page-rank-item:nth-child(1) .page-rank-num { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.page-rank-item:nth-child(2) .page-rank-num { background: rgba(148, 163, 184, 0.15); color: var(--text-secondary); }
.page-rank-item:nth-child(3) .page-rank-num { background: rgba(180, 83, 9, 0.15); color: #B45309; }

.page-rank-name {
  flex: 1;
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-rank-views {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
}

/* ===== Page Toggle ===== */
.admin-page { display: none; }
.admin-page.active { display: block; animation: pageFade 0.3s ease; }

@keyframes pageFade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Toast ===== */
.a-toast {
  position: fixed;
  top: 24px;
  right: 24px;
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 14px 20px;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  min-width: 260px;
  max-width: 400px;
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.a-toast.success { border-left-color: var(--accent); }
.a-toast.error { border-left-color: var(--danger); }
.a-toast.warning { border-left-color: var(--warning); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ===== Filters ===== */
.filter-input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-card);
  font-size: 14px;
  color: var(--text-primary);
  min-width: 180px;
  font-family: inherit;
  min-height: 38px;
  transition: all 0.2s ease;
}

.filter-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ===== Action Bar ===== */
.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.action-bar-left { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.action-bar-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.admin-sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); }
.admin-sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

/* ===== Responsive: Tablet ===== */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-2-equal { grid-template-columns: 1fr; }
  .stats-config-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-main { padding: 20px 24px; }
}

/* ===== Responsive: Mobile (768px) ===== */
@media (max-width: 768px) {
  :root {
    --sidebar-w: 240px;
  }

  /* Layout: sidebar becomes overlay */
  .admin-layout {
    grid-template-columns: 1fr !important;
  }

  .admin-layout.sidebar-collapsed {
    grid-template-columns: 1fr !important;
  }

  /* Sidebar: hidden by default, slides in */
  .admin-sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    width: 260px;
    height: 100vh;
    z-index: 60;
    transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-lg);
  }

  .admin-sidebar.open {
    left: 0;
  }

  /* Always show full sidebar on mobile (not collapsed) */
  .admin-sidebar .nav-text,
  .admin-sidebar .nav-group-title,
  .admin-sidebar .admin-logo-text-wrap,
  .admin-sidebar .admin-footer {
    display: block !important;
  }

  .admin-sidebar .nav-item {
    justify-content: flex-start;
    padding: 10px 12px;
  }

  .admin-sidebar .nav-icon {
    margin: 0;
  }

  /* Main content */
  .admin-main {
    padding: 16px;
  }

  /* Topbar */
  .admin-topbar {
    padding: 12px 16px;
    flex-wrap: wrap;
  }

  .topbar-left {
    gap: 8px;
  }

  .topbar-title {
    font-size: 18px;
  }

  .topbar-subtitle {
    font-size: 11px;
  }

  .topbar-actions {
    gap: 8px;
  }

  .user-chip {
    padding: 4px 8px 4px 4px;
  }

  .user-chip-name {
    display: none;
  }

  /* Stats: single column */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stat-card {
    padding: 16px;
  }

  .stat-card-value {
    font-size: 24px;
  }

  /* Panels */
  .admin-panel {
    padding: 16px;
  }

  .panel-header {
    margin-bottom: 14px;
    padding-bottom: 12px;
  }

  .panel-title {
    font-size: 15px;
  }

  /* Forms */
  .a-form-row {
    grid-template-columns: 1fr;
  }

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

  /* Toggle grid */
  .toggle-grid {
    grid-template-columns: 1fr;
  }

  /* Xianyu plan row: stack vertically */
  .xianyu-plan-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 12px;
  }

  .xianyu-plan-name,
  .xianyu-plan-price {
    font-size: 13px;
  }

  /* Buttons: ensure min 48px touch target */
  .a-btn {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 14px;
  }

  .a-btn-sm {
    min-height: 40px;
    padding: 8px 12px;
    font-size: 13px;
  }

  /* Filter inputs */
  .filter-input {
    min-width: 140px;
    font-size: 14px;
    min-height: 44px;
  }

  /* Action bar */
  .action-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .action-bar-left,
  .action-bar-right {
    width: 100%;
  }

  .action-bar-right {
    justify-content: flex-end;
  }

  /* Tables: horizontal scroll */
  .admin-table {
    font-size: 14px;
  }

  .admin-table thead th {
    font-size: 13px;
    padding: 10px 12px;
  }

  .admin-table tbody td {
    padding: 10px 12px;
  }

  /* Modal: full screen on mobile */
  .a-modal {
    padding: 0;
    align-items: stretch;
  }

  .a-modal-content {
    border-radius: 0;
    max-width: 100%;
    max-height: 100vh;
    min-height: 100vh;
    padding: 20px 16px;
    border-radius: 0;
  }

  .a-modal-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
  }

  .a-modal-title {
    font-size: 16px;
  }

  .a-form-actions {
    flex-direction: column-reverse;
    gap: 8px;
  }

  .a-form-actions .a-btn {
    width: 100%;
    justify-content: center;
  }

  /* Activity stream */
  .activity-stream {
    max-height: 300px;
  }

  .stream-item {
    padding: 10px 4px;
  }

  /* Chart container */
  .chart-container {
    height: 220px;
  }

  /* Content list */
  .content-list-item {
    flex-direction: column;
    gap: 8px;
  }

  .content-list-actions {
    width: 100%;
    justify-content: flex-end;
  }

  /* Login */
  .login-card {
    padding: 32px 24px;
  }

  .login-title {
    font-size: 20px;
  }

  /* Radio group */
  .radio-group {
    flex-direction: column;
  }

  .radio-item {
    width: 100%;
  }
}

/* ===== Responsive: Small Mobile (480px) ===== */
@media (max-width: 480px) {
  .admin-main {
    padding: 12px;
  }

  .stats-grid {
    gap: 10px;
  }

  .stat-card {
    padding: 14px;
  }

  .stat-card-value {
    font-size: 22px;
  }

  .stat-card-icon {
    width: 32px;
    height: 32px;
  }

  .admin-panel {
    padding: 14px;
  }

  .panel-title {
    font-size: 14px;
  }

  .topbar-title {
    font-size: 16px;
  }

  .filter-input {
    min-width: 100%;
  }

  .action-bar-left {
    flex-direction: column;
    align-items: stretch;
  }

  .action-bar-left .filter-input {
    width: 100%;
  }

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

  /* Table font */
  .admin-table {
    font-size: 13px;
  }

  .admin-table thead th {
    padding: 8px 10px;
  font-size: 12px;
  }

  .admin-table tbody td {
    padding: 8px 10px;
  }
}
