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

:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --bg: #f8fafc;
  --bg-dark: #0a1733;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --radius: 16px;
  --radius-lg: 24px;

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
  --shadow: 0 10px 30px rgba(0,0,0,0.08);
  --shadow-lg: 0 20px 50px rgba(0,0,0,0.18);
  --shadow-xl: 0 25px 60px rgba(0,0,0,0.3);

  --tint-blue: #3b82f6;
  --tint-blue-bg: #eff6ff;
  --tint-green: #10b981;
  --tint-green-bg: #ecfdf5;
  --tint-orange: #f59e0b;
  --tint-orange-bg: #fffbeb;
  --tint-pink: #ec4899;
  --tint-pink-bg: #fdf2f8;
  --tint-indigo: #6366f1;
  --tint-indigo-bg: #eef2ff;
  --tint-red: #ef4444;
  --tint-purple: #8b5cf6;
  --tint-purple-bg: #f5f3ff;
  --tint-red-bg: #fef2f2;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* Auth pages - modern style */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #0a1733 0%, #1e3a8a 50%, #0f172a 100%);
}

.auth-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 900' preserveAspectRatio='xMidYMid slice'><polygon points='0,0 300,0 0,280' fill='%231e40af' opacity='0.55'/><polygon points='300,0 600,0 380,220' fill='%231d4ed8' opacity='0.4'/><polygon points='600,0 900,0 720,260 480,200' fill='%231e3a8a' opacity='0.55'/><polygon points='900,0 1200,0 1200,300 1020,260' fill='%231e40af' opacity='0.45'/><polygon points='0,280 280,260 80,520 0,580' fill='%231e293b' opacity='0.7'/><polygon points='280,260 480,200 600,460 380,500 220,420' fill='%231d4ed8' opacity='0.35'/><polygon points='600,460 720,260 900,320 880,540 720,580' fill='%231e3a8a' opacity='0.5'/><polygon points='900,320 1020,260 1200,300 1200,580 1020,560' fill='%231e40af' opacity='0.45'/><polygon points='0,580 80,520 220,720 0,900' fill='%231d4ed8' opacity='0.35'/><polygon points='220,720 380,500 480,720 320,900 80,900' fill='%231e3a8a' opacity='0.5'/><polygon points='480,720 600,460 720,580 700,760 540,820' fill='%231e40af' opacity='0.4'/><polygon points='700,760 880,540 1020,560 1100,800 920,900 720,900' fill='%231d4ed8' opacity='0.4'/><polygon points='1020,560 1200,580 1200,900 920,900 1100,800' fill='%231e3a8a' opacity='0.55'/></svg>");
  background-size: cover;
  background-position: center;
  opacity: 0.85;
  pointer-events: none;
  z-index: 0;
}

.auth-wrapper::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(99,102,241,0.25) 0%, transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(59,130,246,0.2) 0%, transparent 40%);
  pointer-events: none;
  z-index: 0;
}

.auth-card {
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255,255,255,0.1);
  padding: 44px 40px;
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 1;
}

.auth-wrapper > .auth-card {
  /* ensure card stacks above bg pattern */
  position: relative;
  z-index: 2;
}

.invite-banner {
  background: linear-gradient(135deg, #fff7ed, #ffedd5);
  border: 1.5px solid #fdba74;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 18px;
  color: #9a3412;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  line-height: 1.5;
}
.invite-banner strong {
  color: #c2410c;
  font-weight: 700;
  font-family: 'SF Mono', Menlo, monospace;
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

.auth-logo p {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 6px;
}

.form-group {
  margin-bottom: 18px;
}

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

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
  background: #fff;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 22px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  letter-spacing: 0.2px;
}

.btn-primary {
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  color: #fff;
  width: 100%;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4338ca 0%, #4f46e5 100%);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
  transform: translateY(-1px);
}

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

/* Avatar picker */
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 10px;
  max-width: 520px;
}

.avatar-pick {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  background: var(--bg);
}

