/* =============================================
   闪绘 SnapDraw — Prismatic Aperture 深色主题
   设计语言：深空靛蓝 · 棱镜光谱 · 半透明卡片 · 发光强调
   ============================================= */

:root {
  --bg-primary: #070b1e;
  --bg-secondary: #0c1228;
  --bg-tertiary: rgba(238,242,255,0.05);
  --bg-sidebar: #0a0f24;

  --text-primary: #eef2ff;
  --text-secondary: rgba(238,242,255,0.62);
  --text-tertiary: rgba(238,242,255,0.38);
  --text-placeholder: rgba(238,242,255,0.28);

  --border: rgba(238,242,255,0.08);
  --border-strong: rgba(238,242,255,0.16);

  --accent-blue: #3b82f6;
  --accent-blue-hover: #2f74e8;
  --accent-green: #34c759;
  --accent-orange: #f59e0b;
  --accent-red: #ff3b30;
  --accent-purple: #8b5cf6;

  --glow-blue: rgba(59,130,246,0.16);
  --glow-green: rgba(52,199,89,0.14);
  --glow-red: rgba(255,59,48,0.12);
  --glow-orange: rgba(245,158,11,0.12);

  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --shadow-card: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-card-hover: 0 4px 14px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);

  --sidebar-width: 220px;
  --font-tracking: -0.022em;
}

* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: var(--font-tracking);
  display: flex;
}

body.is-previewing-image { overflow: hidden; }

/* Keep auth UI hidden until the saved session check has resolved. */
.auth-page {
  display: none;
}

body.auth-pending {
  background: var(--bg-primary);
}

body.auth-pending .sidebar,
body.auth-pending .main-content {
  visibility: hidden;
}

body.auth-pending::before {
  content: "";
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 1000;
}

body.auth-ready .auth-page {
  display: flex;
}

/* =============================================
   Sidebar
   ============================================= */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand { padding: 28px 20px 20px; }
.sidebar-brand a {
  text-decoration: none;
  display: flex; align-items: center; gap: 10px;
}

.sidebar-logo {
  width: 32px; height: 32px;
  border-radius: 7px;
  box-shadow: none;
}

.sidebar-brand h2 {
  font-size: 15px; font-weight: 650; color: var(--text-primary);
  letter-spacing: -0.01em;
}

.sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.1; gap: 2px; }

.sidebar-tagline {
  font-size: 9.5px; font-weight: 500;
  letter-spacing: 0.22em;
  color: var(--text-tertiary);
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1; padding: 4px 12px;
  display: flex; flex-direction: column; gap: 1px;
}

.sidebar-divider {
  font-size: 10px; font-weight: 600; letter-spacing: 0.06em;
  color: var(--text-tertiary); text-transform: uppercase;
  padding: 20px 12px 6px;
}

.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border: none; border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px; font-weight: 450;
  cursor: pointer; text-align: left;
  width: 100%; font-family: inherit;
  letter-spacing: var(--font-tracking);
  transition: background 0.12s ease, color 0.12s ease;
  box-shadow: none;
}

.sidebar-link:hover {
  background: rgba(0,0,0,0.04);
  color: var(--text-primary);
  transform: none; box-shadow: none; filter: none;
}

.sidebar-link.is-active {
  background: rgba(0,122,255,0.08);
  color: var(--accent-blue);
  font-weight: 550;
  box-shadow: none;
}

#adminTab.sidebar-link.is-active { color: var(--accent-purple); background: rgba(175,82,222,0.08); }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: 8px;
}

.sidebar-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 600;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1; min-width: 0; font-size: 11px; color: var(--text-secondary);
}

/* =============================================
   Mobile Sidebar
   ============================================= */
.sidebar-toggle {
  display: none; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border: none; border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer; font-size: 18px;
  font-family: inherit;
  box-shadow: none;
}

.sidebar-toggle:hover { background: #e8e8ed; transform: none; box-shadow: none; filter: none; }

.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.2); z-index: 99;
}
.sidebar-overlay.is-visible { display: block; }

/* =============================================
   Main Content
   ============================================= */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1; min-height: 100vh;
  display: flex; flex-direction: column;
}

/* =============================================
   Top Bar
   ============================================= */
.topbar {
  height: 52px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px;
  background: rgba(7,11,30,0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
  gap: 14px;
}

.topbar-health,
.health {
  font-size: 12px; font-weight: 500; color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  background: var(--bg-secondary);
}
.topbar-health.ok,
.health.ok { color: var(--accent-green); background: rgba(52,199,89,0.08); }
.topbar-health.warn,
.health.warn { color: var(--accent-orange); background: rgba(255,149,0,0.08); }

.topbar-user {
  display: flex; align-items: center; gap: 12px;
  font-size: 13px; color: var(--text-secondary);
}

.topbar-logout {
  border: none; border-radius: 6px;
  padding: 5px 12px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 12px; font-weight: 500;
  cursor: pointer; font-family: inherit;
  box-shadow: none;
  width: auto;
}

.topbar-actions {
  display: flex; align-items: center; gap: 10px;
}

.topbar-login-btn {
  border: none; border-radius: 8px;
  padding: 7px 16px;
  background: var(--accent-blue);
  color: #fff;
  font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  width: auto;
  box-shadow: none;
  transition: background 0.12s ease, transform 0.12s ease;
}

.topbar-login-btn:hover {
  background: var(--accent-blue-hover);
  transform: none;
  box-shadow: none;
}

.topbar-logout:hover {
  background: rgba(255,59,48,0.08);
  color: var(--accent-red);
  transform: none; box-shadow: none; filter: none;
}

/* =============================================
   Auth Page
   ============================================= */
.auth-page {
  align-items: center; justify-content: center;
  min-height: calc(100vh - 52px);
  padding: 40px 24px;
}

.auth-box {
  width: 400px;
  text-align: center;
}

.auth-logo {
  width: 56px; height: 56px;
  border-radius: 14px;
  margin: 0 auto 24px;
  box-shadow: none;
}

.auth-box h2 {
  font-size: 26px; font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
}

.auth-box .helper-text {
  font-size: 15px; color: var(--text-secondary);
  margin: 0 0 32px;
  line-height: 1.5;
}

.auth-mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  background: var(--bg-secondary);
  border-radius: 9px;
  padding: 3px;
  margin-bottom: 24px;
  border: none;
}

