/* ============================================================
   FlipBook Pro — Design System
   Light theme, inspired by Linear & Vercel aesthetic
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700&family=Geist+Mono:wght@400;500&display=swap');

/* ── CSS Custom Properties ─────────────────────────────────── */
:root {
  --font-sans: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'Geist Mono', 'Fira Code', monospace;

  /* Colors */
  --gray-50:  #fafafa;
  --gray-100: #f4f4f5;
  --gray-200: #e4e4e7;
  --gray-300: #d1d1d6;
  --gray-400: #a1a1aa;
  --gray-500: #71717a;
  --gray-600: #52525b;
  --gray-700: #3f3f46;
  --gray-800: #27272a;
  --gray-900: #18181b;
  --gray-950: #09090b;

  --accent:        #6366f1;
  --primary:       #6366f1;
  --primary-light: #eef2ff;
  --accent-light:  #eef2ff;
  --accent-dark:   #4f46e5;
  --accent-muted:  #eef2ff;
  --accent-muted:  #eff6ff;

  --green:         #16a34a;
  --green-light:   #dcfce7;
  --red:           #dc2626;
  --red-light:     #fee2e2;
  --amber:         #d97706;
  --amber-light:   #fef3c7;
  --purple:        #7c3aed;
  --purple-light:  #ede9fe;

  /* Semantic */
  --bg:            #ffffff;
  --bg-subtle:     var(--gray-50);
  --bg-muted:      var(--gray-100);
  --border:        var(--gray-200);
  --border-strong: var(--gray-300);
  --text:          var(--gray-900);
  --text-secondary:var(--gray-500);
  --text-tertiary: var(--gray-400);
  --ring:          rgba(37, 99, 235, 0.4);

  /* Layout */
  --sidebar-w:     240px;
  --header-h:      56px;
  --content-max:   1200px;

  /* Spacing */
  --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;

  /* Radius */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.03);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,.08), 0 8px 10px -6px rgba(0,0,0,.03);

  /* Transitions */
  --t-fast: 100ms ease;
  --t-base: 150ms ease;
  --t-slow: 250ms ease;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 4; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

/* ── Typography ─────────────────────────────────────────────── */
h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
h2 { font-size: 20px; font-weight: 600; letter-spacing: -0.015em; }
h3 { font-size: 16px; font-weight: 600; }
h4 { font-size: 14px; font-weight: 600; }
p  { color: var(--text-secondary); }
code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: var(--r-sm);
}

/* ── Layout Shell ───────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow: visible;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-4);
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
}
.sidebar-logo-mark {
  width: 28px; height: 28px;
  background: var(--gray-900);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-logo-mark svg { width: 16px; height: 16px; color: #fff; }
.sidebar-logo-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.sidebar-nav {
  overflow-y: auto;
  flex: 1;
  flex: 1;
  padding: var(--space-3) var(--space-3);
  overflow-y: auto;
}
.nav-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: var(--space-3) var(--space-2) var(--space-1);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px var(--space-2);
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 450;
  transition: all var(--t-base);
  cursor: pointer;
  white-space: nowrap;
}
.nav-item:hover { background: var(--bg-muted); color: var(--text); }
.nav-item.active {
  background: var(--bg-muted);
  color: var(--text);
  font-weight: 500;
}
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-light);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: var(--r-full);
}

.sidebar-footer {
  padding: var(--space-3);
  border-top: 1px solid var(--border);
  position: relative;
  z-index: 101;
  background: var(--bg);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--t-base);
}
.sidebar-user:hover { background: var(--bg-muted); }
.avatar {
  width: 28px; height: 28px;
  border-radius: var(--r-full);
  background: var(--gray-200);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-700);
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-plan {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: capitalize;
}

/* ── Main Content ────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-header {
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 50;
}
.page-header h1 { font-size: 15px; font-weight: 600; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }

.page-body {
  padding: var(--space-6);
  max-width: var(--content-max);
  width: 100%;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 6px 14px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--t-base);
  white-space: nowrap;
  text-decoration: none;
  outline: none;
}
.btn:focus-visible { box-shadow: 0 0 0 3px var(--ring); }
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-lg { padding: 9px 20px; font-size: 14.5px; }
.btn-icon { padding: 6px; }
.btn-icon.btn-sm { padding: 4px; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:active { background: var(--accent-dark); }

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-muted); border-color: var(--gray-300); }

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

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

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

.btn-success {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

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

/* ── Form Elements ───────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: var(--space-1); }
.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.form-hint {
  font-size: 12px;
  color: var(--text-tertiary);
}

.input, .select, .textarea {
  padding: 7px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  width: 100%;
}
.input::placeholder, .textarea::placeholder { color: var(--text-tertiary); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}
.input.error { border-color: var(--red); }
.textarea { resize: vertical; min-height: 80px; }
.select { cursor: pointer; 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='%2371717a' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }

.form-error { font-size: 12px; color: var(--red); }

/* Toggle / Checkbox ─────────────────── */
.toggle {
  appearance: none;
  width: 36px; height: 20px;
  border-radius: var(--r-full);
  background: var(--gray-300);
  cursor: pointer;
  position: relative;
  transition: background var(--t-base);
  flex-shrink: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  top: 2px; left: 2px;
  transition: transform var(--t-base);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle:checked { background: var(--accent); }
.toggle:checked::after { transform: translateX(16px); }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.card-header h3 { font-size: 14px; font-weight: 600; }
.card-body { padding: var(--space-5); }
.card-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}