.avatar-pick:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.avatar-pick.selected {
  border-color: var(--primary);
  transform: scale(1.08);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.avatar-pick-bg {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  opacity: 0.25;
  z-index: 0;
}

.avatar-pick-emoji {
  position: relative;
  z-index: 1;
  font-size: 28px;
  line-height: 1;
}

/* Dashboard welcome */
.dash-welcome {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.dash-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.dash-name {
  font-weight: 700;
  font-size: 20px;
  margin-top: 2px;
}

/* Profile section */
.profile-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.profile-card .btn-primary {
  width: auto;
  min-width: 140px;
}

.profile-card .form-row + .btn-primary {
  margin-top: 4px;
}

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

@media (max-width: 640px) {
  .avatar-grid { grid-template-columns: repeat(6, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .dash-name { font-size: 17px; }
  .dash-avatar { width: 50px; height: 50px; font-size: 28px; }
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-danger {
  background: #fef2f2;
  color: var(--danger);
  border: 1.5px solid #fecaca;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

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

.btn-ghost:hover {
  background: #eef2ff;
  border-radius: 6px;
}

.auth-switch {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-muted);
}

.auth-switch a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

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

/* Nav - modern glass over dark bg */
.nav {
  background: linear-gradient(135deg, #0a1733 0%, #1e3a8a 100%);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 12px rgba(10, 23, 51, 0.18);
}

.nav-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

/* 汉堡菜单按钮 (仅 admin 后台且移动端显示) */
.nav-burger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.18);
  cursor: pointer;
  color: #ffffff;
  margin-right: 12px;
  flex-shrink: 0;
  transition: background 0.2s;
}

.nav-burger:hover {
  background: rgba(255,255,255,0.2);
}

.nav-burger-icon {
  width: 18px;
  height: 14px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.nav-burger-icon span {
  display: block;
  height: 2px;
  background: #ffffff;
  border-radius: 1px;
  transition: all 0.25s;
}

.nav-brand {
  font-size: 19px;
  font-weight: 700;
  color: #ffffff;
  text-decoration: none;
  letter-spacing: 0.5px;
}

.nav-brand span {
  color: rgba(255,255,255,0.7);
  font-weight: 400;
  font-size: 13px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-user {
  font-size: 14px;
  color: rgba(255,255,255,0.95);
}

.nav .btn-ghost {
  color: rgba(255,255,255,0.92);
  font-weight: 500;
}

.nav .btn-ghost:hover {
  background: rgba(255,255,255,0.12);
  color: #ffffff;
}

/* Nav user trigger (clickable to open profile modal) */
.nav-user-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  color: #ffffff;
}

.nav-user-trigger:hover {
  border-color: rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.18);
}

.nav-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.25);
}

.nav-user-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.2;
}

.nav-user-greeting {
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  line-height: 1;
  margin-bottom: 2px;
}

.nav-user-name {
  font-weight: 600;
  font-size: 13px;
  color: #ffffff;
  margin-top: 1px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-chevron {
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  margin-left: 2px;
}

/* Dashboard */
.dashboard {
  padding: 28px 0 40px;
  color: var(--text);
  max-width: 1240px;
  margin: 0 auto;
  padding-left: 24px;
  padding-right: 24px;
}

/* 管理员以客户身份查看时的顶部提示横幅 */
.impersonate-banner {
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border: 1.5px solid #fca5a5;
  color: #991b1b;
  border-radius: 12px;
  padding: 12px 18px;
  margin: 0 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(239,68,68,0.08);
}
.impersonate-banner .btn-sm {
  background: #dc2626;
  color: #ffffff;
  border: none;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.impersonate-banner .btn-sm:hover {
  background: #b91c1c;
}

/* Modern page background — solid white; nav keeps the deep-blue glass effect on top */
.bg-modern {
  position: relative;
  min-height: 100vh;
  background: #ffffff;
}

/* Hero section is now just a transparent wrapper (white page bg shows through) */
.dashboard-hero {
  position: relative;
  padding: 8px 0 20px;
  z-index: 1;
}

/* Stat cards row (4-up tinted cards like muniu.app) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 10px;
}

.stat-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  border: 1px solid #e2e8f0;
  min-height: 140px;
  display: flex;
  flex-direction: column;
}

.stat-card::after {
  content: '';
  position: absolute;
  right: -28px;
  bottom: -28px;
  width: 140px;
  height: 140px;
  background: linear-gradient(135deg, transparent 50%, var(--accent, currentColor) 50%);
  border-radius: 50%;
  opacity: 0.13;
}

.stat-card .stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: var(--accent-bg, #eef2ff);
  margin-bottom: 16px;
  flex-shrink: 0;
}

.stat-card .stat-value {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.1;
  color: #1e293b;
  margin-bottom: 4px;
  letter-spacing: -0.5px;
}

/* 客户后台：使用较小字号，保持原有观感（到期时间卡片例外保留 18px） */
.dashboard .stat-card .stat-value:not([style*="font-size"]) {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0;
}

.stat-card .stat-label {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 4px;
}

.stat-card .stat-detail {
  font-size: 12px;
  color: var(--accent, #64748b);
  margin-top: auto;
  font-weight: 600;
  padding-top: 8px;
}

.stat-card.tint-blue   { --accent: #3b82f6; --accent-bg: #dbeafe; }
.stat-card.tint-green  { --accent: #10b981; --accent-bg: #d1fae5; }
.stat-card.tint-orange { --accent: #f59e0b; --accent-bg: #fef3c7; }
.stat-card.tint-red    { --accent: #ef4444; --accent-bg: #fee2e2; }
.stat-card.tint-purple { --accent: #8b5cf6; --accent-bg: #ede9fe; }
.stat-card.tint-pink   { --accent: #ec4899; --accent-bg: #fce7f3; }
.stat-card.tint-indigo { --accent: #6366f1; --accent-bg: #e0e7ff; }
.stat-card.tint-red    { --accent: #ef4444; --accent-bg: #fee2e2; }

.page-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 24px;
  color: #ffffff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Main 2-col layout for dashboard sections */
.main-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

.section-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}

.section-card h3 {
  font-size: 17px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Subscription cards - modern */
.sub-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.sub-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  border: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: visible;
  position: relative;
  min-height: 220px;
  border: none;
}

.sub-card.win {
  background: linear-gradient(135deg, #eff6ff 0%, #ffffff 70%);
}

.sub-card.ios {
  background: linear-gradient(135deg, #fef2f2 0%, #ffffff 70%);
}

.sub-card::before {
  content: '';
  position: absolute;
  right: -40px;
  top: -40px;
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, rgba(255,255,255,0.5) 0%, transparent 60%);
  pointer-events: none;
}

.sub-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  min-width: 0;
}

.sub-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.sub-card.win .sub-card-icon {
  background: #dbeafe;
}

.sub-card.ios .sub-card-icon {
  background: #fee2e2;
}

.sub-card-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.sub-card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 2px;
}

.sub-url-box {
  background: rgba(248, 250, 252, 0.95);
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 10px;
  min-width: 0;
  min-height: 80px;  /* 保证两张卡片 sub-url-box 同样高 */
}

.sub-url {
  width: 100%;
  font-size: 12px;
  font-family: 'Monaco', 'Consolas', monospace;
  color: var(--text);
  word-break: break-all;
  overflow-wrap: anywhere;
  line-height: 1.5;
  min-width: 0;
}

.copy-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 14px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 500;
}

.copy-btn.copied {
  background: var(--success);
}

/* 订阅按钮行（复制 + 一键导入） */
.sub-actions {
  display: flex;
  gap: 8px;
  width: 100%;
}
.sub-actions .copy-btn { flex: 1; }

.import-btn {
  background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex: 1;
  transition: transform 0.1s, box-shadow 0.15s;
}
.import-btn:hover:not(:disabled) {
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}
.import-btn:active:not(:disabled) {
  transform: scale(0.97);
}
.import-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* 导入下拉菜单 */
.import-dropdown {
  position: relative;
  flex: 1;
  display: flex;
}
.import-dropdown .import-btn {
  width: 100%;
}
.import-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  z-index: 9999;
  overflow: hidden;
  padding: 4px;
}
.import-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  text-align: left;
  font-size: 13px;
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.import-menu-item:hover {
  background: var(--bg);
}
.import-menu-item:active {
  background: #fde68a;
}
.import-menu-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.import-menu-icon {
  font-size: 16px;
  flex-shrink: 0;
}


/* Expiry banner */
.expiry-banner {
  background: #fefce8;
  border: 1.5px solid #fde047;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.expiry-banner.danger {
  background: #fef2f2;
  border-color: #fca5a5;
}

.expiry-banner .eb-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.expiry-banner .eb-content h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
}

.expiry-banner .eb-content p {
  font-size: 13px;
  color: var(--text-muted);
}

.expiry-days {
  font-size: 22px;
  font-weight: 800;
  color: var(--warning);
}

.expiry-banner.danger .expiry-days {
  color: var(--danger);
}

/* 风险提示卡片 */
.risk-notice {
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
  border: 1.5px solid #fdba74;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.risk-notice .rn-icon {
  font-size: 24px;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 2px;
}

.risk-notice .rn-content h4 {
  font-size: 15px;
  font-weight: 700;
  color: #9a3412;
  margin-bottom: 6px;
}

.risk-notice .rn-content p {
  font-size: 13px;
  color: #7c2d12;
  line-height: 1.65;
}

/* Stats grid (legacy class - kept for back-compat with admin stats page) */
.stat-card.legacy {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  border: 1.5px solid var(--border);
  text-align: center;
}

.stat-card.legacy .stat-num {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
}

.stat-card.legacy .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Table */
.table-wrap {
  background: var(--card);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.03);
}

/* Inner scroll wrapper so border-radius clips nicely + horizontal scroll on mobile */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll table { min-width: 720px; border-collapse: collapse; }

.table-toolbar {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  width: 280px;
}

.search-box input {
  border: none;
  background: transparent;
  font-size: 14px;
  flex: 1;
  outline: none;
}

.table-toolbar-right {
  display: flex;
  gap: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px 16px;
  text-align: left;
  font-size: 13px;
}

th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

tr:not(:last-child) td {
  border-bottom: 1px solid var(--border);
}

tr:hover td {
  background: #f8fafc;
}

/* Admin customer table - more compact, wider */
.admin-content .table-wrap table {
  font-size: 13px;
}

.admin-content .table-wrap th,
.admin-content .table-wrap td {
  padding: 14px 12px;
  vertical-align: middle;
}

.admin-content .table-wrap th {
  white-space: nowrap;
  font-size: 11px;
  padding: 12px 12px;
}

.admin-content .table-wrap td {
  line-height: 1.5;
}

/* 客户表：套餐 / VIP / 状态 / 操作 间隔加宽 */
.admin-content .table-wrap table th:nth-child(6),
.admin-content .table-wrap table td:nth-child(6),
.admin-content .table-wrap table th:nth-child(7),
.admin-content .table-wrap table td:nth-child(7),
.admin-content .table-wrap table th:nth-child(8),
.admin-content .table-wrap table td:nth-child(8),
.admin-content .table-wrap table th:nth-child(9),
.admin-content .table-wrap table td:nth-child(9) {
  padding-left: 20px;
  padding-right: 20px;
}

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

.status-badge.active {
  background: #dcfce7;
  color: var(--success);
}

.status-badge.expired {
  background: #fee2e2;
  color: var(--danger);
}

.status-badge.disabled {
  background: #f1f5f9;
  color: var(--text-muted);
}

.status-badge.no_expiry {
  background: #e0f2fe;
  color: #0369a1;
}

.status-badge.risk {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #92400e;
  border: 1px solid #f59e0b;
}

.actions-cell {
  display: flex;
  gap: 4px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal {
  background: var(--card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

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

.modal-header h2 {
  font-size: 17px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Settings form */
.settings-section {
  background: var(--card);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  margin-bottom: 20px;
  overflow: hidden;
}

.settings-section-header {
  padding: 16px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}

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

.setting-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.setting-row:last-child {
  margin-bottom: 0;
}

/* Toast */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: toastIn 0.3s ease;
}

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

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

/* Utility */
.text-muted { color: var(--text-muted); }
.font-mono { font-family: 'Monaco', 'Consolas', monospace; font-size: 12px; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-sm { font-size: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.text-center { text-align: center; }

/* Plan badge */
.plan-badge {
  background: #e0f2fe;
  color: #0369a1;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.plan-badge.plan-unpaid {
  background: #f1f5f9;
  color: #94a3b8;
}

/* VIP badge */
.vip-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.vip-badge.vip-personal {
  background: #f1f5f9;
  color: #475569;
}

.vip-badge.vip-team {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #92400e;
}

.vip-badge.vip-enterprise {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #fbbf24;
}

.vip-badge.vip-none {
  background: #f8fafc;
  color: #94a3b8;
  border: 1px dashed #cbd5e1;
}

/* Admin sidebar */
.admin-sidebar {
  position: fixed;
  left: 0;
  top: 64px;
  bottom: 0;
  width: 220px;
  background: rgba(10, 23, 51, 0.85);
  backdrop-filter: blur(16px);
  border-right: 1px solid rgba(255,255,255,0.08);
  padding: 12px 0;
  z-index: 10;
  overflow-y: auto;
}

.container.admin-page {
  max-width: 100%;
  margin: 0;
  padding: 28px 32px;
}

.admin-content {
  margin-left: 220px;
  min-height: calc(100vh - 105px);
}

.note-cell {
  font-size: 12px;
  color: #64748b;
  line-height: 1.5;
  max-width: 300px;
  word-break: break-word;
  white-space: pre-wrap;
}

.actions-cell {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  align-items: center;
}

.sidebar-item {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  color: rgba(255,255,255,0.8);
  border-left: 3px solid transparent;
}

.sidebar-item:hover {
  background: rgba(255,255,255,0.08);
  color: #ffffff;
}

.sidebar-item.active {
  background: rgba(79, 70, 229, 0.3);
  color: #ffffff;
  font-weight: 700;
  border-left: 3px solid #818cf8;
}

/* Primary text */
.text-primary { color: var(--primary); }

/* Quick renew buttons */
#renew-modal .modal-body button {
  transition: all 0.15s;
}

#renew-modal .modal-body button:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ==================== Client Downloads ==================== */
.downloads-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.download-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 22px 16px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
}

.download-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(59, 130, 246, 0.18);
  text-decoration: none;
}

.download-card.disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.download-card.disabled:hover {
  transform: none;
  box-shadow: 0 6px 20px rgba(0,0,0,0.06);
}

.download-logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(59,130,246,0.15);
}

.download-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 8px;
}

.download-emoji {
  font-size: 32px;
}

.download-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin-top: 2px;
}

.download-action {
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
  margin-top: 2px;
}

.download-card.disabled .download-action {
  color: var(--text-muted);
}

/* Admin download management — row layout */
#downloads-admin-list {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dl-admin-rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dl-admin-row {
  display: grid;
  grid-template-columns: 90px 200px 1fr 80px;
  gap: 16px;
  align-items: center;
}

.dl-logo-slot {
  width: 80px;
  height: 80px;
  border: 1.5px dashed var(--border);
  border-radius: 16px;
  background: var(--bg);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.dl-logo-slot:hover {
  border-color: var(--primary);
  background: #eef4ff;
}

.dl-logo-slot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 8px;
}

.dl-logo-placeholder {
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
  user-select: none;
  pointer-events: none;
}

.dl-input {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  outline: none;
  transition: border-color 0.15s;
}

.dl-input:focus {
  border-color: var(--primary);
  background: #fff;
}

.dl-row-actions {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.dl-act-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  padding: 0;
}

.dl-act-btn.save:hover {
  background: var(--primary);
  border-color: var(--primary);
  transform: scale(1.1);
}

.dl-act-btn.del:hover {
  background: var(--danger);
  border-color: var(--danger);
  transform: scale(1.1);
}

.dl-key {
  grid-column: 1 / -1;
  margin-top: -4px;
  font-size: 11px;
  font-family: 'Monaco', 'Consolas', monospace;
  opacity: 0.6;
}

.dl-admin-footer {
  border-top: 1px dashed var(--border);
  padding-top: 16px;
  margin-top: 4px;
  display: flex;
  justify-content: center;
}

.btn-add-client {
  background: transparent;
  border: 1.5px dashed var(--border);
  color: var(--primary);
  padding: 12px 32px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  width: auto;
}

.btn-add-client:hover {
  background: var(--primary);
  color: #fff;
  border-style: solid;
  border-color: var(--primary);
}

.admin-page-header {
  margin-bottom: 20px;
}
.admin-page-header h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
  color: #ffffff;
}

/* 商店系统 */
.shop-gen-card,
.shop-list-card {
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.03);
}
.shop-gen-card h3,
.shop-list-card h3 {
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 16px;
}
.shop-gen-form {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  align-items: end;
}
.shop-gen-form .form-group {
  margin-bottom: 0;
}
.gen-result {
  margin-top: 16px;
}
.gen-result-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px;
}
.gen-codes-area {
  width: 100%;
  min-height: 120px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 13px;
  resize: vertical;
}
.select-sm {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  font-size: 13px;
  background: #ffffff;
  cursor: pointer;
}

/* 客户后台：兑换会员 */
.redeem-card {
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.03);
}
.redeem-header {
  margin-bottom: 14px;
}
.redeem-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 4px;
}
.redeem-input-row {
  display: flex;
  gap: 12px;
  align-items: stretch;
}
.redeem-input {
  flex: 1;
  padding: 11px 16px;
  border-radius: 10px;
  border: 1.5px solid #e2e8f0;
  font-size: 15px;
  font-family: 'SF Mono', Menlo, monospace;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-width: 0;
  align-self: stretch;
}
.redeem-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.redeem-card .btn-primary {
  flex: 1;
  width: auto !important;
  white-space: nowrap;
  padding: 11px 16px;
  font-size: 15px;
}

