/* ═══════════════════════════════════════════════════════════════════
   Onboard Dashboard — Edler.ai-inspired Design System
   ═══════════════════════════════════════════════════════════════════ */

/* ── Edler-inspired Design Tokens ────────────────────────────── */
:root {
  --bg-page: #F5F7FA;
  --bg-card: #FFFFFF;
  --bg-sidebar: #0B1C35;
  --bg-sidebar-hover: #132F4F;
  --bg-sidebar-active: #1A3F6A;
  --text-primary: #1E293B;
  --text-secondary: #6B7A99;
  --text-sidebar: #C8D6E5;
  --text-sidebar-active: #FFFFFF;
  --accent-blue: #295CC9;
  --accent-blue-hover: #214EA8;
  --accent-blue-light: #EEF3FC;
  --accent-green: #10B981;
  --accent-green-light: #D1FAE5;
  --accent-amber: #F59E0B;
  --accent-amber-light: #FEF3C7;
  --accent-red: #EF4444;
  --accent-red-light: #FEE2E2;
  --accent-purple: #8B5CF6;
  --accent-purple-light: #EDE9FE;
  --border: #E2E8F0;
  --border-light: #F1F5F9;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 6px rgba(0,0,0,0.05), 0 10px 15px rgba(0,0,0,0.05);
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
  --sidebar-width: 240px;
  --header-height: 56px;
  --transition: 0.2s ease;
}

/* ── Reset & Base ─────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent-blue);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-blue-hover);
}

img {
  max-width: 100%;
  height: auto;
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

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

/* ── Sidebar ──────────────────────────────────────────────────── */
.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  z-index: 40;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-blue);
  border-radius: 6px;
  color: #fff;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 1.125rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 12px;
}

.sidebar-section-title {
  padding: 16px 16px 8px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: #4A6A8A;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  margin-bottom: 2px;
  border-radius: var(--radius);
  color: var(--text-sidebar);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
  cursor: pointer;
}

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

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

.sidebar-nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: #6B7A99;
}

.sidebar-nav-item.active .sidebar-nav-icon {
  color: #fff;
}

.sidebar-nav-item:hover .sidebar-nav-icon {
  color: #fff;
}

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.75rem;
  color: #4A6A8A;
  font-family: var(--font-mono);
}

/* ── Sidebar Overlay (mobile) ─────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 39;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.sidebar-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ── Hamburger (mobile) ───────────────────────────────────────── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  z-index: 41;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  align-items: center;
  justify-content: space-between;
}

.mobile-brand {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--accent-blue);
}

.hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius);
  transition: background var(--transition);
}

.hamburger:hover {
  background: var(--bg-page);
}

.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all var(--transition);
}

.hamburger span + span {
  margin-top: 5px;
}

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

/* ── App Header ───────────────────────────────────────────────── */
.app-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 30;
  gap: 16px;
}

.breadcrumb {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.breadcrumb span {
  color: var(--text-primary);
  font-weight: 500;
}

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

/* ── App Content ──────────────────────────────────────────────── */
.app-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* ── Cards ────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 20px;
  transition: transform var(--transition), box-shadow var(--transition);
}

.card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

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

.card-header h2,
.card-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

/* ── Stat Cards ───────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform var(--transition), box-shadow var(--transition);
}

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

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.blue {
  background: var(--accent-blue-light);
  color: var(--accent-blue);
}

.stat-icon.green {
  background: var(--accent-green-light);
  color: var(--accent-green);
}

.stat-icon.amber {
  background: var(--accent-amber-light);
  color: var(--accent-amber);
}

.stat-icon.purple {
  background: var(--accent-purple-light);
  color: var(--accent-purple);
}

.stat-icon.red {
  background: var(--accent-red-light);
  color: var(--accent-red);
}

.stat-icon svg {
  width: 22px;
  height: 22px;
}

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

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 2px;
}

/* ── Badges ───────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

.badge-green {
  background: var(--accent-green-light);
  color: #065F46;
}

.badge-blue {
  background: #DBEAFE;
  color: #1E40AF;
}

.badge-amber {
  background: var(--accent-amber-light);
  color: #92400E;
}

.badge-red {
  background: var(--accent-red-light);
  color: #991B1B;
}

.badge-slate {
  background: var(--border-light);
  color: #475569;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}

.btn:hover {
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

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

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

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

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn-outline:hover {
  background: #F8FAFC;
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

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

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

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

.btn-danger:hover {
  background: #DC2626;
  color: #fff;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.8125rem;
}

.btn-icon {
  padding: 6px;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 1rem;
}

/* ── Tables ───────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

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

thead th {
  background: #F8FAFC;
  padding: 12px 16px;
  text-align: left;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  white-space: nowrap;
}

tbody td {
  padding: 12px 16px;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover {
  background: #F8FAFC;
}

tbody tr:last-child td {
  border-bottom: none;
}

/* ── Pipeline / Funnel ────────────────────────────────────────── */
.pipeline {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 16px 0;
}

