/* ============================================================
   FlipBook Pro — Dashboard Styles (app.css)
   Created with Perplexity Computer
   ============================================================ */

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Colors — refined dark theme */
  --color-sidebar-bg: #0c1222;
  --color-sidebar-surface: #111a2e;
  --color-sidebar-hover: rgba(255, 255, 255, 0.06);
  --color-sidebar-active: rgba(37, 99, 235, 0.12);
  --color-sidebar-active-border: #3b82f6;
  --color-sidebar-text: #7b8ba5;
  --color-sidebar-text-hover: #c8d3e3;
  --color-sidebar-text-active: #e8edf5;
  --color-sidebar-border: rgba(255, 255, 255, 0.06);
  --color-sidebar-logo: #ffffff;
  --color-sidebar-section-label: #4b5b75;

  --color-content-bg: #f1f5f9;
  --color-surface: #ffffff;
  --color-surface-elevated: #ffffff;
  --color-border: #e2e8f0;
  --color-border-hover: #cbd5e1;
  --color-border-subtle: #f1f5f9;

  --color-accent: #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-accent-subtle: #eff6ff;
  --color-accent-text: #1d4ed8;
  --color-accent-glow: rgba(37, 99, 235, 0.15);

  --color-text-primary: #0f172a;
  --color-text-secondary: #475569;
  --color-text-muted: #94a3b8;
  --color-text-inverse: #ffffff;

  --color-success: #16a34a;
  --color-success-bg: #f0fdf4;
  --color-success-border: #bbf7d0;
  --color-warning: #d97706;
  --color-warning-bg: #fffbeb;
  --color-warning-border: #fde68a;
  --color-danger: #dc2626;
  --color-danger-bg: #fef2f2;
  --color-danger-border: #fecaca;
  --color-danger-hover: #b91c1c;
  --color-purple: #7c3aed;
  --color-purple-bg: #f5f3ff;
  --color-purple-border: #ddd6fe;

  /* Sidebar */
  --sidebar-width: 252px;
  --sidebar-collapsed-width: 68px;

  /* Spacing — 4px base */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --text-xs: 11px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 15px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 30px;

  /* Border radius — consistent */
  --radius-sm: 4px;
  --radius: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.10), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-card-hover: 0 12px 28px rgba(37, 99, 235, 0.10), 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.06);
  --shadow-premium: 0 24px 60px rgba(15, 23, 42, 0.08), 0 10px 24px rgba(15, 23, 42, 0.05);
  --page-shell-max: 1380px;
  --page-shell-narrow: 1240px;
  --surface-soft: rgba(255, 255, 255, 0.76);
  --surface-panel: rgba(255, 255, 255, 0.92);
  --surface-border-strong: rgba(148, 163, 184, 0.18);

  /* Transitions */
  --transition-fast: 120ms ease;
  --transition: 200ms ease;
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--color-text-primary);
  background:
    radial-gradient(circle at top left, rgba(191, 219, 254, 0.45), transparent 28%),
    radial-gradient(circle at bottom right, rgba(226, 232, 240, 0.55), transparent 36%),
    linear-gradient(180deg, #f8fbff 0%, #eef4fb 100%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── App Shell (Dashboard Layout) ─────────────────────────── */
#app {
  height: 100dvh;
  display: flex;
  overflow: hidden;
}

#app.editor-mode > .sidebar {
  display: none;
}

#app.editor-mode > .main-content {
  width: 100%;
}

#app.editor-mode .mobile-overlay {
  display: none !important;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: linear-gradient(180deg, #0e1629 0%, #0a0f1e 100%);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  transition: width var(--transition-slow), min-width var(--transition-slow), transform var(--transition-slow);
  z-index: 100;
  border-right: 1px solid var(--color-sidebar-border);
  position: relative;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
  min-width: var(--sidebar-collapsed-width);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5);
  border-bottom: 1px solid var(--color-sidebar-border);
  text-decoration: none;
  color: var(--color-sidebar-logo);
  min-height: 64px;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 6px rgba(37, 99, 235, 0.35));
}

.sidebar-logo-text {
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
  transition: opacity var(--transition), transform var(--transition);
}

.sidebar.collapsed .sidebar-logo-text {
  opacity: 0;
  width: 0;
  overflow: hidden;
  transform: translateX(-8px);
}

.sidebar-section {
  padding: var(--space-3) var(--space-3);
  flex: 1;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-sidebar-section-label);
  padding: var(--space-4) var(--space-3) var(--space-2);
  transition: opacity var(--transition);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.collapsed .sidebar-section-label {
  opacity: 0;
  height: 0;
  padding: 0;
  overflow: hidden;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--radius-md);
  color: var(--color-sidebar-text);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  position: relative;
  margin-bottom: 2px;
  border-left: 3px solid transparent;
}

.sidebar-nav-item:hover {
  background: var(--color-sidebar-hover);
  color: var(--color-sidebar-text-hover);
}

.sidebar-nav-item.active {
  background: var(--color-sidebar-active);
  color: var(--color-sidebar-text-active);
  border-left-color: var(--color-sidebar-active-border);
  font-weight: 600;
}

.sidebar-nav-item .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity var(--transition-fast);
}

.sidebar-nav-item:hover .nav-icon,
.sidebar-nav-item.active .nav-icon {
  opacity: 1;
}

.sidebar-nav-item .nav-label {
  transition: opacity var(--transition), transform var(--transition);
}

.sidebar.collapsed .nav-label {
  opacity: 0;
  width: 0;
  overflow: hidden;
  transform: translateX(-8px);
}

.sidebar-nav-item .nav-badge {
  margin-left: auto;
  background: var(--color-accent);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  transition: opacity var(--transition);
}

.sidebar.collapsed .nav-badge { opacity: 0; }

/* Sidebar collapse button */
.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3);
  border-top: 1px solid var(--color-sidebar-border);
  cursor: pointer;
  color: var(--color-sidebar-text);
  background: none;
  border-left: none;
  border-right: none;
  border-bottom: none;
  width: 100%;
  transition: all var(--transition-fast);
}

.sidebar-collapse-btn:hover {
  background: var(--color-sidebar-hover);
  color: #cbd5e1;
}

/* Sidebar user footer */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-sidebar-border);
  cursor: pointer;
  transition: background var(--transition-fast);
  overflow: hidden;
  white-space: nowrap;
  margin: var(--space-2);
  margin-top: 0;
  border-radius: var(--radius-md);
}

.sidebar-user:hover {
  background: var(--color-sidebar-hover);
}

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
  position: relative;
}

/* Plan badge dot on avatar */
.sidebar-user-avatar::after {
  content: '';
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 12px;
  height: 12px;
  border-radius: var(--radius-full);
  background: var(--color-success);
  border: 2px solid #0e1629;
}

.sidebar-user-info {
  overflow: hidden;
  transition: opacity var(--transition), transform var(--transition);
}

.sidebar.collapsed .sidebar-user-info {
  opacity: 0;
  width: 0;
  transform: translateX(-8px);
}