.auth-mode-button {
  padding: 8px 14px;
  border: none; border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px; font-weight: 500;
  cursor: pointer; font-family: inherit;
  width: 100%;
  box-shadow: none;
  transition: all 0.15s ease;
}

.auth-mode-button:hover {
  transform: none; box-shadow: none; filter: none;
  background: transparent; color: var(--text-primary);
}

.auth-mode-button.is-active {
  background: rgba(238,242,255,0.1);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3), 0 0 0 0.5px rgba(238,242,255,0.08);
}

.auth-form-shell {
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  padding: 24px;
  margin-bottom: 16px;
  text-align: left;
}

.auth-form { display: flex; flex-direction: column; gap: 14px; }

.auth-form-title {
  font-size: 15px; font-weight: 650;
  color: var(--text-primary);
  margin-bottom: 4px;
  text-align: center;
}

/* =============================================
   Page Content
   ============================================= */
.page-content {
  padding: 36px 40px 64px;
  flex: 1;
  max-width: 1100px;
}

.feature-stage {
  /* wrapper, no additional styles needed */
}

/* =============================================
   Panel Card
   ============================================= */
.panel-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.panel-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-card-hover);
}

/* =============================================
   Home Page (LinkFox-inspired)
   ============================================= */
.home-hero {
  text-align: center;
  padding: 52px 24px 44px;
  margin-bottom: 32px;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, rgba(79,70,229,0.07) 0%, rgba(159,79,255,0.05) 40%, rgba(0,122,255,0.04) 100%);
  border: 1px solid rgba(79,70,229,0.1);
  position: relative;
  overflow: hidden;
}

.home-hero::before {
  content: ""; position: absolute;
  top: -80px; right: -60px;
  width: 240px; height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(159,79,255,0.1) 0%, transparent 70%);
  pointer-events: none;
}

.home-hero::after {
  content: ""; position: absolute;
  bottom: -60px; left: -40px;
  width: 180px; height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(79,70,229,0.08) 0%, transparent 70%);
  pointer-events: none;
}

.home-hero h1 {
  font-size: 36px; font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: 0 0 10px;
  position: relative; z-index: 1;
  background: linear-gradient(135deg, #4F46E5, #9F4FFF);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.home-hero p {
  font-size: 16px; color: var(--text-secondary);
  margin: 0 auto 24px;
  max-width: 520px;
  line-height: 1.6;
  position: relative; z-index: 1;
}

.home-hero-cta {
  display: flex; justify-content: center; gap: 12px;
  position: relative; z-index: 1;
  flex-wrap: wrap;
}

.home-cta-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 28px;
  border: none; border-radius: 10px;
  background: linear-gradient(135deg, #4F46E5, #7C3AED);
  color: #fff;
  font-size: 15px; font-weight: 650;
  cursor: pointer; font-family: inherit;
  width: auto;
  letter-spacing: -0.01em;
  box-shadow: 0 4px 14px rgba(79,70,229,0.25);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.home-cta-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(79,70,229,0.35);
  background: linear-gradient(135deg, #4338CA, #6D28D9);
}

.home-cta-outline {
  background: transparent;
  border: 1.5px solid rgba(79,70,229,0.3);
  color: #4F46E5;
  box-shadow: none;
}

.home-cta-outline:hover {
  background: rgba(79,70,229,0.05);
  border-color: rgba(79,70,229,0.5);
  box-shadow: none;
  color: #4F46E5;
}

/* Section */
.home-section {
  margin-bottom: 36px;
}

.home-section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}

.home-section-title {
  font-size: 18px; font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 16px;
  letter-spacing: -0.01em;
}

.home-section-head .home-section-title { margin-bottom: 0; }

/* Bento Grid */
.home-bento-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.home-bento-item {
  display: flex; align-items: flex-start; gap: 13px;
  padding: 18px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-primary);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
  text-align: left;
  font-family: inherit;
  width: 100%;
  color: inherit;
  box-shadow: var(--shadow-card);
}

.home-bento-item:hover {
  border-color: rgba(79,70,229,0.2);
  box-shadow: 0 8px 24px rgba(79,70,229,0.06);
  transform: translateY(-1px);
  background: transparent;
}

.home-bento-hero {
  grid-column: span 2;
  grid-row: span 1;
}

.home-bento-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px;
  color: #fff;
  flex-shrink: 0;
}

.home-bento-body {
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0;
}

.home-bento-body strong {
  font-size: 14px; font-weight: 650;
  color: var(--text-primary);
}

.home-bento-body span {
  font-size: 13px; color: var(--text-secondary);
  line-height: 1.5;
}

/* Steps */
.home-steps {
  display: flex; align-items: flex-start; gap: 0;
  justify-content: space-between;
}