/* 购买兑换码按钮：橙色主题，与「立即兑换」区别 */
.redeem-card .btn-shop {
  flex: 1;
  width: auto !important;
  white-space: nowrap;
  padding: 11px 16px;
  font-size: 15px;
  background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-weight: 600;
  transition: all 0.2s;
}
.redeem-card .btn-shop:hover {
  background: linear-gradient(135deg, #d97706 0%, #ea580c 100%);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
  transform: translateY(-1px);
}
.redeem-card .btn-shop:active {
  transform: translateY(0);
}

/* 兑换码复制样式 */
.code-copyable {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s;
  user-select: none;
}
.code-copyable:hover {
  background: #f1f5f9;
}
.code-copyable:hover .copy-mini {
  opacity: 1;
}
.copy-mini {
  font-size: 12px;
  opacity: 0.35;
  transition: opacity 0.15s;
}

@media (max-width: 768px) {
  .shop-gen-form { grid-template-columns: 1fr; }
  .redeem-input-row { flex-direction: column; }
  .redeem-card .btn-primary,
  .redeem-card .btn-shop { width: 100% !important; }
  .invite-url-row { flex-direction: column; gap: 10px; }
  .invite-url-row .btn-primary,
  .invite-url-row .btn-shop { width: 100% !important; flex: none; }
}

/* Admin main area: dark page + white content cards */
#admin-content {
  background: transparent;
}