.sidebar-user-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: #e2e8f0;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.sidebar-user-plan {
  font-size: var(--text-xs);
  color: var(--color-sidebar-text);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sidebar-user-plan::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  flex-shrink: 0;
}

/* ── Main Content ───────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.55), rgba(241,245,249,0.68)),
    linear-gradient(180deg, #f8fbff 0%, #edf3fa 100%);
}

/* ── Top Bar ────────────────────────────────────────────────── */
.topbar {
  height: 64px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-6);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}

.topbar-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  padding: var(--space-2);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.topbar-hamburger:hover { background: var(--color-content-bg); }

.topbar-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text-primary);
  letter-spacing: -0.02em;
}

/* Breadcrumbs */
.topbar-breadcrumbs {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.topbar-breadcrumbs a {
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.topbar-breadcrumbs a:hover { color: var(--color-accent); }

.topbar-breadcrumbs .breadcrumb-sep {
  font-size: var(--text-xs);
  color: var(--color-border-hover);
}

.topbar-breadcrumbs .breadcrumb-current {
  color: var(--color-text-primary);
  font-weight: 600;
}

.topbar-search {
  flex: 1;
  max-width: 360px;
  position: relative;
}

.topbar-search input {
  width: 100%;
  padding: 9px var(--space-3) 9px 38px;
  background: var(--color-content-bg);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  color: var(--color-text-primary);
  transition: all var(--transition-fast);
  outline: none;
}

.topbar-search input:hover {
  border-color: var(--color-border);
}

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

.topbar-search input::placeholder { color: var(--color-text-muted); }

.topbar-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  width: 16px;
  height: 16px;
  pointer-events: none;
}

/* Keyboard shortcut hint */
.topbar-search::after {
  content: '\2318K';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  font-weight: 600;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  pointer-events: none;
  opacity: 0.7;
  font-family: var(--font-sans);
}

.topbar-search input:focus ~ .topbar-search::after,
.topbar-search:focus-within::after {
  opacity: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

/* Notification bell */
.topbar-notification {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-2);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}

.topbar-notification:hover {
  background: var(--color-content-bg);
  color: var(--color-text-primary);
}

.topbar-notification-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--color-danger);
  border: 2px solid var(--color-surface);
}

/* User avatar in topbar */
.topbar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
  flex-shrink: 0;
}

.topbar-user-avatar:hover {
  box-shadow: 0 0 0 3px var(--color-accent-glow);
  transform: scale(1.05);
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--color-accent);
  color: #ffffff;
  border-color: var(--color-accent);
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text-primary);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-content-bg);
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-sm);
}

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

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

.btn-danger {
  background: var(--color-danger);
  color: #ffffff;
  border-color: var(--color-danger);
}

.btn-danger:hover {
  background: var(--color-danger-hover);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
}

.btn-sm {
  padding: 5px var(--space-3);
  font-size: var(--text-xs);
  border-radius: var(--radius);
}

.btn-lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-md);
}

.btn-icon {
  padding: var(--space-2);
  width: 36px;
  height: 36px;
}

.btn-icon.btn-sm {
  width: 30px;
  height: 30px;
  padding: var(--space-1);
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-sm svg { width: 14px; height: 14px; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Page Content Wrapper ────────────────────────────────────  */
.page-content {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-8);
}

/* ── Page Header ────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-8);
  gap: var(--space-4);
}

.page-header-left h1 {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
}

.page-header-left p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* ── Card ───────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border);
}

.card-header h2 {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--color-text-primary);
}

.card-body { padding: var(--space-6); }

/* ── Status Badges ──────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge-published {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid var(--color-success-border);
}

.badge-draft {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border: 1px solid var(--color-warning-border);
}

.badge-private {
  background: var(--color-purple-bg);
  color: var(--color-purple);
  border: 1px solid var(--color-purple-border);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
}

/* ── Filter tabs ───────────────────────────────────────────── */
.active-filter {
  background: var(--color-accent-subtle) !important;
  color: var(--color-accent) !important;
  border-color: rgba(37, 99, 235, 0.15) !important;
}

/* ── Flipbook Grid ──────────────────────────────────────────── */
.flipbook-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-6);
}

/* ── Flipbook Card ──────────────────────────────────────────── */
.flipbook-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  content-visibility: auto;
  contain-intrinsic-size: 0 320px;
  position: relative;
}

.flipbook-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-4px);
  border-color: rgba(37, 99, 235, 0.2);
}

.flipbook-card-thumbnail {
  aspect-ratio: 4/3;
  background: linear-gradient(135deg, #e8f0fe 0%, #c7d7fd 100%);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.flipbook-card-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.flipbook-card-thumbnail-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  color: rgba(100, 130, 180, 0.6);
}

.flipbook-card-thumbnail-placeholder svg {
  width: 44px;
  height: 44px;
  opacity: 0.4;
}

.flipbook-card-hover-actions {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  opacity: 0;
  transition: opacity var(--transition);
  backdrop-filter: blur(4px);
}

.flipbook-card:hover .flipbook-card-hover-actions { opacity: 1; }

.flipbook-card-hover-actions .btn {
  font-size: var(--text-xs);
  padding: 7px var(--space-3);
  gap: 5px;
  border-radius: var(--radius);
  backdrop-filter: blur(4px);
  transition: all var(--transition-fast);
}

.flipbook-card-hover-actions .btn:hover {
  transform: scale(1.05);
}

.flipbook-card-hover-actions .btn svg {
  width: 13px;
  height: 13px;
}

.flipbook-card-body {
  padding: var(--space-4) var(--space-4) var(--space-3);
}

.flipbook-card-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: var(--space-2);
  line-height: 1.4;
}

.flipbook-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.flipbook-card-stats {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.flipbook-card-stats span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.flipbook-card-stats svg {
  width: 12px;
  height: 12px;
}

.flipbook-card-date {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

/* ── Empty State ────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-12) var(--space-8);
  gap: var(--space-5);
}

.empty-state-icon {
  width: 100px;
  height: 100px;
  background: linear-gradient(135deg, var(--color-accent-subtle), #dbeafe);
  border-radius: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent);
  position: relative;
  animation: empty-float 3s ease-in-out infinite;
}

@keyframes empty-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.empty-state-icon svg { width: 44px; height: 44px; }

/* Decorative dots around empty state icon */
.empty-state-icon::before {
  content: '';
  position: absolute;
  inset: -12px;
  border: 2px dashed rgba(37, 99, 235, 0.15);
  border-radius: 34px;
}

.empty-state h3 {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text-primary);
  letter-spacing: -0.02em;
}

.empty-state p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: 340px;
  line-height: 1.6;
}

/* ── Auth Pages ─────────────────────────────────────────────── */
.auth-layout {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0c1222 0%, #111a2e 50%, #0a0f1e 100%);
  padding: var(--space-6);
  position: relative;
  overflow: hidden;
}

.auth-bg-pattern {
  position: absolute;
  inset: 0;
  opacity: 0.03;
  background-image:
    radial-gradient(circle at 25% 25%, rgba(59, 130, 246, 0.3) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(99, 102, 241, 0.2) 0%, transparent 50%),
    linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px;
}