.home-step {
  flex: 1;
  text-align: center;
  padding: 0 8px;
}

.home-step-num {
  width: 44px; height: 44px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4F46E5, #7C3AED);
  color: #fff;
  font-size: 20px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.home-step-content strong {
  display: block;
  font-size: 15px; font-weight: 650;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.home-step-content span {
  font-size: 13px; color: var(--text-secondary);
  line-height: 1.5;
}

.home-step-arrow {
  font-size: 24px; color: var(--text-tertiary);
  padding: 10px 4px 0;
  flex-shrink: 0;
}

/* Compare — Prismatic Aperture 改版：暗房 vs 光谱 */
.home-compare {
  display: grid;
  grid-template-columns: 1fr 72px 1fr;
  gap: 16px;
  align-items: stretch;
}

.home-compare-col {
  border-radius: 20px;
  padding: 28px;
  position: relative;
  overflow: hidden;
}

/* 旧：低饱和冷调，传达"低效、缓慢" */
.home-compare-old {
  background: #f6f7fb;
  border: 1px solid #e2e8f0;
  color: #64748b;
}
.home-compare-old .home-compare-tag {
  display: inline-block;
  font-size: 10px; font-weight: 700; letter-spacing: 0.22em;
  padding: 3px 10px; border-radius: 999px;
  background: #e2e8f0; color: #94a3b8;
  margin-bottom: 10px;
}
.home-compare-old .home-compare-head h3 {
  font-size: 18px; color: #94a3b8; font-weight: 700;
  letter-spacing: -0.01em; margin-bottom: 18px;
}
.home-compare-old .home-compare-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: #e2e8f0; color: #94a3b8; font-size: 11px;
  margin-right: 12px; flex-shrink: 0; font-weight: 700;
}
.home-compare-old .home-compare-list li {
  font-size: 13.5px; color: #64748b;
  padding: 13px 0; border-bottom: 1px solid #e2e8f0;
  display: flex; align-items: center; line-height: 1.5;
}
.home-compare-old .home-compare-list li:last-child { border-bottom: none; }

/* 新：深空靛蓝 + 顶部光谱光束 —— AI、智能、专业 */
.home-compare-new {
  background: linear-gradient(135deg, #0e1533 0%, #1a1440 60%, #221844 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  box-shadow:
    0 12px 32px rgba(15, 21, 51, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.home-compare-new::before {
  content: "";
  position: absolute;
  top: 0; left: 8%; right: 8%;
  height: 3px;
  background: linear-gradient(90deg, #3b82f6 0%, #8b5cf6 35%, #d946ef 70%, #f59e0b 100%);
  box-shadow: 0 0 16px rgba(139, 92, 246, 0.5);
  border-radius: 0 0 2px 2px;
}
.home-compare-new .home-compare-tag {
  display: inline-block;
  font-size: 10px; font-weight: 700; letter-spacing: 0.22em;
  padding: 3px 10px; border-radius: 999px;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6, #d946ef);
  color: #ffffff;
  margin-bottom: 10px;
}
.home-compare-new .home-compare-head h3 {
  font-size: 18px; color: #ffffff; font-weight: 800;
  letter-spacing: -0.01em; margin-bottom: 18px;
}
.home-compare-new .home-compare-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #d946ef);
  color: #ffffff; font-size: 11px;
  margin-right: 12px; flex-shrink: 0; font-weight: 700;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.45);
}
.home-compare-new .home-compare-list li {
  font-size: 13.5px; color: #cbd5e1;
  padding: 13px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex; align-items: center; line-height: 1.5;
}
.home-compare-new .home-compare-list li:last-child { border-bottom: none; }

/* 中央棱镜光圈 —— 呼应 logo 取景框 + 光谱光束 */
.home-compare-center {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative;
}
.home-compare-prism {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, #0e1533, #1a1440);
  border: 1px solid rgba(139, 92, 246, 0.3);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  box-shadow:
    0 0 28px rgba(139, 92, 246, 0.25),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}
.home-compare-prism::after {
  content: "";
  width: 24px; height: 5px;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6, #d946ef, #f59e0b);
  border-radius: 5px;
  transform: rotate(-45deg);
  box-shadow: 0 0 14px rgba(139, 92, 246, 0.5);
}
.home-compare-prism-label {
  font-size: 8.5px; font-weight: 700;
  letter-spacing: 0.28em;
  color: #94a3b8;
  margin-top: 10px;
}

/* 响应式 */
@media (max-width: 768px) {
  .home-compare {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .home-compare-center {
    flex-direction: row;
    gap: 10px;
    padding: 4px 0;
  }
  .home-compare-prism-label { margin-top: 0; }
}
.home-recent-tasks {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  padding: 16px;
  min-height: 60px;
}

/* Responsive for home */
@media (max-width: 768px) {
  .home-bento-grid { grid-template-columns: 1fr; }
  .home-bento-hero { grid-column: span 1; }
  .home-steps { flex-direction: column; gap: 8px; }
  .home-step-arrow { transform: rotate(90deg); padding: 0; font-size: 20px; }
}

.section-header {
  margin-bottom: 24px;
}

.section-header h2 {
  font-size: 26px; font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin: 0 0 4px;
}

/* Keep original .card reference for compatibility */
.card { background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 28px; box-shadow: var(--shadow-card); }
.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-card-hover); }
.card h2 { margin: 0 0 4px; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; color: var(--text-primary); }

/* =============================================
   Feature Panel visibility
   ============================================= */
.feature-panel[hidden] { display: none !important; }
.feature-panel.is-active { animation: panelReveal 0.2s ease-out; }

@keyframes panelReveal {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Old feature-switcher (hidden in sidebar layout) */
.feature-switcher { display: none; }

/* =============================================
   Forms & Inputs
   ============================================= */
label {
  display: block;
  margin-bottom: 16px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
}

textarea, select, input[type="text"], input[type="password"], input[type="number"], input[type="file"] {
  width: 100%;
  margin-top: 6px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--bg-primary);
  color: var(--text-primary);
  padding: 11px 14px;
  font-size: 14px;
  font-family: inherit;
  letter-spacing: var(--font-tracking);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  -webkit-appearance: none;
}

textarea:focus, select:focus, input[type="text"]:focus, input[type="password"]:focus, input[type="number"]:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 4px rgba(0,122,255,0.15);
}

textarea { resize: vertical; line-height: 1.6; }

::placeholder { color: var(--text-placeholder); }

.row {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 14px;
}
.row.two-cols { grid-template-columns: 1fr 1fr; }
.row.three-cols { grid-template-columns: 1fr 1fr 140px; }

/* File Input */
input[type="file"] { padding: 10px 12px; cursor: pointer; }
input[type="file"]::file-selector-button {
  padding: 5px 12px;
  border: none; border-radius: 6px;
  background: rgba(0,122,255,0.08);
  color: var(--accent-blue);
  font-size: 12px; font-weight: 600;
  cursor: pointer; margin-right: 10px;
  transition: background 0.12s ease;
}
input[type="file"]::file-selector-button:hover { background: rgba(0,122,255,0.15); }

/* =============================================
   Buttons
   ============================================= */
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%;
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: 14px; font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: var(--accent-blue);
  cursor: pointer;
  letter-spacing: var(--font-tracking);
  transition: background 0.12s ease, transform 0.12s ease;
  box-shadow: none;
  position: relative; overflow: hidden;
}