.admin-content .table-wrap {
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.03);
  overflow: hidden;
}

.admin-content .table-wrap table { border-collapse: collapse; }

.admin-content .table-wrap th,
.admin-content .table-wrap td {
  border-color: #f1f5f9;
}

.admin-content .table-wrap th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
}

.admin-content .table-wrap td {
  color: #334155;
}

/* Modal on dark bg: give modal a white bg */
.modal-overlay .modal {
  background: #ffffff;
  border-radius: 20px;
}

.modal-overlay .modal-header {
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
}

.modal-overlay .modal-header h2 {
  color: #1e293b;
}

.modal-overlay .modal-body {
  background: #ffffff;
  color: #334155;
}

.modal-overlay .modal-close {
  color: #64748b;
}

.modal-overlay .modal-close:hover {
  color: #1e293b;
  background: #f1f5f9;
}

/* Toast on dark bg */
.toast {
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.toast.success {
  background: linear-gradient(135deg, #10b981, #059669);
}

.toast.error {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

.toast.info {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
}

.toast.warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

/* Form inputs on dark page need white bg */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="time"],
select,
textarea {
  background: #ffffff;
  color: #1e293b;
  border: 1.5px solid #e2e8f0;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

@media (max-width: 1100px) {
  .downloads-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 820px) {
  .dl-admin-row {
    grid-template-columns: 70px 1fr 60px;
    grid-template-areas:
      "logo name actions"
      "logo url  actions";
    gap: 10px;
  }
  .dl-admin-row .dl-logo-slot { grid-area: logo; }
  .dl-admin-row .dl-name-row { grid-area: name; }
  .dl-admin-row .dl-url-row { grid-area: url; }
  .dl-admin-row .dl-row-actions { grid-area: actions; }
}

@media (max-width: 600px) {
  .downloads-grid { grid-template-columns: 1fr; }
  .dl-logo-slot { width: 60px; height: 60px; }
  .dl-admin-row {
    grid-template-columns: 60px 1fr;
    grid-template-areas:
      "logo actions"
      "name name"
      "url  url";
  }
}

/* ==================== Logo Editor Modal ==================== */
.logo-editor-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.15s;
}

.logo-editor-overlay.show {
  display: flex;
}

.logo-editor-modal {
  background: var(--card);
  border-radius: 16px;
  width: 480px;
  max-width: 90vw;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.2s;
}

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

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

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

.logo-editor-header h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
}

.logo-editor-close {
  background: transparent;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.logo-editor-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.logo-editor-stage {
  width: 240px;
  height: 240px;
  border-radius: 22px;
  border: 2px dashed var(--border);
  background: var(--bg);
  overflow: hidden;
  position: relative;
  cursor: grab;
  user-select: none;
}

.logo-editor-stage:active {
  cursor: grabbing;
}

.logo-editor-stage img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: center;
  cursor: grab;
  display: block;
}

.logo-editor-hint {
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

.logo-editor-controls {
  padding: 16px 20px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.logo-editor-zoom-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-editor-zoom-row input[type="range"] {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}

.logo-editor-zoom-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
}

.logo-editor-zoom-row input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.logo-editor-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Edit button (separate color) */
.dl-act-btn.edit {
  background: var(--bg);
}

.dl-act-btn.edit:hover {
  background: #f59e0b;
  border-color: #f59e0b;
  transform: scale(1.1);
}

.dl-act-btn.edit:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.dl-act-btn.edit:disabled:hover {
  background: var(--bg);
  border-color: var(--border);
  transform: none;
}

/* Logo slot with drag cursor hint */
.dl-logo-slot {
  position: relative;
}

.dl-logo-slot img {
  cursor: grab;
}

.dl-logo-slot img:active {
  cursor: grabbing;
}

/* Three buttons per row (edit, save, del) */
.dl-row-actions {
  display: flex;
  gap: 4px;
  justify-content: center;
}

/* ─── 响应式：平板 ─── */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .sub-cards { grid-template-columns: 1fr; }
  .main-grid { grid-template-columns: 1fr; }
  .downloads-grid { grid-template-columns: repeat(2, 1fr); }
  .container.admin-page { padding: 24px 24px; }
}

/* ─── 平板 ─── */
@media (max-width: 768px) {
  /* Admin 后台侧边栏改为抽屉 */
  .admin-sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
    width: 240px;
  }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-content {
    margin-left: 0 !important;
  }
  .nav-burger { display: flex !important; }
  /* 遮罩 */
  .sidebar-backdrop {
    position: fixed;
    inset: 64px 0 0 0;
    background: rgba(0,0,0,0.5);
    z-index: 9;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }

  /* 表格横向滚动 */
  .table-wrap, .admin-content .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .admin-content .table-wrap table { min-width: 720px; }

  /* 订阅卡片：按钮堆叠为纵列 */
  .sub-actions { flex-direction: column; }
  .sub-actions .copy-btn, .sub-actions .import-btn { width: 100%; }
}