.pipeline-stage {
  flex: 1;
  min-width: 160px;
  background: #F8FAFC;
  border-radius: var(--radius-lg);
  padding: 12px;
}

.pipeline-stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.pipeline-stage-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.pipeline-stage-count {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.pipeline-stage-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 8px;
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: box-shadow var(--transition);
}

.pipeline-stage-card:hover {
  box-shadow: var(--shadow-md);
}

.pipeline-stage-card:last-child {
  margin-bottom: 0;
}

.pipeline-stage-card-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
}

.pipeline-stage-card-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin-top: 6px;
  overflow: hidden;
}

.pipeline-stage-card-progress-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent-blue);
  transition: width 0.3s ease;
}

/* ── Progress Bar ─────────────────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-green));
  transition: width 0.5s ease;
}

/* ── Modal ─────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 24px;
  max-width: 500px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ── Forms ────────────────────────────────────────────────────── */
input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-card);
  transition: all var(--transition);
  box-sizing: border-box;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(41, 92, 201, 0.1);
}

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='%236B7A99' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

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

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

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

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ── Empty State ──────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.3;
  color: var(--text-secondary);
}

.empty-state h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 8px;
}

.empty-state p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  max-width: 400px;
  margin: 0 auto;
}

/* ── Activity List ────────────────────────────────────────────── */
.activity-list {
  display: flex;
  flex-direction: column;
}

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

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

.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-blue-light);
  color: var(--accent-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.activity-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}

.activity-meta {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.activity-time {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Quick Actions ────────────────────────────────────────────── */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
  text-align: center;
}

.quick-action-btn:hover {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  text-decoration: none;
}

.quick-action-btn svg {
  width: 28px;
  height: 28px;
  color: var(--accent-blue);
}

/* ── Toast / Notifications ────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 400px;
}

.toast {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.3s ease;
  margin-bottom: 8px;
  border-left: 4px solid var(--accent-blue);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.toast-success {
  border-left-color: var(--accent-green);
}

.toast-error {
  border-left-color: var(--accent-red);
}

.toast-warning {
  border-left-color: var(--accent-amber);
}

.toast-body {
  flex: 1;
}

.toast-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.toast-message {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.toast-close {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 1rem;
  padding: 0;
  border-radius: 4px;
}

.toast-close:hover {
  background: var(--border-light);
}

/* ── Loading Skeleton ─────────────────────────────────────────── */
.loading-skeleton {
  background: linear-gradient(90deg, var(--border-light) 25%, var(--border) 50%, var(--border-light) 75%);
  background-size: 200px 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: var(--radius);
}

.loading-skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  width: 80%;
}

.loading-skeleton-title {
  height: 20px;
  margin-bottom: 12px;
  width: 60%;
}

.loading-skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

/* ── Spinner ──────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

.spinner-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

/* HTMX indicator */
.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator {
  display: inline-block;
}

.htmx-request.htmx-indicator {
  display: inline-block;
}

/* ── Section ──────────────────────────────────────────────────── */
.section {
  margin-bottom: 24px;
}

.section-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

/* ── Keyframes / Animations ───────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

@keyframes shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: 200px 0; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

/* ── Page fade-in on load ─────────────────────────────────────── */
.app-content {
  animation: pageFadeIn 0.25s ease-out;
}