button:hover {
  background: var(--accent-blue-hover);
  transform: none; box-shadow: none; filter: none;
}

button:active { background: #0055cc; transform: scale(0.98); }

button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; filter: none; }

.secondary-button {
  width: auto;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: none;
  padding: 7px 14px;
  font-size: 12px; font-weight: 500;
  box-shadow: none;
  white-space: nowrap;
}

.secondary-button:hover {
  background: #e8e8ed;
  transform: none; filter: none; box-shadow: none;
  border: none;
}

.secondary-button:disabled { opacity: 0.4; cursor: not-allowed; }

.secondary-link {
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--accent-blue);
  text-decoration: none;
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px; font-weight: 500;
}

.secondary-link:hover { background: rgba(0,122,255,0.06); }

.danger-button { color: var(--accent-red); }

/* =============================================
   Status & Health
   ============================================= */
.status {
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-top: 14px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.status:empty {
  display: none;
}

.status.ok {
  background: rgba(52,199,89,0.08);
  color: var(--accent-green);
  border: 1px solid rgba(52,199,89,0.15);
}

.status.warn {
  background: rgba(255,149,0,0.08);
  color: var(--accent-orange);
  border: 1px solid rgba(255,149,0,0.15);
}

.status.error {
  background: rgba(255,59,48,0.08);
  color: var(--accent-red);
  border: 1px solid rgba(255,59,48,0.15);
}

/* =============================================
   Result Area
   ============================================= */
.result { margin-top: 16px; }

.result-actions {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 8px; margin-bottom: 12px;
}

.result img {
  display: block;
  width: 100%;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  transition: transform 0.12s ease;
}

.result img:hover { transform: scale(1.003); }

/* Image preview trigger */
.image-preview-trigger {
  position: relative;
  display: block;
  width: 100%;
  padding: 0; margin: 0 0 12px;
  border: 0; border-radius: var(--radius-md);
  background: transparent;
  color: inherit;
  cursor: zoom-in;
  overflow: hidden;
  box-shadow: none;
}

.image-preview-trigger:hover {
  transform: none; filter: none; box-shadow: none;
}

.image-preview-trigger::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgba(0,0,0,0.18));
  opacity: 0; transition: opacity 0.15s ease;
  pointer-events: none;
}

.image-preview-trigger:hover::after { opacity: 1; }

.image-preview-hint {
  position: absolute; right: 12px; bottom: 12px; z-index: 1;
  padding: 6px 10px; border-radius: 999px;
  background: rgba(7,11,30,0.85);
  color: var(--text-primary);
  font-size: 11px; font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  opacity: 0; transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
}

.image-preview-trigger:hover .image-preview-hint,
.image-preview-trigger:focus-visible .image-preview-hint {
  opacity: 1; transform: translateY(0);
}

/* Image Viewer */
.image-viewer {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: center;
  padding: 28px;
}

.image-viewer-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.image-viewer-dialog {
  position: relative; z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1100px, 96vw);
  max-height: 92vh;
  border-radius: 16px;
  background: rgba(12,18,40,0.97);
  border: 1px solid rgba(238,242,255,0.12);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  overflow: hidden;
}

.image-viewer-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.image-viewer-actions { display: flex; align-items: center; gap: 8px; }

.image-viewer-body {
  min-height: 0; padding: 16px; overflow: auto;
  background: var(--bg-tertiary);
}

.image-viewer-body img {
  display: block;
  max-width: 100%;
  max-height: calc(92vh - 100px);
  width: auto; height: auto;
  margin: 0 auto;
  border-radius: 12px;
  object-fit: contain;
  background: rgba(7,11,30,0.6);
}

/* =============================================
   Upload Preview
   ============================================= */