/* ─── 手机 ─── */
@media (max-width: 640px) {
  .auth-card { padding: 28px 22px; border-radius: 18px; }
  .auth-card h1 { font-size: 22px; }
  .nav-inner { padding: 0 12px; height: 60px; }
  .nav-brand { font-size: 16px; }
  .nav-user-name { display: none; }
  .nav-user-info { display: none; }
  .nav-chevron { display: none; }
  .nav-user-trigger { padding: 4px; gap: 0; }
  .nav-avatar { width: 34px; height: 34px; font-size: 17px; }
  .nav .btn-ghost { font-size: 12px; padding: 6px 8px; }

  .container { padding: 16px 14px; }
  .container.dashboard { padding: 16px 14px; }
  .container.admin-page { padding: 20px 14px; }

  .stats-grid { grid-template-columns: 1fr; gap: 12px; }
  .stat-card { min-height: 100px; padding: 18px; border-radius: 16px; }
  .stat-card .stat-value { font-size: 20px; }
  .stat-card .stat-label { font-size: 11px; }
  .stat-card .stat-icon { width: 32px; height: 32px; font-size: 16px; }

  .downloads-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .download-card { padding: 16px 10px; border-radius: 12px; }
  .download-logo { width: 48px; height: 48px; }

  .section-card { padding: 18px; border-radius: 14px; }
  .sub-card { padding: 18px; border-radius: 16px; min-height: auto; }
  .sub-card h3 { font-size: 15px; }
  .sub-url-box { padding: 12px; min-height: 70px; }
  .sub-url { font-size: 12px; }
  .copy-btn, .import-btn { font-size: 12px; padding: 8px 10px; }

  .expiry-banner { padding: 12px 14px; border-radius: 12px; }
  .expiry-banner h3 { font-size: 14px; }
  .expiry-banner p { font-size: 12px; }
  .risk-notice { padding: 12px 14px; border-radius: 12px; }
  .risk-notice .rn-content h4 { font-size: 14px; }
  .risk-notice .rn-content p { font-size: 12px; }
  .expiry-days { font-size: 18px; padding: 6px 12px; }

  /* Modal 全屏 */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%;
    max-height: 95vh;
    border-radius: 18px 18px 0 0;
  }
  .modal-header { padding: 16px 18px; }
  .modal-header h2 { font-size: 15px; }
  .modal-body { padding: 18px; }

  /* Profile form */
  .avatar-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .avatar-pick { width: 50px; height: 50px; font-size: 24px; }

  /* Import dropdown */
  .import-dropdown-menu { min-width: 160px; }

  /* Logo editor */
  .logo-editor-stage { width: 240px; height: 240px; }
}