.auth-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25);
  padding: var(--space-10);
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 1;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
  justify-content: center;
}

.auth-logo-text {
  font-size: var(--text-xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--color-text-primary);
}

.auth-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
}

.auth-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-8);
  line-height: 1.5;
}

.auth-footer {
  margin-top: var(--space-6);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

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

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

.auth-error {
  background: var(--color-danger-bg);
  border: 1px solid var(--color-danger-border);
  color: var(--color-danger);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
  display: none;
}

.auth-error.show { display: block; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
}

.form-label.required::after {
  content: ' *';
  color: var(--color-danger);
}

.form-input {
  width: 100%;
  padding: 10px var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: var(--text-base);
  font-family: var(--font-sans);
  color: var(--color-text-primary);
  transition: all var(--transition-fast);
  outline: none;
  line-height: 1.5;
}

.form-input:hover { border-color: var(--color-border-hover); }

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

.form-input::placeholder { color: var(--color-text-muted); }

.form-input:disabled {
  background: var(--color-content-bg);
  cursor: not-allowed;
  opacity: 0.7;
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* Range input */
.form-range {
  width: 100%;
  accent-color: var(--color-accent);
  cursor: pointer;
  height: 4px;
}

/* Toggle */
.toggle-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) 0;
}

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

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

.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.toggle input { display: none; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--color-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition);
}

.toggle-slider::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: #fff;
  top: 3px;
  left: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition: transform var(--transition);
}

.toggle input:checked ~ .toggle-slider { background: var(--color-accent); }
.toggle input:checked ~ .toggle-slider::after { transform: translateX(18px); }

/* Color input */
.color-input-group {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.color-swatch {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  border: 2px solid var(--color-border);
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
  transition: border-color var(--transition-fast);
}

.color-swatch:hover { border-color: var(--color-border-hover); }

.color-swatch input[type="color"] {
  width: 200%;
  height: 200%;
  margin: -50%;
  border: none;
  cursor: pointer;
  padding: 0;
}

/* ── Create (Upload) Page ────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-12) var(--space-8);
  text-align: center;
  background: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  max-width: 600px;
  margin: 0 auto;
  position: relative;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--color-accent);
  background: var(--color-accent-subtle);
  box-shadow: 0 0 0 4px var(--color-accent-glow);
}

.upload-zone.drag-over {
  transform: scale(1.01);
}

.upload-zone-icon {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, var(--color-accent-subtle), #dbeafe);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent);
  transition: transform var(--transition-spring);
}

.upload-zone:hover .upload-zone-icon { transform: scale(1.08) translateY(-2px); }
.upload-zone-icon svg { width: 36px; height: 36px; }

.upload-zone h3 {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text-primary);
}

.upload-zone p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.6;
}

.upload-progress {
  max-width: 600px;
  margin: var(--space-8) auto 0;
  display: none;
}

.upload-progress.show { display: block; }

.progress-bar-wrap {
  background: var(--color-content-bg);
  border-radius: var(--radius-full);
  height: 8px;
  overflow: hidden;
  margin-bottom: var(--space-3);
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-accent), #6366f1);
  border-radius: var(--radius-full);
  transition: width 200ms ease;
  position: relative;
}

.progress-bar-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: progress-shimmer 1.5s infinite;
}

@keyframes progress-shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.progress-status {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  text-align: center;
}

/* ── Editor Layout ───────────────────────────────────────────── */
.editor-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
  background: #f6f9fe;
}

.editor-preview {
  flex: 1;
  background: #f6f9fe;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  min-width: 0;
  padding: 10px 12px;
}

.editor-preview-inner {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

#preview-container {
  width: 100%;
  height: 100%;
  background: transparent;
  border-radius: 18px;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  text-align: center;
  flex-direction: column;
  gap: var(--space-3);
}

.editor-preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
}

.editor-preview-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  border-radius: 18px;
}

.editor-settings {
  width: 318px;
  min-width: 318px;
  background: linear-gradient(180deg, #283449 0%, #243043 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  color: #eef4ff;
  overflow: hidden;
  overscroll-behavior: contain;
  box-shadow: none;
}

/* Editor topbar */
.editor-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 52px;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(149, 163, 184, 0.14);
  flex-shrink: 0;
}

.editor-title-display {
  flex: 1;
  min-width: 0;
}

.editor-title-display strong {
  display: block;
  font-size: 15px;
  line-height: 1.2;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.editor-title-kicker {
  display: block;
  margin-bottom: 2px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}

.editor-settings-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.editor-settings-header {
  padding: 10px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: transparent;
}

.editor-settings-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  padding: 0;
  background: transparent;
  border: 0;
  color: rgba(207, 218, 239, 0.72);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.editor-settings-link i {
  width: 14px;
  height: 14px;
}

.editor-settings-header h2 {
  font-size: 22px;
  line-height: 1;
  color: #ffffff;
  letter-spacing: -0.03em;
  margin-bottom: 14px;
}

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

.editor-settings-actions .btn {
  flex: 1;
  justify-content: center;
  min-height: 36px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.editor-settings-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-menu-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.editor-nav {
  padding: 8px 8px 16px;
  overflow: visible;
  border-bottom: none;
}

.editor-nav-item {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 12px 12px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: #e7eefb;
  text-align: left;
  transition: all var(--transition-fast);
  cursor: pointer;
  text-decoration: none;
}

.editor-nav-item + .editor-nav-item {
  margin-top: 2px;
}

.editor-nav-item:hover,
.editor-nav-item.active {
  background: rgba(0, 0, 0, 0.18);
  border-color: rgba(92, 133, 255, 0.2);
  box-shadow: none;
  transform: none;
}

.editor-nav-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  flex: 0 0 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(61, 103, 226, 0.18);
  color: #6d98ff;
}

.editor-nav-icon i,
.editor-nav-chevron i {
  width: 16px;
  height: 16px;
}

.editor-nav-icon-accent {
  background: rgba(16, 185, 129, 0.14);
  color: #44d1a0;
}

.editor-nav-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.editor-nav-copy strong {
  font-size: 14px;
  line-height: 1.2;
  color: #ffffff;
}

.editor-nav-copy small {
  font-size: 11px;
  line-height: 1.45;
  color: rgba(198, 212, 236, 0.62);
}

.editor-nav-chevron {
  margin-left: auto;
  color: rgba(179, 197, 225, 0.48);
  padding-top: 2px;
}

.editor-inline-section-host {
  display: none;
  margin: 0 0 4px;
}

.editor-inline-section-host:not([hidden]) {
  display: block;
}

.editor-section-bank {
  display: none;
}

.editor-section-panels {
  padding: 0;
}

.editor-section-panel {
  display: none;
}

.editor-section-panel.active {
  display: block;
}

.editor-section-card {
  margin: 0 12px 6px 44px;
  background: rgba(9, 14, 25, 0.38);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  padding: 14px;
  box-shadow: none;
}

.editor-section-head {
  margin-bottom: 12px;
}

.editor-section-head h3 {
  font-size: 14px;
  color: #ffffff;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.editor-section-head p {
  font-size: 11px;
  line-height: 1.45;
  color: rgba(210, 223, 244, 0.66);
}

.editor-info-card {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.07);
  color: rgba(217, 227, 244, 0.82);
  font-size: 12px;
  line-height: 1.55;
}