.upload-preview {
  margin: -4px 0 16px;
  padding: 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  transition: border-color 0.12s ease;
}

.upload-preview:hover { border-color: rgba(0,0,0,0.15); }

.upload-preview.is-empty {
  color: var(--text-tertiary);
  font-size: 13px;
  line-height: 1.6;
}

.upload-preview-single img {
  display: block;
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: 6px;
  background: var(--bg-tertiary);
}

.upload-preview-meta { margin-top: 10px; color: var(--text-tertiary); font-size: 12px; }

.upload-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
}

.upload-preview-grid.is-empty { display: block; }

.upload-preview-item {
  border-radius: 6px; overflow: hidden;
  background: rgba(0,0,0,0.03);
  border: 1px solid var(--border);
  transition: border-color 0.12s, transform 0.12s;
}

.upload-preview-item:hover {
  border-color: rgba(0,0,0,0.12);
  transform: translateY(-1px);
}

.upload-preview-item img {
  display: block; width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--bg-tertiary);
}

.upload-preview-item div {
  padding: 7px 9px 9px;
  color: var(--text-secondary);
  font-size: 11px; line-height: 1.5;
  word-break: break-word;
}

/* =============================================
   Product Gallery
   ============================================= */
.fixed-size-note {
  margin: -4px 0 16px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--accent-green);
  background: rgba(52,199,89,0.06);
  border: 1px solid rgba(52,199,89,0.12);
  font-size: 13px;
}

.gallery-analysis {
  margin-bottom: 14px; padding: 12px 14px;
  border-radius: var(--radius-md);
  color: var(--accent-blue);
  background: rgba(0,122,255,0.06);
  border: 1px solid rgba(0,122,255,0.12);
  font-size: 13px; line-height: 1.6;
}

.product-gallery-toolbar {
  margin: 0 0 14px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
}

.product-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.product-gallery-item {
  padding: 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-primary);
  box-shadow: var(--shadow-card);
  min-width: 0;
  overflow: hidden;
}

.product-gallery-item > * { min-width: 0; }

.product-gallery-item pre {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  margin: 0;
}

.product-gallery-item.is-main {
  grid-column: span 2;
  border-color: rgba(0,122,255,0.2);
  box-shadow: 0 0 0 1px rgba(0,122,255,0.05), 0 4px 16px rgba(0,0,0,0.05);
}

.product-gallery-item img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  border-radius: 8px;
  margin-bottom: 10px;
  background: var(--bg-tertiary);
}

/* =============================================
   Task Progress
   ============================================= */
.task-panel-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 12px;
}

.task-panel-head h2 { margin-bottom: 4px; }

.task-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px; margin-top: 14px;
}

.task-summary-item {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-secondary);
  box-shadow: none;
}

.task-summary-item:hover {
  transform: none; filter: none; box-shadow: none;
  border-color: var(--border-strong);
}

.task-summary-item span { font-size: 12px; }
.task-summary-item strong { color: var(--text-primary); font-size: 22px; line-height: 1; }

.task-summary-active { border-left: 3px solid var(--accent-blue); }
.task-summary-completed { border-left: 3px solid var(--accent-green); }
.task-summary-partial { border-left: 3px solid var(--accent-orange); }
.task-summary-failed { border-left: 3px solid var(--accent-red); }

.task-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.task-filters { display: flex; flex-wrap: wrap; gap: 4px; }

.task-filter {
  width: auto;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 12px;
  box-shadow: none;
}

.task-filter:hover,
.task-filter.is-active {
  transform: none; filter: none; box-shadow: none;
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #fff;
}

.task-filter-hint {
  flex: 0 0 auto;
  color: var(--text-tertiary);
  font-size: 12px;
}

.task-retention-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-orange);
  border-radius: 8px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.task-retention-note strong {
  color: var(--accent-orange);
  font-weight: 650;
}

.task-retention-icon {
  flex-shrink: 0;
  font-size: 15px;
  line-height: 1;
}

.task-list { display: grid; gap: 6px; margin-top: 10px; }

.task-pagination-host { margin-top: 14px; }

.task-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 0;
  border-top: 1px dashed var(--border);
}

.task-page-btn {
  width: auto;
  min-width: 36px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  box-shadow: none;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.task-page-btn:hover:not(:disabled):not(.is-active) {
  border-color: var(--border-strong);
  color: var(--text-primary);
  background: var(--bg-secondary);
}
.task-page-btn.is-active {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #fff;
}
.task-page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.task-page-btn.is-active:disabled {
  opacity: 0.9;
}

.task-page-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: task-page-spin 0.7s linear infinite;
  vertical-align: -1px;
}

@keyframes task-page-spin {
  to { transform: rotate(360deg); }
}

.task-page-ellipsis {
  min-width: 24px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
  user-select: none;
}

.task-pagination-hint {
  margin-left: 6px;
  color: var(--text-tertiary);
  font-size: 12px;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .task-pagination { justify-content: center; }
  .task-pagination-hint { margin-left: 0; width: 100%; text-align: center; }
}

.task-empty {
  padding: 18px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
  line-height: 1.6;
}

.task-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) 116px 106px minmax(130px, auto);
  align-items: center; gap: 12px;
  min-height: 60px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.task-row:hover,
.task-row.is-selected {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-card);
}

.task-row.task-partial { border-left: 3px solid var(--accent-orange); }
.task-row.task-failed { border-left: 3px solid var(--accent-red); }

.task-row-main { min-width: 0; }