/* ─── 小手机 ─── */
@media (max-width: 420px) {
  .downloads-grid { grid-template-columns: 1fr; }
  .nav-brand { font-size: 14px; letter-spacing: 0; }
  .nav-user-trigger { padding: 4px; }
  .stats-grid { gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card .stat-value { font-size: 18px; }
}

/* ─── 访问记录 ────────────────────────────────────────────────── */
.access-log-empty {
  padding: 24px;
  text-align: center;
  color: #94a3b8;
  background: #f8fafc;
  border-radius: 12px;
  font-size: 13px;
}

.access-devices {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.access-device-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  min-width: 0;
}
.ad-icon {
  font-size: 22px;
  flex-shrink: 0;
}
.ad-info { min-width: 0; }
.ad-name {
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}
.ad-os {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}

.access-log-list {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  overflow: hidden;
}

.access-log-row {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  align-items: center;
}
.access-log-row:last-child { border-bottom: none; }
.access-log-row.failed { background: #fef2f2; }
.access-log-row.failed .alr-icon { filter: grayscale(0.4); opacity: 0.7; }

.alr-icon {
  font-size: 22px;
  width: 32px;
  text-align: center;
  flex-shrink: 0;
}
.alr-body {
  flex: 1;
  min-width: 0;
}
.alr-line1, .alr-line2 {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.alr-line1 {
  font-size: 13px;
  color: #1e293b;
  font-weight: 500;
  margin-bottom: 4px;
}
.alr-line2 {
  font-size: 12px;
  color: #64748b;
}
.alr-platform {
  font-weight: 700;
  color: #4f46e5;
}
.alr-ip {
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 11px;
  color: #94a3b8;
}
.alr-fail {
  background: #fee2e2;
  color: #b91c1c;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.alr-sep { color: #cbd5e1; }

/* Admin 表格紧凑列 */
.last-access-cell {
  font-size: 12px;
}
.la-line1 {
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 2px;
}
.la-line2 {
  color: #64748b;
  font-size: 11px;
}

/* 访问记录弹窗 */
.access-logs-modal {
  max-width: 720px;
  width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.access-logs-modal .modal-body {
  overflow-y: auto;
  padding: 20px 24px;
}
.al-loading, .al-empty {
  padding: 40px;
  text-align: center;
  color: #94a3b8;
}
.al-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.als-item {
  text-align: center;
  padding: 14px;
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
}
.als-value {
  font-size: 22px;
  font-weight: 800;
  color: #4f46e5;
}
.als-label {
  font-size: 12px;
  color: #64748b;
  margin-top: 4px;
}

/* ── 访问审查 ── */
.audit-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  align-items: flex-end;
}
.audit-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
  flex: 1 1 auto;
}
.audit-field:first-child {
  flex: 2 1 320px;
}
.audit-field label {
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
}
.audit-field .form-control {
  min-width: 0;
  padding: 8px 10px;
  font-size: 13px;
  background: #ffffff;
}
.audit-empty,
.audit-loading {
  text-align: center;
  padding: 60px 20px;
  color: #94a3b8;
  font-size: 14px;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px dashed #e2e8f0;
}

/* ── 客户搜索选择器 ── */
.audit-customer-field { position: relative; }
.audit-customer-picker {
  position: relative;
}
.audit-customer-input {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.audit-customer-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.audit-customer-list {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15,23,42,0.12);
  z-index: 50;
}
.audit-customer-picker.open .audit-customer-list { display: block; }
.audit-customer-option {
  padding: 9px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.1s;
}
.audit-customer-option:last-child { border-bottom: none; }
.audit-customer-option:hover {
  background: #eef2ff;
  color: #4338ca;
}
.audit-customer-empty {
  padding: 14px;
  text-align: center;
  font-size: 13px;
  color: #94a3b8;
}
.audit-current {
  margin-top: 6px;
  font-size: 12px;
  color: #16a34a;
  font-weight: 600;
}

.al-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.al-row {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  align-items: flex-start;
}
.al-row.failed { background: #fef2f2; border-color: #fecaca; }
.al-row .alr-icon {
  margin-top: 2px;
}
.al-row .alr-line3 {
  margin-top: 4px;
  font-size: 11px;
  color: #94a3b8;
  font-family: 'SF Mono', Menlo, monospace;
}
.alr-ok {
  background: #dcfce7;
  color: #15803d;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

@media (max-width: 640px) {
  .access-device-chip { padding: 6px 10px; }
  .ad-icon { font-size: 18px; }
  .alr-line1, .alr-line2 { gap: 4px; }
  .access-logs-modal { max-height: 95vh; border-radius: 18px 18px 0 0; }
}

/* ── 邀请系统 ─────────────────────────────────────────── */
/* 客户后台 */
.invite-section {
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 16px;
  padding: 20px 24px;
  margin-bottom: 20px;
}
.invite-header { margin-bottom: 14px; }
.invite-header h3 { margin: 0 0 4px; font-size: 16px; }
.invite-url-block { margin-bottom: 14px; }
.invite-url-label {
  display: block; font-size: 13px; color: #475569;
  font-weight: 600; margin-bottom: 8px;
}
.invite-url-row {
  display: flex; gap: 10px; align-items: stretch;
}
.invite-url-input {
  flex: 1 1 0; min-width: 0; padding: 11px 16px;
  border: 1.5px solid #e2e8f0; border-radius: 10px;
  font-size: 15px; color: #475569; background: #f8fafc;
  letter-spacing: 0.3px; font-family: 'SF Mono', Menlo, monospace;
  text-align: center;
}
.invite-url-row .btn-primary {
  flex: 1;
  width: auto !important;
  white-space: nowrap;
  padding: 11px 16px;
  font-size: 15px;
}
.invite-url-row .btn-shop {
  flex: 1;
  width: auto !important;
  white-space: nowrap;
  padding: 11px 16px;
  font-size: 15px;
  background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
  color: #fff;
  text-decoration: none;
  text-align: center;
}
.invite-url-row .btn-shop:hover {
  background: linear-gradient(135deg, #d97706 0%, #ea580c 100%);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
  transform: translateY(-1px);
}
.invite-url-row .btn-shop:active {
  transform: translateY(0);
}
.modal-invite-records { max-width: 560px; }
.renew-quick-btn.active {
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  color: #fff;
  border-color: #4f46e5;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}
.invite-modal-tip {
  text-align: center; font-size: 12px; color: #94a3b8;
  margin-top: 12px; padding-top: 10px; border-top: 1px solid #f1f5f9;
}
.invite-records { margin-top: 8px; }
.invite-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.invite-table th {
  text-align: left; padding: 8px 12px; color: #94a3b8;
  font-weight: 600; font-size: 11px; border-bottom: 1px solid #f1f5f9;
}
.invite-table td {
  padding: 8px 12px; border-bottom: 1px solid #f8fafc; color: #334155;
}

/* 管理员后台 */
.invites-page { padding: 24px; }
.invites-toolbar { margin-bottom: 20px; }
.invites-stat-cards {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px;
}
.invites-stat-card {
  background: #fff; border-radius: 14px; padding: 18px 20px;
  border: 1.5px solid #e2e8f0; text-align: center;
}
.invites-stat-num { font-size: 28px; font-weight: 800; color: #0f172a; margin-bottom: 4px; }
.invites-stat-label { font-size: 12px; color: #64748b; }
.invites-filter-row { margin-bottom: 4px; }
.invites-table-wrap {
  background: #fff; border-radius: 16px; border: 1.5px solid #e2e8f0;
  overflow: hidden; padding: 0;
}
.invites-table { width: 100%; border-collapse: collapse; }
.invites-table th {
  text-align: left; padding: 12px 16px; font-size: 12px; font-weight: 600;
  color: #64748b; background: #f8fafc; border-bottom: 1px solid #f1f5f9;
}
.invites-table td {
  padding: 12px 16px; font-size: 13px; color: #334155; vertical-align: middle;
}