.editor-info-card strong {
  color: #ffffff;
  font-size: 12px;
}

.editor-settings .form-label,
.editor-settings .toggle-label,
.editor-settings .visibility-option-label {
  color: #f6f8ff;
}

.editor-settings .form-hint,
.editor-settings .toggle-hint,
.editor-settings .visibility-option-desc {
  color: rgba(191, 206, 230, 0.74);
}

.editor-settings .form-input,
.editor-settings .form-select,
.editor-settings .code-block {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.1);
  color: #f8fbff;
}

.editor-settings .form-input::placeholder {
  color: rgba(188, 201, 223, 0.54);
}

.editor-settings .form-input:focus,
.editor-settings .form-select:focus {
  background: rgba(255,255,255,0.08);
  border-color: rgba(118, 157, 255, 0.48);
}

.editor-settings .toggle-group.compact {
  margin-bottom: 0;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.editor-settings .visibility-options {
  gap: 10px;
}

.editor-settings .visibility-option {
  padding: 12px;
  border-radius: 12px;
}

.editor-settings .toggle-group.compact:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

/* ── Analytics Page ──────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-5);
  margin-bottom: var(--space-8);
}

.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  box-shadow: var(--shadow-card);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-accent), #6366f1);
  opacity: 0;
  transition: opacity var(--transition);
}

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

.kpi-card:hover::before { opacity: 1; }

.kpi-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

.kpi-value {
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums lining-nums;
  line-height: 1;
}

.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--text-xs);
  font-weight: 600;
  margin-top: var(--space-2);
}

.kpi-delta.up { color: var(--color-success); }
.kpi-delta.down { color: var(--color-danger); }
.kpi-delta svg { width: 12px; height: 12px; }

.charts-grid {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: var(--space-5);
  margin-bottom: var(--space-8);
}

.chart-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-card);
}

.chart-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.chart-title::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  flex-shrink: 0;
}

.chart-wrap {
  position: relative;
  height: 220px;
}

/* Chart empty state */
.chart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: var(--space-3);
  color: var(--color-text-muted);
}

.chart-empty svg { width: 48px; height: 48px; opacity: 0.3; }
.chart-empty p { font-size: var(--text-sm); }

/* ── Data Table ──────────────────────────────────────────────── */
.data-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  background: var(--color-surface);
}

.data-table thead tr {
  border-bottom: 1px solid var(--color-border);
}

.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--color-content-bg);
  z-index: 1;
  padding: var(--space-3) var(--space-5);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--color-border-subtle);
  transition: background var(--transition-fast);
}

.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--color-content-bg); }

.data-table tbody td {
  padding: var(--space-3) var(--space-5);
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}

.data-table tbody td:first-child { color: var(--color-text-primary); font-weight: 500; }

/* ── Settings Page ───────────────────────────────────────────── */
.settings-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--space-8);
  align-items: start;
}

.settings-nav {
  position: sticky;
  top: 0;
}

.settings-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  transition: all var(--transition-fast);
  margin-bottom: 2px;
}

.settings-nav-item:hover { background: var(--color-content-bg); color: var(--color-text-primary); }
.settings-nav-item.active { background: var(--color-accent-subtle); color: var(--color-accent-text); font-weight: 600; }
.settings-nav-item svg { width: 16px; height: 16px; }

.settings-section { display: none; }
.settings-section.active { display: block; }

.settings-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-5);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.settings-card-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border);
}

.settings-card-header h3 {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--color-text-primary);
}

.settings-card-header p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.settings-card-body {
  padding: var(--space-6);
}

/* Plan cards */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
}

.plan-card {
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: all var(--transition);
}

.plan-card:hover {
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-md);
}

.plan-card.current {
  border-color: var(--color-accent);
  background: var(--color-accent-subtle);
}

.plan-name {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: var(--space-1);
}

.plan-price {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--color-text-primary);
  letter-spacing: -0.03em;
}

.plan-price span {
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--color-text-muted);
}

.plan-features {
  list-style: none;
  margin-top: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.plan-features li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}

.plan-features li svg { width: 14px; height: 14px; color: var(--color-success); flex-shrink: 0; }

/* ── Modal / Overlay ─────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

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

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modal-in 250ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

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

.modal-header h3 { font-size: var(--text-lg); font-weight: 700; }
.modal-body { padding: var(--space-6); }
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6);
  border-top: 1px solid var(--color-border);
  background: var(--color-content-bg);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ── Toast ───────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  background: var(--color-text-primary);
  color: #fff;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  animation: toast-in 250ms cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 360px;
}

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

@keyframes toast-in {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(16px) scale(0.95); }
}

/* ── User Menu Dropdown ──────────────────────────────────────── */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  min-width: 200px;
  z-index: 200;
  display: none;
  overflow: hidden;
  animation: dropdown-in 150ms cubic-bezier(0.34, 1.56, 0.64, 1);
  padding: var(--space-1) 0;
}

.dropdown-menu.show { display: block; }

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 9px var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  transition: all var(--transition-fast);
  border-radius: 0;
}

.dropdown-item:hover { background: var(--color-content-bg); color: var(--color-text-primary); }
.dropdown-item svg { width: 15px; height: 15px; }
.dropdown-item.danger { color: var(--color-danger); }
.dropdown-item.danger:hover { background: var(--color-danger-bg); }
.dropdown-separator { height: 1px; background: var(--color-border); margin: var(--space-1) 0; }

/* ── Embed code ─────────────────────────────────────────────── */
.code-block {
  background: #0c1222;
  color: #a5f3fc;
  border-radius: var(--radius-md);
  padding: var(--space-4);
  font-size: var(--text-xs);
  font-family: 'Fira Code', 'Consolas', monospace;
  overflow-x: auto;
  line-height: 1.7;
  white-space: pre;
  position: relative;
}

.copy-btn {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
}

/* ── Visibility section ─────────────────────────────────────── */
.visibility-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.visibility-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.visibility-option:hover { border-color: var(--color-border-hover); }

.visibility-option:has(input:checked) {
  border-color: var(--color-accent);
  background: var(--color-accent-subtle);
}

.visibility-option input { display: none; }