.task-row-main strong,
.task-row-main small {
  display: block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.task-row-main strong { color: var(--text-primary); font-size: 14px; font-weight: 600; }
.task-row-main small { margin-top: 3px; color: var(--text-tertiary); font-size: 11px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.task-row-user {
  display: inline-block;
  margin-top: 4px; padding: 2px 8px;
  border-radius: 999px;
  background: rgba(175,82,222,0.08);
  border: 1px solid rgba(175,82,222,0.12);
  color: var(--accent-purple);
  font-size: 11px; font-weight: 500;
}

.task-row-count, .task-row-time { overflow: hidden; color: var(--text-secondary); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.task-row-time { color: var(--text-tertiary); }

.task-row-actions { display: flex; justify-content: flex-end; gap: 6px; }
.task-row-actions .secondary-button { padding: 6px 10px; font-size: 12px; }

.task-row-progress { height: 3px; margin-top: 6px; overflow: hidden; border-radius: 2px; background: var(--bg-secondary); }
.task-row-progress span { display: block; height: 100%; border-radius: inherit; background: var(--accent-blue); transition: width 0.25s ease; }

.task-status {
  flex: 0 0 auto;
  padding: 4px 10px; border-radius: 999px;
  color: var(--accent-blue);
  background: rgba(0,122,255,0.08);
  border: 1px solid rgba(0,122,255,0.12);
  font-size: 11px; font-weight: 700;
}

.task-status.ok { color: var(--accent-green); background: rgba(52,199,89,0.08); border-color: rgba(52,199,89,0.12); }
.task-status.warn { color: var(--accent-orange); background: rgba(255,149,0,0.08); border-color: rgba(255,149,0,0.12); }
.task-status.error { color: var(--accent-red); background: rgba(255,59,48,0.08); border-color: rgba(255,59,48,0.12); }

.task-progress { height: 6px; overflow: hidden; border-radius: 3px; background: var(--bg-secondary); }
.task-progress span { display: block; height: 100%; border-radius: inherit; background: var(--accent-blue); transition: width 0.25s ease; }

.task-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 10px; color: var(--text-tertiary); font-size: 12px; }

.task-error {
  margin-top: 12px; white-space: pre-wrap; word-break: break-word;
  color: var(--accent-red);
  background: rgba(255,59,48,0.05);
  border: 1px solid rgba(255,59,48,0.1);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.task-result-actions { margin-top: 14px; }

.task-result {
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--border);
}

.task-detail {
  grid-column: 1 / -1;
  margin-top: 0; padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  min-width: 0;
  overflow: hidden;
}

.task-detail * { min-width: 0; }

.task-detail-head, .task-detail-title, .task-detail-progress, .task-detail-meta {
  display: flex; align-items: center; gap: 10px;
}
.task-detail-head { justify-content: space-between; align-items: flex-start; }
.task-detail-title { flex-wrap: wrap; }
.task-detail-head code { display: inline-block; margin-top: 6px; cursor: copy; word-break: break-all; }
.task-detail-progress { margin-top: 14px; }
.task-detail-progress .task-progress { flex: 1; }
.task-detail-progress > span { flex: 0 0 auto; color: var(--text-secondary); font-size: 12px; }
.task-detail-meta { flex-wrap: wrap; margin-top: 10px; color: var(--text-tertiary); font-size: 12px; }
.task-detail-result { border-top: 0; }
.task-detail-empty {
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--text-tertiary); font-size: 13px;
}

/* =============================================
   Batch Items
   ============================================= */
.batch-item {
  margin-top: 14px; padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-primary);
  box-shadow: var(--shadow-card);
  transition: border-color 0.12s;
}

.batch-item:hover { border-color: var(--border-strong); }

.batch-item-header {
  display: flex; justify-content: space-between;
  gap: 12px; align-items: center;
  margin-bottom: 10px;
}

.batch-item-header strong { font-size: 14px; font-weight: 600; color: var(--text-primary); }

.batch-item-success { border-color: rgba(52,199,89,0.2); }
.batch-item-success .batch-item-header span {
  color: var(--accent-green); font-size: 12px; font-weight: 500;
  background: rgba(52,199,89,0.08); padding: 2px 10px; border-radius: 999px;
}

.batch-item-error { border-color: rgba(255,59,48,0.12); }
.batch-item-error .batch-item-header span {
  color: var(--accent-red); font-size: 12px; font-weight: 500;
  background: rgba(255,59,48,0.08); padding: 2px 10px; border-radius: 999px;
}

/* =============================================
   Helper Text & Tips
   ============================================= */
.helper-text {
  margin: 0 0 16px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
}

.tips { margin-top: 20px; }
.tips h2 { font-size: 16px; font-weight: 600; margin-bottom: 12px; color: var(--text-primary); }
.tips ol { margin: 0; padding-left: 20px; }
.tips li { margin-bottom: 6px; color: var(--text-secondary); font-size: 14px; line-height: 1.6; }
.tips li:last-child { margin-bottom: 0; }

code {
  background: var(--bg-secondary);
  padding: 2px 7px; border-radius: 5px;
  font-size: 13px; color: var(--accent-blue);
  border: 1px solid rgba(0,122,255,0.08);
}

kbd {
  display: inline-block; padding: 1px 7px;
  font-size: 12px; font-family: inherit;
  color: var(--text-secondary);
  background: rgba(0,0,0,0.04);
  border: 1px solid var(--border);
  border-radius: 5px;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.06);
}

/* =============================================
   Replace Mode Options
   ============================================= */
.replace-mode-row {
  display: flex; gap: 12px; margin-bottom: 16px;
}

.replace-mode-option {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 13px; font-weight: 500;
  transition: all 0.12s ease;
}