/* Stat card ─────────────────────────── */
.stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.stat-label {
  font-size: 12.5px;
  color: var(--text-secondary);
  font-weight: 500;
}
.stat-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1;
}
.stat-change {
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 3px;
}
.stat-change.up { color: var(--green); }
.stat-change.down { color: var(--red); }

/* Flipbook card ─────────────────────── */
.flipbook-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: all var(--t-slow);
  cursor: pointer;
}
.flipbook-card:hover {
  border-color: var(--gray-300);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.flipbook-thumb {
  aspect-ratio: 3/4;
  background: var(--bg-muted);
  overflow: hidden;
  position: relative;
}
.flipbook-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform var(--t-slow);
}
.flipbook-card:hover .flipbook-thumb img { transform: scale(1.02); }
.flipbook-thumb-placeholder {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-muted), var(--gray-100));
}
.flipbook-thumb-placeholder svg { width: 40px; height: 40px; color: var(--gray-300); }
.flipbook-info { padding: var(--space-3) var(--space-4); }
.flipbook-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.flipbook-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.flipbook-meta svg { width: 11px; height: 11px; }
.flipbook-actions {
  display: flex;
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--border);
  gap: var(--space-1);
}

/* ── Badges / Chips ──────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 500;
}
.badge-gray   { background: var(--bg-muted); color: var(--text-secondary); }
.badge-blue   { background: var(--accent-light); color: var(--accent); }
.badge-green  { background: var(--green-light); color: var(--green); }
.badge-red    { background: var(--red-light); color: var(--red); }
.badge-amber  { background: var(--amber-light); color: var(--amber); }
.badge-purple { background: var(--purple-light); color: var(--purple); }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--r-md);
  font-size: 13.5px;
  border-left: 3px solid;
  margin-bottom: var(--space-4);
}
.alert-success { background: var(--green-light); color: #14532d; border-color: var(--green); }
.alert-error   { background: var(--red-light); color: #7f1d1d; border-color: var(--red); }
.alert-warning { background: var(--amber-light); color: #78350f; border-color: var(--amber); }
.alert-info    { background: var(--accent-muted); color: #1e3a8a; border-color: var(--accent); }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--bg-subtle); }
th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: var(--space-3) var(--space-4);
  font-size: 13.5px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--bg-subtle); }

/* ── Upload Zone ─────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--r-xl);
  padding: var(--space-10) var(--space-8);
  text-align: center;
  cursor: pointer;
  transition: all var(--t-base);
  background: var(--bg-subtle);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-muted);
}
.upload-icon {
  width: 48px; height: 48px;
  background: var(--bg-muted);
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-4);
}
.upload-icon svg { width: 24px; height: 24px; color: var(--text-secondary); }
.upload-zone h3 { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: var(--space-1); }
.upload-zone p { font-size: 13px; color: var(--text-secondary); }

/* ── Progress Bar ────────────────────────────────────────────── */
.progress {
  height: 6px;
  background: var(--bg-muted);
  border-radius: var(--r-full);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: var(--r-full);
  transition: width 0.4s ease;
}
.progress-bar.success { background: var(--green); }
.progress-bar.warning { background: var(--amber); }
.progress-bar.danger  { background: var(--red); }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-slow);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg);
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(10px) scale(.98);
  transition: transform var(--t-slow);
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal.modal-lg { max-width: 720px; }
.modal-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-body { padding: var(--space-6); }
.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  background: var(--bg-subtle);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}