.visibility-option-icon {
  width: 36px;
  height: 36px;
  background: var(--color-content-bg);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.visibility-option:has(input:checked) .visibility-option-icon {
  background: rgba(37, 99, 235, 0.1);
  color: var(--color-accent);
}

.visibility-option-label { font-size: var(--text-sm); font-weight: 600; }
.visibility-option-desc { font-size: var(--text-xs); color: var(--color-text-muted); }

/* ── Loading states / Skeleton ──────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeleton-wave 1.5s ease-in-out infinite;
  border-radius: var(--radius);
}

@keyframes skeleton-wave {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Skeleton card variant */
.skeleton-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.skeleton-card .skeleton-thumb {
  aspect-ratio: 4/3;
  background: linear-gradient(90deg, #f1f5f9 25%, #e8edf3 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeleton-wave 1.5s ease-in-out infinite;
}

.skeleton-card .skeleton-body {
  padding: var(--space-4);
}

.skeleton-line {
  height: 12px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeleton-wave 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
}

.skeleton-line.w-75 { width: 75%; }
.skeleton-line.w-50 { width: 50%; }
.skeleton-line.w-25 { width: 25%; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .sidebar {
    width: var(--sidebar-collapsed-width);
    min-width: var(--sidebar-collapsed-width);
  }
  .sidebar .nav-label,
  .sidebar .sidebar-logo-text,
  .sidebar .sidebar-section-label,
  .sidebar .sidebar-user-info,
  .sidebar .nav-badge {
    opacity: 0;
    width: 0;
    overflow: hidden;
  }
  .charts-grid { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { position: static; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    z-index: 200;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.3);
  }

  #app.editor-mode .sidebar {
    display: none;
    transform: translateX(-100%);
  }

  .sidebar.mobile-open .nav-label,
  .sidebar.mobile-open .sidebar-logo-text,
  .sidebar.mobile-open .sidebar-section-label,
  .sidebar.mobile-open .sidebar-user-info,
  .sidebar.mobile-open .nav-badge {
    opacity: 1;
    width: auto;
    overflow: visible;
  }

  .topbar-hamburger { display: flex; }
  .page-content { padding: var(--space-5); }
  .flipbook-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--space-4); }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .editor-layout { flex-direction: column; }
  .editor-settings {
    width: 100%;
    min-width: 0;
    max-height: 46vh;
    box-shadow: none;
  }
  .editor-settings-body { flex-direction: column; }
  .editor-nav {
    width: 100%;
    min-width: 0;
    border-right: none;
  }
  .editor-detail-header { padding: 12px 14px; }
  .editor-section-panels { padding: 14px; }
  .editor-preview { min-height: 54vh; padding: 16px; }

  .mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 150;
    display: none;
    backdrop-filter: blur(2px);
  }

  .mobile-overlay.show { display: block; }

  /* Hide search shortcut hint on mobile */
  .topbar-search::after { display: none; }
  .topbar-breadcrumbs { display: none; }

  /* Topbar adjustments */
  .topbar { padding: 0 var(--space-4); gap: var(--space-3); }
  .topbar-search { max-width: 200px; }
}

@media (max-width: 480px) {
  .flipbook-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr; }
  .topbar-search { display: none; }

  .plan-grid { grid-template-columns: 1fr; }

  .editor-topbar { padding: 0 14px; }
  .editor-settings {
    max-height: none;
    height: auto;
  }
  .editor-settings-body {
    flex-direction: column;
  }
  .editor-nav {
    width: 100%;
    min-width: 0;
    border-right: none;
    border-bottom: none;
    max-height: 220px;
  }
  .editor-settings-header,
  .editor-section-panels { padding-left: 14px; padding-right: 14px; }
  .editor-preview { min-height: 48vh; padding: 12px; }
}

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-border-hover); }

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

/* ── Utility ─────────────────────────────────────────────────── */
.hidden { display: none !important; }
.hidden-block { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.text-muted { color: var(--color-text-muted); }
.text-center { text-align: center; }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.w-full { width: 100%; }
.btn-top-gap { margin-top: var(--space-2); }
.sidebar-section-label-spaced { margin-top: var(--space-2); }
.input-hidden { display: none !important; }
.form-input-mono {
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
}
.form-input-compact { font-size: 12px; }
.inline-field-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.range-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 11px;
  color: var(--color-text-muted);
}
.code-block-compact {
  font-size: 11px;
  padding: 12px;
  border-radius: var(--radius-md);
  position: relative;
}
.helper-copy.compact-copy {
  margin: 0;
  font-size: 12px;
  color: var(--color-text-muted);
}
.card-body-flush { padding: 0; }
.data-table-wrap-flat {
  border: none;
  border-radius: 0;
  box-shadow: none;
}
.card-spaced { margin-bottom: var(--space-8); }
.section-actions {
  margin-top: var(--space-4);
  flex-wrap: wrap;
}
.form-hint-top { margin-top: 12px; }
.modal-copy {
  color: var(--color-text-secondary);
  font-size: 14px;
  line-height: 1.6;
}
.editor-view {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}
.editor-topbar-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}
.editor-save-status {
  font-size: 12px;
  color: var(--color-text-muted);
}
.upload-remove-btn {
  margin-top: var(--space-2);
  display: none;
}
.analytics-range-select {
  width: 168px;
  padding: 8px 32px 8px 12px;
  font-size: 13px;
}
.analytics-breadcrumbs { margin-bottom: 20px; }
.settings-content {
  display: grid;
  gap: var(--space-6);
}
.plan-card-action { margin-top: var(--space-4); }
.preview-placeholder-icon {
  width: 48px;
  height: 48px;
  color: #475569;
  margin-bottom: 12px;
}
.preview-placeholder-title {
  color: #64748b;
  font-size: 14px;
}
.preview-placeholder-subtitle {
  color: #94a3b8;
  font-size: 12px;
  margin-top: 4px;
}
.upload-progress-card { padding: 24px; }

/* ── Focus ring (accessibility) ──────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ── Selection ───────────────────────────────────────────────── */
::selection {
  background: rgba(37, 99, 235, 0.15);
  color: var(--color-text-primary);
}

/* ── Smooth transitions on view changes ─────────────────────── */
#view-dashboard,
#view-create,
#view-editor,
#view-analytics,
#view-settings {
  animation: view-fade-in 300ms ease;
}

#view-dashboard,
#view-create,
#view-analytics,
#view-settings {
  min-height: 0;
  overflow: auto;
}

#view-editor {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

@keyframes view-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════════════════════════
   AGENT 4 POLISH — Dashboard UI/UX Enhancements
   ══════════════════════════════════════════════════════════════ */

/* ── Dashboard Toolbar ────────────────────────────────────────── */
.dashboard-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.dashboard-toolbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.flipbook-count-label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.sort-select {
  width: 140px;
  padding: 6px 32px 6px 10px !important;
  font-size: var(--text-xs) !important;
  border-radius: var(--radius) !important;
}

/* ── View Toggle ──────────────────────────────────────────────── */
.view-toggle {
  display: flex;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.view-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 30px;
  background: var(--color-surface);
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: all var(--transition-fast);
}

.view-toggle-btn:not(:last-child) {
  border-right: 1px solid var(--color-border);
}

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

.view-toggle-btn.active {
  background: var(--color-accent-subtle);
  color: var(--color-accent);
}

/* ── List View ────────────────────────────────────────────────── */
.flipbook-grid.list-view {
  grid-template-columns: 1fr;
  gap: var(--space-3);
}

.flipbook-grid.list-view .flipbook-card {
  display: grid;
  grid-template-columns: 140px 1fr;
  contain-intrinsic-size: 0 80px;
}