.replace-mode-option:hover { border-color: rgba(0,0,0,0.15); }

.replace-mode-option.is-replace:has(input:checked),
.replace-mode-option:has(input:checked) {
  border-color: rgba(0,122,255,0.25);
  background: rgba(0,122,255,0.06);
  color: var(--accent-blue);
}

.replace-mode-option.is-style:has(input:checked) {
  border-color: rgba(175,82,222,0.25);
  background: rgba(175,82,222,0.06);
  color: var(--accent-purple);
}

.replace-mode-option input[type="radio"] { width: auto; margin: 0; accent-color: var(--accent-blue); }

/* =============================================
   Admin
   ============================================= */
.admin-stats-panel, .admin-create-form {
  margin-bottom: 24px; padding: 24px;
  border-radius: var(--radius-lg);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
}

.admin-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.admin-stats-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px; margin-bottom: 24px;
}

.admin-stats-summary article {
  padding: 24px 20px; border-radius: var(--radius-lg);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  text-align: center;
}

.admin-stats-summary span, .admin-stats-summary small {
  display: block; color: var(--text-tertiary); font-size: 12px;
}

.admin-stats-summary strong {
  display: block; margin: 8px 0 6px;
  color: var(--text-primary); font-size: 32px; line-height: 1.1;
  font-weight: 700;
}

.admin-stats-column {
  display: flex; flex-direction: column; gap: 24px;
}

.admin-stats-section h3 { margin: 0 0 10px; color: var(--text-secondary); font-size: 13px; font-weight: 600; text-transform: none; letter-spacing: 0; }

.admin-stat-list { display: flex; flex-direction: column; gap: 0; }

.admin-stat-bar-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary); font-size: 13px;
  transition: background 0.15s;
}
.admin-stat-bar-row:last-child { border-bottom: none; }
.admin-stat-bar-row:hover { background: var(--bg-tertiary); margin: 0 -8px; padding: 6px 8px; border-radius: 4px; }
.admin-stat-bar-row.is-today { background: rgba(0,122,255,0.04); }
.admin-stat-bar-row.is-today .admin-stat-bar-label { color: var(--accent-blue); font-weight: 600; }

.admin-stat-bar-label {
  flex: 0 0 88px; min-width: 0;
  font-variant-numeric: tabular-nums; font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.admin-stat-bar-track {
  flex: 1; height: 6px; min-width: 40px;
  background: var(--bg-secondary);
  border-radius: 3px; overflow: hidden;
}

.admin-stat-bar-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
  transition: width 0.4s ease;
}

.admin-stat-bar-count {
  flex: 0 0 48px; text-align: right;
  color: var(--text-primary); font-size: 14px; font-weight: 650;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
  .admin-stat-bar-label { flex: 0 0 64px; }
  .admin-stat-bar-count { flex: 0 0 36px; font-size: 13px; }
}

/* Billing */
.admin-billing-summary {
  margin-bottom: 24px; padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255,149,0,0.15);
  border-radius: var(--radius-md);
  background: rgba(255,149,0,0.04);
}

.admin-billing-head, .admin-billing-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}

.admin-billing-head { color: var(--text-primary); font-size: 13px; }

.admin-billing-toggle {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  align-items: center; gap: 14px;
  width: 100%; padding: 12px 14px;
  border: 0; border-radius: 0;
  background: transparent; color: var(--text-primary);
  box-shadow: none; text-align: left;
}

.admin-billing-toggle:hover { transform: none; filter: none; background: rgba(255,149,0,0.04); box-shadow: none; }

.admin-billing-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 10px; }
.admin-billing-title strong { color: var(--text-primary); font-size: 13px; }
.admin-billing-title small, .admin-billing-total, .admin-billing-row span { color: var(--text-tertiary); font-size: 12px; }
.admin-billing-total { justify-self: end; }

.admin-billing-chevron {
  display: grid; place-items: center;
  width: 24px; height: 24px; border-radius: 999px;
  background: rgba(255,149,0,0.08);
  color: var(--accent-orange);
  font-size: 16px; line-height: 1;
  transition: transform 0.15s ease;
}

.admin-billing-summary:not(.is-collapsed) .admin-billing-chevron { transform: rotate(180deg); }

.admin-billing-content { padding: 0 14px 12px; }
.admin-billing-content[hidden] { display: none; }

.admin-billing-row {
  margin-top: 9px; padding-top: 9px;
  border-top: 1px solid rgba(255,149,0,0.1);
}

.admin-billing-row strong { color: var(--accent-orange); font-size: 13px; }
.admin-billing-row { flex-wrap: wrap; }

.admin-billing-actions { display: inline-flex; gap: 8px; }
.admin-billing-actions .secondary-button { padding: 4px 12px; font-size: 12px; }

.admin-billing-records {
  margin: 6px 0 10px; padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(238,242,255,0.05);
  border: 1px solid rgba(245,158,11,0.15);
}

.admin-billing-record {
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  padding: 4px 0; font-size: 12px; color: var(--text-tertiary);
}

.admin-billing-record + .admin-billing-record { border-top: 1px dashed rgba(255,149,0,0.08); }

.admin-billing-record .balance-plus { color: var(--accent-green); font-weight: 600; }
.admin-billing-record .balance-minus { color: var(--accent-red); font-weight: 600; }
.admin-billing-record .admin-billing-note { flex: 1 1 100%; color: var(--text-tertiary); opacity: 0.85; }

/* Admin table */
.admin-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin-top: 8px;
}

.admin-table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}