/* ── Dropdown ────────────────────────────────────────────────── */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 160px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  overflow: hidden;
  display: none;
}
.dropdown-menu.open { display: block; }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
  transition: background var(--t-fast);
}
.dropdown-item:hover { background: var(--bg-muted); }
.dropdown-item.danger { color: var(--red); }
.dropdown-item svg { width: 14px; height: 14px; color: var(--text-tertiary); }
.dropdown-sep { height: 1px; background: var(--border); margin: var(--space-1) 0; }

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: var(--space-5); }
.tab {
  padding: var(--space-3) var(--space-4);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--t-base);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--gray-900); }

/* ── Empty State ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
}
.empty-icon {
  width: 56px; height: 56px;
  background: var(--bg-muted);
  border-radius: var(--r-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-4);
}
.empty-icon svg { width: 28px; height: 28px; color: var(--gray-300); }
.empty-state h3 { font-size: 15px; font-weight: 600; margin-bottom: var(--space-1); }
.empty-state p { font-size: 13.5px; color: var(--text-secondary); max-width: 300px; margin: 0 auto var(--space-5); }

/* ── Toast ───────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--gray-900);
  color: #fff;
  border-radius: var(--r-lg);
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  min-width: 260px;
  animation: toastIn 0.25s ease forwards;
}
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Auth Pages ──────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  padding: var(--space-4);
}
.auth-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--space-8);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}
.auth-title { font-size: 22px; font-weight: 600; margin-bottom: var(--space-1); }
.auth-subtitle { font-size: 14px; color: var(--text-secondary); margin-bottom: var(--space-6); }
.auth-footer {
  text-align: center;
  margin-top: var(--space-5);
  font-size: 13px;
  color: var(--text-secondary);
}
.auth-footer a { color: var(--accent); font-weight: 500; }
.divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-tertiary);
  font-size: 12px;
  margin: var(--space-5) 0;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Storage bar ─────────────────────────────────────────────── */
.storage-bar {
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--space-3) var(--space-4);
}
.storage-info {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}
.storage-label { font-weight: 500; color: var(--text); }

/* ── Embed code ──────────────────────────────────────────────── */
.embed-code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--gray-950);
  color: #a3e635;
  padding: var(--space-4);
  border-radius: var(--r-md);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Skeleton loader ─────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-muted) 25%, var(--gray-100) 50%, var(--bg-muted) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r-md);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Grid utilities ──────────────────────────────────────────── */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }

/* ── Spacing utilities ───────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.w-full { width: 100%; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-secondary { color: var(--text-secondary); }
.text-center { text-align: center; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform var(--t-slow); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-body { padding: var(--space-4); }
  .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }

  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text);
  }
}

@media (max-width: 480px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .auth-card { padding: var(--space-5); }
}

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

/* ── Print ───────────────────────────────────────────────────── */
@media print {
  .sidebar, .page-header, .btn, .modal-overlay { display: none !important; }
  .main-content { margin-left: 0; }
}

/* ═══════════════════════════════════════════════════════════════
   ADDITIONAL STYLES FOR FLIPBOOKS, EDIT, ANALYTICS, SETTINGS
   ═══════════════════════════════════════════════════════════════ */

/* Filters bar */
.filters-bar { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:20px; flex-wrap:wrap; }
.filters-form { display:flex; align-items:center; gap:10px; flex-wrap:wrap; flex:1; }
.search-input-wrap { position:relative; display:flex; align-items:center; }
.search-input-wrap svg { position:absolute; left:10px; color:var(--text-muted); pointer-events:none; }
.search-input { padding-left:34px!important; min-width:200px; }
.form-select { min-width:130px; cursor:pointer; }
.form-select-sm { padding:4px 8px; font-size:12px; border-radius:6px; border:1px solid var(--border); cursor:pointer; }

/* View toggle */
.view-toggle { display:flex; gap:2px; background:var(--bg-secondary); border-radius:8px; padding:3px; }
.view-btn { background:transparent; border:none; border-radius:6px; padding:5px 7px; cursor:pointer; color:var(--text-muted); display:flex; align-items:center; }
.view-btn.active { background:#fff; color:var(--primary); box-shadow:0 1px 3px rgba(0,0,0,.1); }

/* Flipbooks grid */
.flipbooks-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:16px; }
.flipbooks-list { display:flex; flex-direction:column; gap:10px; }
.flipbooks-list .flipbook-card { display:flex; gap:12px; align-items:center; }
.flipbooks-list .flipbook-thumb { width:64px; height:82px; flex-shrink:0; border-radius:6px; }
.flipbooks-list .flipbook-card-header { flex-direction:row; justify-content:space-between; }