.flipbook-grid.list-view .flipbook-card-thumbnail {
  aspect-ratio: auto;
  height: 80px;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.flipbook-grid.list-view .flipbook-card-body {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
}

.flipbook-grid.list-view .flipbook-card-title {
  margin-bottom: 0;
  min-width: 160px;
  flex-shrink: 0;
}

.flipbook-grid.list-view .flipbook-card-meta {
  flex: 1;
}

.flipbook-grid.list-view .flipbook-card-date {
  margin-top: 0;
  margin-left: auto;
  white-space: nowrap;
}

.flipbook-grid.list-view .flipbook-card:hover {
  transform: translateY(-2px);
}

.flipbook-grid.list-view .flipbook-card-hover-actions {
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

/* ── Enhanced Empty State ─────────────────────────────────────── */
.empty-state-illustration {
  margin-bottom: var(--space-4);
  animation: empty-float 3s ease-in-out infinite;
}

.empty-state-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-2);
}

/* ── Upload Zone Polish ───────────────────────────────────────── */
.upload-zone-title {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text-primary);
}

.upload-zone-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.upload-zone-constraints {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  justify-content: center;
}

.upload-constraint {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  background: var(--color-content-bg);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
}

.upload-zone.drag-over .upload-zone-icon {
  animation: drag-pulse 0.6s ease-in-out infinite alternate;
}

@keyframes drag-pulse {
  from { transform: scale(1); }
  to { transform: scale(1.12) translateY(-4px); }
}

.upload-zone.invalid-file {
  border-color: var(--color-danger) !important;
  background: var(--color-danger-bg) !important;
}

.upload-zone.invalid-file .upload-zone-icon {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

/* File Preview (before upload) */
.upload-file-preview {
  max-width: 600px;
  margin: 0 auto;
}

.upload-file-preview .card {
  padding: var(--space-6);
}

.upload-file-info {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.upload-file-icon {
  width: 48px;
  height: 48px;
  background: var(--color-accent-subtle);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent);
  flex-shrink: 0;
}

.upload-file-details {
  flex: 1;
  min-width: 0;
}

.upload-file-name {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-file-meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

.upload-file-actions {
  display: flex;
  gap: var(--space-3);
}

/* Upload Progress Enhancements */
.upload-progress-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.upload-progress-icon {
  width: 40px;
  height: 40px;
  background: var(--color-accent-subtle);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent);
  flex-shrink: 0;
}

.upload-progress-name {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text-primary);
}

.upload-progress-size {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.upload-progress-pct {
  margin-left: auto;
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-accent);
  font-variant-numeric: tabular-nums;
}

/* Upload Success State */
.upload-success {
  max-width: 600px;
  margin: var(--space-8) auto 0;
}