.admin-table th, .admin-table td {
  padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: left;
  line-height: 1.5;
  white-space: nowrap;
  vertical-align: middle;
}

.admin-table th {
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  font-size: 11px; letter-spacing: 0.02em; font-weight: 650;
}

.admin-actions { display: inline-flex; gap: 6px; flex-wrap: nowrap; }

/* 用户列表分页 */
.admin-pagination { display: flex; align-items: center; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.admin-pagination .secondary-button { padding: 4px 10px; font-size: 13px; min-width: 32px; }
.admin-pagination .secondary-button.is-active { background: var(--accent-blue); color: #fff; border-color: var(--accent-blue); }
.admin-pagination .secondary-button:disabled { opacity: 0.4; cursor: not-allowed; }
.admin-pagination-info { margin-left: 8px; color: var(--text-secondary); font-size: 12px; }

/* 邀请码 */
.admin-section { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--border); }
.admin-section h3 { margin: 0 0 4px; font-size: 16px; font-weight: 650; }
.invite-form { margin-bottom: 12px; }
.invite-form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.invite-form-row label {
  display: flex; flex-direction: column; gap: 4px;
  flex: 1 1 200px; min-width: 0;
}
.invite-form-row label input {
  width: 100%; box-sizing: border-box;
  padding: 10px 12px; font-size: 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-primary); color: var(--text-primary);
}
.invite-form-row button {
  flex-shrink: 0; align-self: flex-end;
  width: auto; padding: 10px 20px; font-size: 14px;
  margin-bottom: 0; height: auto;
}
.invite-code-badge {
  font-size: 14px; font-weight: 600; letter-spacing: 2px;
  color: var(--accent-blue); background: rgba(0,122,255,0.06);
  padding: 4px 10px; border-radius: var(--radius-sm); cursor: pointer;
  user-select: none; transition: background 0.15s;
}
.invite-code-badge:hover { background: rgba(0,122,255,0.12); }
.badge { font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 4px; }
.badge-ok { color: var(--accent-green); background: rgba(52,199,89,0.08); }
.badge-muted { color: var(--text-tertiary); background: var(--bg-secondary); }
.small-button { font-size: 12px; padding: 3px 10px; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid var(--border); background: var(--bg-primary); color: var(--text-secondary); width: auto; }
.small-button.danger-button { color: var(--accent-red); border-color: rgba(255,59,48,0.15); background: rgba(255,59,48,0.05); }
.small-button.danger-button:hover { background: rgba(255,59,48,0.1); }

/* =============================================
   Scrollbar
   ============================================= */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.2); }

/* =============================================
   Animations
   ============================================= */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.result > *, .batch-item, .upload-preview:not(.is-empty) {
  animation: fadeIn 0.25s ease-out;
}

/* =============================================
   Responsive
   ============================================= */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-overlay.is-visible { display: block; }
  .sidebar-toggle { display: flex; }
  .main-content { margin-left: 0; }
  .topbar { padding: 0 16px; }
  .page-content { padding: 24px 16px 48px; max-width: none; }
  .product-gallery-item.is-main { grid-column: span 1; }
  .product-gallery-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

@media (max-width: 1280px) {
  .product-gallery-item.is-main { grid-column: span 1; }
}

@media (max-width: 640px) {
  .auth-box { width: 100%; }
  .row, .row.two-cols, .row.three-cols { grid-template-columns: 1fr; }
  .admin-stats-summary, .admin-stats-grid, .task-summary { grid-template-columns: 1fr 1fr; }
  .task-row {
    grid-template-columns: 1fr auto;
    gap: 8px 12px; padding: 12px;
  }
  .task-row-status, .task-row-main { grid-column: 1; }
  .task-row-count, .task-row-time { grid-column: 2; grid-row: 1; text-align: right; }
  .task-row-time { grid-row: 2; }
  .task-row-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .task-toolbar { align-items: flex-start; flex-direction: column; }
  .task-detail-head { flex-direction: column; }
  .task-detail-head > .secondary-button { width: 100%; }
  .upload-preview-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
  .topbar { padding: 0 12px; }
  .page-content { padding: 20px 12px 40px; }
  .replace-mode-row { flex-direction: column; }
}

@media (min-width: 901px) {
  .sidebar-toggle { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .feature-panel.is-active, .result > *, .batch-item, .upload-preview:not(.is-empty) {
    animation: none !important;
  }
}

/* ── 管理面板开关 ── */
.admin-model-toggle,
.admin-fallback-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-tertiary);
  box-sizing: border-box;
  line-height: 1;
}

.admin-model-toggle .toggle-label,
.admin-fallback-toggle .toggle-label {
  display: inline-flex;
  align-items: center;
  align-self: center;
  height: 100%;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  color: var(--text-secondary);
  white-space: nowrap;
}

.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  align-self: center;
  margin: auto 0;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--text-tertiary);
  border-radius: 22px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform 0.2s ease;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent-blue);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

.toggle-switch input:disabled + .toggle-slider {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── 重新生成加载态 ── */
.product-gallery-item.is-regenerating {
  position: relative;
  pointer-events: none;
}

.product-gallery-item.is-regenerating > * {
  opacity: 0.55;
  transition: opacity 0.2s ease;
}

.product-gallery-item.is-regenerating::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.02);
  z-index: 5;
  pointer-events: none;
  border-radius: inherit;
}

.secondary-button.is-regenerating {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  position: relative;
}

.secondary-button.is-regenerating::before {
  content: "";
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: regen-spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes regen-spin {
  to { transform: rotate(360deg); }
}