/* ── Responsive: Tablet ─────────────────────────────────────────── */
@media (max-width: 1024px) {
  .app-content {
    padding: 20px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
}

/* ── Responsive: Mobile ─────────────────────────────────────────── */
@media (max-width: 768px) {
  body {
    padding-top: var(--header-height);
  }

  .mobile-header {
    display: flex;
  }

  .app-sidebar {
    transform: translateX(-100%);
  }

  .app-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: block;
  }

  .app-main {
    margin-left: 0;
  }

  .app-content {
    padding: 16px;
  }

  .app-header {
    padding: 0 16px;
    top: var(--header-height);
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .stat-card {
    padding: 16px;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .quick-actions {
    grid-template-columns: 1fr 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    border-radius: var(--radius);
  }

  .table-wrap th,
  .table-wrap td {
    padding: 10px 12px;
  }

  .card {
    padding: 16px;
  }

  .pipeline {
    padding: 12px 0;
  }

  .pipeline-stage {
    min-width: 140px;
  }
}

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

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .app-content {
    padding: 12px;
  }

  .app-header {
    padding: 0 12px;
  }
}

/* ── Print ────────────────────────────────────────────────────── */
@media print {
  .app-sidebar,
  .mobile-header,
  .sidebar-overlay,
  .header-actions,
  .btn {
    display: none !important;
  }

  .app-main {
    margin-left: 0;
  }

  .card,
  .stat-card {
    box-shadow: none;
    border: 1px solid var(--border);
    break-inside: avoid;
  }

  .app-content {
    padding: 0;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   Content Tab Styles (Edler-inspired)
   ═══════════════════════════════════════════════════════════════════ */

.content-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: #F1F5F9;
    padding: 4px;
    border-radius: 10px;
    width: fit-content;
}

.content-tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #6B7A99;
    cursor: pointer;
    transition: var(--transition);
}

.content-tab.active {
    background: white;
    color: #1E293B;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.content-card {
    overflow: hidden;
    padding: 0;
}

.content-card-preview {
    height: 120px;
    background: var(--color-border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
}

.content-card-body {
    padding: 16px;
}

.content-card-body h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 4px 0;
}

.content-card-meta {
    font-size: 13px;
    color: var(--color-text-muted);
    margin: 0 0 12px 0;
}

.content-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tab-content {
    display: none;
}

.tab-content:first-of-type {
    display: block;
}

/* ═══════════════════════════════════════════════════════════════════
   Content Editor Styles (Edler-inspired)
   ═══════════════════════════════════════════════════════════════════ */

.editor-layout {
    display: flex;
    gap: 0;
    height: calc(100vh - 56px);
    margin: -32px;
}

.editor-sidebar {
    width: 240px;
    min-width: 240px;
    background: #F8FAFC;
    border-right: 1px solid var(--color-border);
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.editor-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border-light);
}

.editor-sidebar-header h3 {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    color: var(--color-text);
}

.editor-lesson-list {
    flex: 1;
    overflow-y: auto;
}

.editor-lesson-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: 2px;
}

.editor-lesson-item:hover {
    background: var(--color-border-light);
}

.editor-lesson-item.active {
    background: var(--color-primary-light);
    color: var(--color-primary);
    font-weight: 500;
}

.lesson-number {
    width: 24px;
    height: 24px;
    background: var(--color-border-light);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.editor-lesson-item.active .lesson-number {
    background: var(--color-primary);
    color: white;
}

.lesson-title {
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.editor-main {
    flex: 1;
    padding: 24px 32px;
    overflow-y: auto;
    position: relative;
}

.editor-title-input {
    width: 100%;
    border: none;
    font-size: 24px;
    font-weight: 700;
    padding: 8px 0;
    margin-bottom: 24px;
    outline: none;
    background: transparent;
    color: var(--color-text);
    font-family: var(--font-family);
}

.editor-title-input:focus {
    border-bottom: 2px solid var(--color-primary);
    margin-bottom: 22px;
}

.editor-blocks {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
}

.add-block-fab {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 56px;
    height: 56px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.add-block-fab:hover {
    transform: scale(1.05);
    background: var(--color-primary-hover);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.block-type-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.block-type-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    cursor: pointer;
    background: white;
    transition: all var(--transition);
}

.block-type-item:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
    transform: translateY(-1px);
}

.block-type-icon {
    font-size: 24px;
}

.block-type-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
}

/* Editor Block Styles */
.editor-block {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    position: relative;
    transition: all var(--transition);
    animation: editorBlockFadeIn 0.3s ease;
}

.editor-block:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
}

.editor-block-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border-light);
}

.editor-block-controls {
    position: absolute;
    top: 8px;
    right: 8px;
    display: none;
    gap: 2px;
}

.editor-block:hover .editor-block-controls {
    display: flex;
}

.editor-block-content textarea {
    width: 100%;
    border: none;
    resize: vertical;
    min-height: 60px;
    font-size: 15px;
    outline: none;
    font-family: var(--font-family);
    padding: 8px;
    border-radius: var(--radius);
    background: var(--color-bg);
    color: var(--color-text);
    transition: background var(--transition-fast);
}

.editor-block-content textarea:focus {
    background: white;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.editor-block .block-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: white;
    background: var(--color-primary);
}

/* Ghost button variant */
.btn-ghost {
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-ghost:hover {
    background: var(--color-border-light);
}

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

/* Card grid */
.card-grid {
    display: grid;
    gap: 16px;
}

/* Edit/main mode responsive */
@media (max-width: 768px) {
    .editor-layout {
        flex-direction: column;
        height: auto;
        margin: -16px;
    }

    .editor-sidebar {
        width: 100%;
        min-width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
        max-height: 200px;
        overflow-y: auto;
    }

    .editor-main {
        padding: 16px;
    }

    .add-block-fab {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
        font-size: 24px;
    }

    .block-type-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .content-tabs {
        width: 100%;
        overflow-x: auto;
    }

    .card-grid .stat-card {
        padding: 16px;
    }
}