.upload-success-card {
  padding: var(--space-10);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

.upload-success-icon {
  width: 80px;
  height: 80px;
  background: var(--color-success-bg);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-success);
  animation: success-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes success-pop {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.upload-success-card h3 {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text-primary);
}

.upload-success-card p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.upload-success-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

/* ── Color Presets ─────────────────────────────────────────────── */
.color-presets {
  display: flex;
  gap: 6px;
  margin-top: var(--space-3);
  flex-wrap: wrap;
}

.color-preset {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  border: 2px solid var(--color-border);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.color-preset:hover {
  transform: scale(1.15);
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px var(--color-accent-glow);
}

.color-preset.active::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: var(--radius-full);
  border: 2px solid var(--color-accent);
}

/* ── KPI Card Enhancements ─────────────────────────────────────── */
.kpi-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.kpi-icon-wrap {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-icon-blue {
  background: var(--color-accent-subtle);
  color: var(--color-accent);
}

.kpi-icon-green {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.kpi-icon-purple {
  background: var(--color-purple-bg);
  color: var(--color-purple);
}

.kpi-icon-orange {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.kpi-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-2);
}

.kpi-sparkline {
  flex-shrink: 0;
}

/* ── Avatar Upload ─────────────────────────────────────────────── */
.avatar-upload-group {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.avatar-upload-preview {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
  overflow: hidden;
  position: relative;
}

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

.avatar-upload-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.avatar-upload-actions .form-hint {
  margin-top: var(--space-1);
}

.avatar-upload-actions .btn {
  width: fit-content;
}

/* ── API Key Section ───────────────────────────────────────────── */
.api-key-item {
  padding: var(--space-4);
  background: var(--color-content-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.api-key-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
}

.api-key-value {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.api-key-value code {
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  background: var(--color-surface);
  padding: 4px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.api-key-meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ── Engagement Bar ────────────────────────────────────────────── */
.engagement-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 120px;
}

.engagement-bar-track {
  flex: 1;
  height: 6px;
  background: var(--color-content-bg);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.engagement-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.engagement-bar-value {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 32px;
  text-align: right;
}

/* ── Toast Improvements ────────────────────────────────────────── */
.toast {
  min-width: 220px;
}

.toast .toast-close {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 2px;
  margin-left: auto;
  opacity: 0.7;
  transition: opacity var(--transition-fast);
  display: flex;
  align-items: center;
}

.toast .toast-close:hover {
  opacity: 1;
}

/* ── Keyboard Shortcut Badge ──────────────────────────────────── */
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-sans);
  background: var(--color-content-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  line-height: 1;
  min-width: 20px;
  text-align: center;
}

/* ── Additional responsive for new features ───────────────────── */
@media (max-width: 1024px) {
  .dashboard-toolbar {
    flex-wrap: wrap;
  }
  .dashboard-toolbar-right {
    flex-wrap: wrap;
  }
}

@media (max-width: 768px) {
  .dashboard-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .dashboard-toolbar-right {
    justify-content: space-between;
  }
  .flipbook-grid.list-view .flipbook-card {
    grid-template-columns: 100px 1fr;
  }
  .flipbook-grid.list-view .flipbook-card-body {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }
  .upload-success-actions {
    flex-direction: column;
    width: 100%;
  }
  .upload-success-actions .btn {
    width: 100%;
  }
  .avatar-upload-group {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .view-toggle { display: none; }
  .sort-select { width: 100%; }
  .flipbook-grid.list-view .flipbook-card {
    grid-template-columns: 1fr;
  }
  .flipbook-grid.list-view .flipbook-card-thumbnail {
    height: 120px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
}

/* ══════════════════════════════════════════════════════════════
   Premium Admin Alignment Pass
   ══════════════════════════════════════════════════════════════ */

#app {
  background:
    radial-gradient(circle at top left, rgba(255,255,255,0.8), transparent 22%),
    linear-gradient(180deg, #f8fbff 0%, #eef4f9 100%);
}

.sidebar {
  width: 268px;
  min-width: 268px;
  background:
    radial-gradient(circle at top left, rgba(59,130,246,0.18), transparent 24%),
    linear-gradient(180deg, #0f1729 0%, #0a1120 100%);
  box-shadow: 20px 0 48px rgba(2, 8, 23, 0.22);
}

.sidebar-logo {
  min-height: 72px;
  padding: 18px 20px;
}

.sidebar-section {
  padding: 16px 14px;
}

.sidebar-nav-item {
  min-height: 44px;
  border-radius: 14px;
  padding: 12px 14px;
}

.sidebar-user {
  margin: 12px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.03);
}

.topbar,
.editor-topbar {
  min-height: 64px;
  height: 64px;
  padding: 0 22px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
  box-shadow: none;
}

.topbar {
  background: rgba(255, 255, 255, 0.76);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
}

.topbar-title {
  font-size: 20px;
  letter-spacing: -0.03em;
}

.topbar-actions {
  gap: 10px;
}

.topbar-notification,
.btn-icon,
.topbar-user-avatar {
  width: 40px;
  height: 40px;
}

.page-content {
  padding: 26px 28px 36px;
}

.page-content > * {
  width: 100%;
  max-width: var(--page-shell-max);
  margin-left: auto;
  margin-right: auto;
}

.page-header {
  margin-bottom: 28px;
}

.page-header-left h1 {
  font-size: 28px;
  letter-spacing: -0.035em;
}

.page-header-left p {
  margin-top: 6px;
  font-size: 14px;
  max-width: 720px;
}

.card,
.chart-container,
.kpi-card,
.settings-card {
  border-radius: 16px;
  border-color: rgba(148, 163, 184, 0.16);
  box-shadow: var(--shadow-card);
}

.card-header,
.settings-card-header,
.chart-container,
.settings-card-body {
  padding-left: 24px;
  padding-right: 24px;
}

.card-header,
.settings-card-header {
  padding-top: 20px;
  padding-bottom: 18px;
}

.dashboard-toolbar {
  padding: 12px 14px;
  margin-bottom: 22px;
  background: rgba(255,255,255,0.82);
  border: 1px solid rgba(148,163,184,0.14);
  border-radius: 14px;
  box-shadow: none;
}

.flipbook-grid {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.flipbook-card {
  border-radius: 16px;
}

.flipbook-card-body {
  padding: 16px 16px 14px;
}

.upload-zone,
.upload-file-preview,
.upload-progress,
.upload-success {
  max-width: 760px;
}

.upload-zone {
  padding: 44px 28px;
  border-radius: 18px;
  background: rgba(255,255,255,0.72);
  border-color: rgba(148,163,184,0.18);
  box-shadow: var(--shadow-card);
}

.upload-file-preview .card,
.upload-progress .card,
.upload-success .card {
  border-radius: 24px;
}

.editor-layout {
  background: #f6f9fe;
}

.editor-settings {
  width: 318px;
  min-width: 318px;
  background: linear-gradient(180deg, #283449 0%, #243043 100%);
}

.editor-settings-header {
  padding: 10px 16px 14px;
}

.editor-settings-header h2 {
  font-size: 22px;
}

.editor-settings-actions .btn {
  min-height: 36px;
}

.editor-nav {
  padding: 8px 8px 16px;
}

.editor-section-card {
  border-radius: 14px;
  padding: 14px;
  background: rgba(12, 19, 31, 0.38);
}

.editor-preview {
  padding: 10px 12px;
}

#preview-container {
  border-radius: 18px;
  box-shadow: none;
}

.kpi-grid {
  gap: 22px;
}

.kpi-card {
  min-height: 182px;
  padding: 22px 24px;
}

.chart-container {
  padding-top: 22px;
  padding-bottom: 22px;
}

.data-table thead th,
.data-table tbody td {
  padding-left: 24px;
  padding-right: 24px;
}

.settings-layout {
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 28px;
}

.settings-nav {
  top: 8px;
  padding: 14px;
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(148,163,184,0.14);
  border-radius: 16px;
  box-shadow: none;
}

.settings-nav-item {
  min-height: 46px;
  padding: 12px 14px;
  border-radius: 14px;
}

.settings-card-body {
  padding-top: 24px;
  padding-bottom: 24px;
}

.plan-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.plan-card {
  min-height: 100%;
  border-radius: 18px;
  padding: 22px;
}

.api-key-item {
  border-radius: 18px;
  padding: 18px;
}

.modal {
  border-radius: 22px;
  max-width: 520px;
}

.modal-footer {
  border-radius: 0 0 22px 22px;
}

@media (max-width: 1024px) {
  .sidebar {
    width: var(--sidebar-collapsed-width);
    min-width: var(--sidebar-collapsed-width);
  }

  .page-content {
    padding: 28px 24px 36px;
  }

  .settings-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .settings-nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
  }

  .settings-nav-item {
    margin-bottom: 0;
  }

  .editor-settings {
    width: 320px;
    min-width: 320px;
  }
}

@media (max-width: 768px) {
  .topbar,
  .editor-topbar {
    min-height: 64px;
    height: 64px;
    padding: 0 16px;
  }

  .page-content {
    padding: 22px 16px 28px;
  }

  .dashboard-toolbar {
    padding: 14px;
  }

  .charts-grid,
  .kpi-grid {
    gap: 16px;
  }

  .editor-settings {
    width: 100%;
    min-width: 0;
    max-height: 52vh;
  }

  .editor-preview {
    min-height: 48vh;
    padding: 10px;
  }

  .settings-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .inline-field-row {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .page-content {
    padding: 18px 12px 24px;
  }

  .dashboard-toolbar-right,
  .section-actions,
  .upload-file-actions {
    width: 100%;
  }

  .dashboard-toolbar-right {
    flex-direction: column;
    align-items: stretch;
  }

  .settings-nav {
    grid-template-columns: 1fr;
  }

  .editor-settings-header h2 {
    font-size: 20px;
  }
}

/* ── Dashboard Publication Cards ───────────────────────────── */
.flipbook-grid {
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 20px;
}

.flipbook-card {
  background: #ffffff;
  border: 1px solid rgba(191, 201, 214, 0.72);
  border-radius: 18px;
  box-shadow: 0 6px 22px rgba(15, 23, 42, 0.05);
  overflow: hidden;
}

.flipbook-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
  border-color: rgba(148, 163, 184, 0.56);
}

.flipbook-card-grid {
  display: flex;
  flex-direction: column;
}

.flipbook-card-grid .flipbook-card-thumbnail {
  aspect-ratio: auto;
  min-height: 228px;
  padding: 18px 18px 0;
  background: linear-gradient(180deg, #f6f9fc 0%, #eef3f8 100%);
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.flipbook-book-shell {
  position: relative;
  width: min(100%, 242px);
  flex-shrink: 0;
}

.flipbook-book-shell-grid {
  padding-right: 26px;
}

.flipbook-book-shell-list {
  width: 102px;
  padding-right: 14px;
}

.flipbook-book-frame {
  position: relative;
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.96);
  border-radius: 12px 10px 10px 12px;
  padding: 10px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.9) inset,
    0 12px 28px rgba(15, 23, 42, 0.06);
}

.flipbook-book-shell-list .flipbook-book-frame {
  border-radius: 8px 6px 6px 8px;
  padding: 6px;
}

.flipbook-book-frame img {
  display: block;
  width: 100%;
  aspect-ratio: 0.72;
  object-fit: cover;
  border-radius: 6px;
  background: #eef3f8;
}

.flipbook-book-stack {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 22px;
  border-radius: 0 14px 14px 0;
  background: linear-gradient(180deg, #cce0ff 0%, #a6cbff 100%);
  border-left: 1px solid rgba(109, 153, 220, 0.24);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.flipbook-book-shell-list .flipbook-book-stack {
  width: 12px;
  border-radius: 0 8px 8px 0;
}

.flipbook-book-stack span {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(77, 108, 168, 0.84);
  text-transform: lowercase;
}

.flipbook-book-edge {
  position: absolute;
  left: 12px;
  right: 40px;
  bottom: -3px;
  height: 8px;
  border-radius: 0 0 10px 10px;
  background: linear-gradient(180deg, rgba(226, 232, 240, 0.95), rgba(203, 213, 225, 0.5));
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.05);
}

.flipbook-book-shell-list .flipbook-book-edge {
  left: 8px;
  right: 20px;
  height: 6px;
}

.flipbook-card-thumbnail-placeholder {
  min-height: 220px;
  border-radius: 8px;
  background: linear-gradient(180deg, #f8fafc 0%, #eff3f8 100%);
  border: 1px dashed rgba(148, 163, 184, 0.34);
  color: #8fa1b5;
}

.flipbook-book-shell-list .flipbook-card-thumbnail-placeholder {
  min-height: 132px;
}

.flipbook-card-thumbnail-placeholder svg {
  width: 34px;
  height: 34px;
  opacity: 0.5;
}

.flipbook-card-thumbnail-placeholder span {
  font-size: 11px;
  font-weight: 600;
}

.flipbook-card-grid .flipbook-card-body {
  padding: 14px 16px 16px;
}

.flipbook-card-grid .flipbook-card-title {
  font-size: 15px;
  line-height: 1.35;
  margin-bottom: 10px;
}

.flipbook-card-grid .flipbook-card-meta {
  align-items: flex-start;
  gap: 10px;
}

.flipbook-card-stats {
  flex-wrap: wrap;
  gap: 10px 12px;
  font-size: 12px;
  color: #64748b;
}

.flipbook-card-stats svg {
  width: 13px;
  height: 13px;
}

.flipbook-card-date {
  color: #94a3b8;
  font-size: 12px;
  margin-top: 8px;
}

.flipbook-card-inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.flipbook-inline-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  background: #f8fafc;
  color: #31507f;
  border-radius: 999px;
  padding: 7px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.flipbook-inline-action:hover {
  background: #eff6ff;
  border-color: rgba(147, 197, 253, 0.8);
}

.flipbook-inline-action svg {
  width: 13px;
  height: 13px;
}

.flipbook-grid.list-view {
  grid-template-columns: 1fr;
  gap: 14px;
}

.flipbook-grid.list-view .flipbook-card {
  display: grid;
  grid-template-columns: 104px 132px minmax(0, 1fr);
  align-items: stretch;
  contain-intrinsic-size: 0 168px;
}

.flipbook-card-list-row .flipbook-row-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 12px;
  border-right: 1px solid rgba(226, 232, 240, 0.95);
  background: linear-gradient(180deg, #fbfcfe 0%, #f5f8fc 100%);
}

.flipbook-row-status-label {
  font-size: 12px;
  font-weight: 700;
  color: #94a3b8;
}

.flipbook-row-status-state {
  font-size: 14px;
  font-weight: 700;
  color: #64748b;
}

.flipbook-row-status-state.is-active {
  color: #16a34a;
}

.flipbook-row-status-toggle {
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: #dbe4ef;
  padding: 2px;
  display: flex;
  align-items: center;
}

.flipbook-row-status-toggle span {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.15);
  transition: transform var(--transition-fast);
}

.flipbook-row-status-toggle.is-on {
  background: rgba(59, 130, 246, 0.22);
}

.flipbook-row-status-toggle.is-on span {
  transform: translateX(14px);
  background: #2563eb;
}

.flipbook-row-quick-icons {
  display: flex;
  gap: 8px;
}

.flipbook-row-icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  background: #ffffff;
  color: #3b82f6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.flipbook-row-icon-btn:hover {
  background: #eff6ff;
}

.flipbook-row-icon-btn svg {
  width: 15px;
  height: 15px;
}

.flipbook-row-thumbnail {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 14px;
  background: linear-gradient(180deg, #f9fbfd 0%, #f3f6fa 100%);
  border-right: 1px solid rgba(226, 232, 240, 0.95);
}

.flipbook-row-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 20px;
}

.flipbook-row-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.flipbook-row-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.flipbook-row-link-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(100%, 390px);
}

.flipbook-row-link-chip {
  flex: 1;
  min-width: 0;
  padding: 9px 14px;
  border-radius: 999px;
  background: #eef3f8;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flipbook-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 18px 20px;
}

.flipbook-row-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: #334e77;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.flipbook-row-action:hover {
  color: #2563eb;
}

.flipbook-row-action svg {
  width: 16px;
  height: 16px;
}

.flipbook-row-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.flipbook-card-stats-list {
  gap: 14px;
  font-size: 14px;
}

.flipbook-grid.list-view .flipbook-card-title {
  font-size: 16px;
  margin-bottom: 0;
}

.flipbook-grid.list-view .flipbook-card-date {
  margin-top: 0;
}

.flipbook-grid.list-view .flipbook-card-meta,
.flipbook-card-hover-actions {
  display: none !important;
}

.modal-body .form-group.is-highlighted {
  border-radius: 12px;
  padding: 10px 12px;
  margin: -10px -12px 0;
  background: rgba(37, 99, 235, 0.05);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.12);
}

@media (max-width: 1024px) {
  .flipbook-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }

  .flipbook-grid.list-view .flipbook-card {
    grid-template-columns: 90px 112px minmax(0, 1fr);
  }

  .flipbook-row-top {
    flex-direction: column;
    align-items: stretch;
  }

  .flipbook-row-link-wrap {
    max-width: none;
  }
}

@media (max-width: 768px) {
  .flipbook-card-grid .flipbook-card-thumbnail {
    min-height: 206px;
  }

  .flipbook-grid.list-view .flipbook-card {
    grid-template-columns: 1fr;
  }

  .flipbook-card-list-row .flipbook-row-status,
  .flipbook-row-thumbnail {
    border-right: 0;
    border-bottom: 1px solid rgba(226, 232, 240, 0.95);
  }

  .flipbook-card-list-row .flipbook-row-status {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
  }

  .flipbook-row-thumbnail {
    justify-content: flex-start;
    padding: 16px;
  }

  .flipbook-row-main {
    padding: 16px;
  }

  .flipbook-row-actions {
    gap: 12px 14px;
  }
}

@media (max-width: 480px) {
  .flipbook-grid {
    grid-template-columns: 1fr;
  }

  .flipbook-card-grid .flipbook-card-thumbnail {
    padding: 16px 12px 0;
  }

  .flipbook-book-shell-grid {
    width: min(100%, 222px);
  }

  .flipbook-row-link-wrap {
    flex-wrap: wrap;
  }

  .flipbook-row-actions {
    flex-direction: column;
    align-items: flex-start;
  }

  .flipbook-row-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}