.flipbook-card { background:#fff; border:1px solid var(--border); border-radius:12px; overflow:hidden; transition:box-shadow .2s,transform .15s; }
.flipbook-card:hover { box-shadow:0 4px 16px rgba(0,0,0,.08); transform:translateY(-2px); }
.flipbook-thumb { position:relative; aspect-ratio:3/4; background:var(--bg-secondary); overflow:hidden; }
.flipbook-thumb img { width:100%; height:100%; object-fit:cover; display:block; }
.thumb-placeholder { width:100%; height:100%; display:flex; align-items:center; justify-content:center; color:var(--text-muted); }
.flipbook-thumb-overlay { position:absolute; inset:0; background:rgba(0,0,0,.4); display:flex; align-items:center; justify-content:center; opacity:0; transition:opacity .2s; }
.flipbook-card:hover .flipbook-thumb-overlay { opacity:1; }
.btn-white { background:#fff; color:#111; border:none; }
.btn-white:hover { background:#f3f4f6; }
.thumb-status-badge { position:absolute; top:8px; left:8px; }
.flipbook-card-body { padding:12px; }
.flipbook-card-header { display:flex; align-items:flex-start; justify-content:space-between; gap:6px; }
.flipbook-card-title { font-size:14px; font-weight:500; margin:0; flex:1; }
.flipbook-card-title a { color:var(--text); text-decoration:none; }
.flipbook-card-title a:hover { color:var(--primary); }
.flipbook-card-meta { display:flex; align-items:center; gap:8px; margin-top:6px; }
.flipbook-card-stats { display:flex; flex-direction:column; gap:3px; margin-top:8px; font-size:12px; color:var(--text-muted); }
.flipbook-card-stats span { display:flex; align-items:center; gap:4px; }
.btn-icon { background:none; border:none; cursor:pointer; padding:4px; border-radius:4px; color:var(--text-muted); display:flex; align-items:center; }
.btn-icon:hover { background:var(--bg-secondary); color:var(--text); }

/* Pagination */
.pagination { display:flex; align-items:center; justify-content:center; gap:4px; margin-top:24px; }
.pagination-btn { display:inline-flex; align-items:center; justify-content:center; min-width:36px; height:36px; padding:0 10px; border:1px solid var(--border); border-radius:8px; color:var(--text); text-decoration:none; font-size:14px; background:#fff; transition:all .15s; }
.pagination-btn:hover { border-color:var(--primary); color:var(--primary); }
.pagination-btn.active { background:var(--primary); color:#fff; border-color:var(--primary); }
.pagination-ellipsis { color:var(--text-muted); padding:0 6px; }

/* Edit layout */
.edit-layout { display:grid; grid-template-columns:1fr 280px; gap:24px; align-items:start; }
.edit-main {}
.edit-sidebar {}
.sticky-card { position:sticky; top:80px; }
.preview-thumb { width:100%; aspect-ratio:3/4; object-fit:cover; border-radius:8px 8px 0 0; display:block; }
.preview-thumb-placeholder { aspect-ratio:3/4; display:flex; align-items:center; justify-content:center; background:var(--bg-secondary); color:var(--text-muted); font-size:13px; }
.stat-row { display:flex; justify-content:space-between; padding:8px 0; border-bottom:1px solid var(--border); font-size:13px; }
.stat-row:last-child { border-bottom:none; }

/* Tabs */
.tabs { display:flex; gap:0; border-bottom:1px solid var(--border); margin-bottom:20px; }
.tab { background:none; border:none; padding:10px 18px; font-size:14px; color:var(--text-muted); cursor:pointer; border-bottom:2px solid transparent; margin-bottom:-1px; transition:all .15s; }
.tab.active, .tab:hover { color:var(--primary); }
.tab.active { border-bottom-color:var(--primary); font-weight:500; }
.tab-content { display:none; }
.tab-content.active { display:block; }

/* Copy field */
.copy-field { display:flex; gap:8px; align-items:stretch; }
.copy-field .form-control { flex:1; }
.code-field { font-family:monospace; font-size:12px; resize:none; }

/* Social share */
.social-share { display:flex; gap:8px; flex-wrap:wrap; }

/* Input prefix */
.input-prefix-wrap { display:flex; align-items:center; }
.input-prefix { background:var(--bg-secondary); border:1px solid var(--border); border-right:none; padding:9px 10px; border-radius:8px 0 0 8px; font-size:12px; color:var(--text-muted); white-space:nowrap; }
.input-prefix-wrap .form-control { border-radius:0 8px 8px 0; }

/* Toggle group */
.toggle-group { display:flex; flex-direction:column; gap:10px; }
.toggle-item { display:flex; align-items:center; gap:10px; cursor:pointer; }
.toggle-item input[type=checkbox] { display:none; }
.toggle-switch { width:38px; height:22px; background:#d1d5db; border-radius:11px; position:relative; transition:background .2s; flex-shrink:0; }
.toggle-switch::after { content:''; position:absolute; top:3px; left:3px; width:16px; height:16px; background:#fff; border-radius:50%; transition:transform .2s; box-shadow:0 1px 3px rgba(0,0,0,.2); }
.toggle-item input:checked + .toggle-switch { background:var(--primary); }
.toggle-item input:checked + .toggle-switch::after { transform:translateX(16px); }

/* Danger card */
.card-danger { border-color:#fecaca; }
.card-danger .card-header { background:#fef2f2; }
.danger-item { display:flex; align-items:center; justify-content:space-between; gap:16px; }

/* Breadcrumb */
.breadcrumb-link { color:var(--text-muted); text-decoration:none; font-size:13px; display:inline-block; margin-bottom:4px; }
.breadcrumb-link:hover { color:var(--primary); }

/* Analytics grid */
.analytics-grid { display:grid; grid-template-columns:1fr 1fr; gap:20px; }
.referrer-item { display:flex; flex-direction:column; gap:4px; }
.referrer-bar-wrap { height:4px; background:var(--bg-secondary); border-radius:2px; }
.referrer-bar { height:4px; background:var(--primary); border-radius:2px; }
.empty-state-sm { padding:32px; text-align:center; color:var(--text-muted); font-size:14px; }

/* Settings layout */
.settings-layout { max-width:700px; }
.avatar-section { display:flex; align-items:center; gap:16px; }
.avatar-large { width:56px; height:56px; border-radius:50%; background:var(--primary); color:#fff; font-size:20px; font-weight:600; display:flex; align-items:center; justify-content:center; flex-shrink:0; }

/* Plan features */
.plan-feature-list { display:flex; flex-wrap:wrap; gap:8px; }
.plan-feature { padding:5px 10px; border-radius:6px; font-size:12px; background:var(--bg-secondary); color:var(--text-muted); }
.plan-feature.active { background:#f0fdf4; color:#16a34a; }

/* Plan cards mini */
.plan-cards-mini { display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:12px; }
.plan-card-mini { border:1px solid var(--border); border-radius:10px; padding:14px; text-align:center; position:relative; }
.plan-card-mini.featured { border-color:var(--primary); box-shadow:0 0 0 2px rgba(99,102,241,.1); }
.plan-badge { position:absolute; top:-8px; left:50%; transform:translateX(-50%); background:var(--primary); color:#fff; font-size:10px; padding:2px 8px; border-radius:20px; white-space:nowrap; }
.plan-name { font-weight:600; margin-bottom:4px; }
.plan-price { font-size:18px; font-weight:700; color:var(--primary); }
.plan-limits { margin-top:4px; }

/* Usage */
.usage-grid { display:flex; flex-direction:column; gap:16px; }
.usage-item {}
.usage-label { display:flex; justify-content:space-between; font-size:13px; margin-bottom:6px; }
.progress-bar-wrap { height:6px; background:var(--bg-secondary); border-radius:3px; overflow:hidden; }
.progress-bar { height:100%; background:var(--primary); border-radius:3px; transition:width .3s; }
.progress-danger { background:#ef4444; }
.progress-warning { background:#f59e0b; }

/* Admin grid */
.admin-grid { display:grid; grid-template-columns:1fr 1fr; gap:20px; }
.user-cell { display:flex; align-items:center; gap:10px; }
.avatar-sm { width:32px; height:32px; border-radius:50%; background:var(--primary); color:#fff; font-size:12px; font-weight:600; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.stat-badge { font-size:11px; background:var(--bg-secondary); color:var(--text-muted); padding:2px 7px; border-radius:10px; margin-left:6px; font-weight:400; }
.inline-form { display:inline; }
.btn-xs { padding:4px 8px; font-size:11px; border-radius:5px; }

/* Text utilities */
.text-danger  { color:#ef4444; }
.text-success { color:#22c55e; }
.text-warning { color:#f59e0b; }
.text-right   { text-align:right; }
.font-medium  { font-weight:500; }
.mt-1 { margin-top:4px; }
.mt-2 { margin-top:8px; }
.mt-3 { margin-top:12px; }
.mt-4 { margin-top:20px; }
.mb-1 { margin-bottom:4px; }
.mb-2 { margin-bottom:8px; }
.mb-3 { margin-bottom:12px; }
.p-4  { padding:16px; }
.p-0  { padding:0; }
.flex { display:flex; }
.items-center { align-items:center; }
.gap-2 { gap:8px; }
.flex-wrap { flex-wrap:wrap; }

/* Responsive */
@media (max-width: 768px) {
  .edit-layout { grid-template-columns:1fr; }
  .edit-sidebar { order:-1; }
  .analytics-grid { grid-template-columns:1fr; }
  .admin-grid { grid-template-columns:1fr; }
  .flipbooks-grid { grid-template-columns:repeat(auto-fill,minmax(160px,1fr)); }
  .table { font-size:12px; }
  .table th:nth-child(n+5), .table td:nth-child(n+5) { display:none; }
}

/* ── Auth page layout ────────────────────────────────────────────────────── */
.auth-body {
  background: #f5f5f7;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.auth-wrap {
  width: 100%;
  max-width: 420px;
}

/* ════════════════════════════════════════════════════════════════
   COMPATIBILITY LAYER — maps new class names to existing styles
   ════════════════════════════════════════════════════════════════ */

/* form-control = old .input style */
.form-control {
  display: block;
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  outline: none;
  transition: border-color var(--t-base), box-shadow var(--t-base);
  line-height: 1.5;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.form-control::placeholder { color: var(--text-tertiary); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

/* stats-grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-info { flex: 1; }
.stat-card {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* page-title / page-subtitle */
.page-title  { font-size: 20px; font-weight: 600; color: var(--text); margin: 0; }
.page-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

/* page-header override for new layout */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
  padding: 0;
  border: none;
  height: auto;
}

/* card body/header */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 14px; font-weight: 600; margin: 0; }
.card-body  { padding: 16px; }

/* table */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); background: var(--bg-subtle); }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg-subtle); }

/* badge */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 500; }
.badge-success   { background: var(--green-light);  color: var(--green); }
.badge-warning   { background: var(--amber-light);  color: var(--amber); }
.badge-danger    { background: var(--red-light);    color: var(--red); }
.badge-primary   { background: var(--primary-light);color: var(--primary); }
.badge-secondary { background: var(--gray-100);     color: var(--gray-600); }

/* alert */
.alert { padding: 12px 16px; border-radius: var(--r-md); font-size: 14px; margin-bottom: 16px; border: 1px solid transparent; }
.alert-success { background: var(--green-light); color: var(--green); border-color: #bbf7d0; }
.alert-danger  { background: var(--red-light);   color: var(--red);   border-color: #fecaca; }
.alert-warning { background: var(--amber-light); color: var(--amber); border-color: #fde68a; }

/* btn-outline */
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }

/* btn sizes */
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 5px; }

/* form-row */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media(max-width:480px){ .form-row { grid-template-columns: 1fr; } }

/* form-actions */
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

/* required star */
.required { color: var(--red); }

/* text utilities */
.text-muted  { color: var(--text-secondary); }
.text-sm     { font-size: 13px; }
.text-xs     { font-size: 11px; }
.text-danger { color: var(--red); }
.text-success{ color: var(--green); }
.text-warning{ color: var(--amber); }
.text-right  { text-align: right; }
.font-medium { font-weight: 500; }

/* spacing */
.mt-1{margin-top:4px} .mt-2{margin-top:8px} .mt-3{margin-top:12px} .mt-4{margin-top:20px}
.mb-1{margin-bottom:4px} .mb-2{margin-bottom:8px} .mb-3{margin-bottom:12px} .mb-4{margin-bottom:20px}
.p-0{padding:0} .p-4{padding:16px} .gap-2{gap:8px}

/* flex */
.flex{display:flex} .items-center{align-items:center} .justify-between{justify-content:space-between}

/* bg-secondary for missing var */
:root { --bg-secondary: var(--gray-100); }

/* dropdown-divider */
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* upload zone */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--r-lg);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.upload-icon { margin-bottom: 12px; color: var(--text-secondary); }
.upload-text { font-size: 15px; }
.upload-hint { margin-top: 6px; }
