/* ============================================================
   FormFlow — Design System
   Premium B2B SaaS Aesthetic
   ============================================================ */

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

/* ── Variables ─────────────────────────────────────────── */
:root {
  /* ── Modern Palette (Slate + Blue) ── */
  --primary:        #2563EB;
  --primary-hover:  #1D4ED8;
  --primary-light:  #EFF6FF;
  --success:        #10B981;
  --success-light:  #F0FDF4;
  --danger:         #EF4444;
  --danger-light:   #FEF2F2;
  --warning:        #F59E0B;
  --warning-light:  #FFFBEB;

  /* Grays (Tailwind Slate inspired) */
  --slate-50:       #F8FAFC;
  --slate-100:      #F1F5F9;
  --slate-200:      #E2E8F0;
  --slate-300:      #CBD5E1;
  --slate-400:      #94A3B8;
  --slate-500:      #64748B;
  --slate-600:      #475569;
  --slate-700:      #334155;
  --slate-800:      #1E293B;
  --slate-900:      #0F172A;

  --bg:             var(--slate-50);
  --card:           #FFFFFF;
  --border:         var(--slate-200);
  --border-input:   var(--slate-200);

  --text:           var(--slate-900);
  --text-secondary: var(--slate-500);
  --text-muted:     var(--slate-400);

  --sidebar-w:      260px;
  --header-h:       64px;
  --radius:         12px;
  --radius-sm:      8px;

  /* Premium Shadows */
  --shadow-sm:      0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow:         0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow-md:      0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg:      0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --transition:     all .2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-hover); }
img { max-width: 100%; display: block; }
ul { list-style: none; }
input, textarea, select, button { font-family: inherit; }

/* ── Typography ─────────────────────────────────────────── */
h1, h2, h3, h4, h5 {
  font-family: 'Inter', sans-serif; /* Standardizing on Inter */
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
  letter-spacing: -0.025em;
}
h1 { font-size: 2.25rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
p  { color: var(--text-secondary); font-size: 0.9375rem; }

/* ── Layout — Sidebar + Main ────────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--slate-900); /* Dark Sidebar */
  border-right: 1px solid var(--slate-800);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform .3s ease;
}

.sidebar-logo {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-logo .logo-icon {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 15px rgba(37,99,235,0.3);
}
.sidebar-logo .logo-icon svg { color: #fff; width: 18px; height: 18px; }
.sidebar-logo .logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.03em;
}
.sidebar-logo .logo-text span { color: var(--primary); }

.sidebar-nav {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
}

.nav-section-label {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--slate-500);
  padding: 20px 12px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--slate-400);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 4px;
}
.nav-item svg { flex-shrink: 0; opacity: .8; width: 18px; height: 18px; }
.nav-item:hover {
  background: var(--slate-800);
  color: #fff;
}
.nav-item.active {
  background: var(--slate-800);
  color: #fff;
  font-weight: 600;
}
.nav-item.active svg { color: var(--primary); opacity: 1; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--slate-800);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  cursor: pointer;
}
.sidebar-user:hover { background: var(--slate-800); }
.sidebar-user .avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--slate-700);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.sidebar-user .avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-user .avatar-initials {
  font-size: .75rem;
  font-weight: 600;
  color: #fff;
}
.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name {
  font-size: .8125rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user .user-email {
  font-size: .6875rem;
  color: var(--slate-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

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

.header-search-wrapper {
  position: relative;
  width: 100%;
  max-width: 400px;
}
.header-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.header-search-input {
  width: 100%;
  padding: 8px 12px 8px 40px;
  background: var(--slate-100);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  transition: var(--transition);
  outline: none;
}
.header-search-input:focus {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37,99,235,.1);
}

.header-right { display: flex; align-items: center; gap: 16px; }

.header-user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}
.header-user-badge:hover { background: var(--card); border-color: var(--border-input); }

.user-avatar-sm {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .65rem;
  font-weight: 700;
  overflow: hidden;
}
.user-avatar-sm img { width: 100%; height: 100%; object-fit: cover; }
.user-name-sm { font-size: .875rem; font-weight: 500; color: var(--text); }

.header-divider { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }

.btn-logout-header {
  color: var(--text-muted);
  transition: var(--transition);
  display: flex; align-items: center;
}
.btn-logout-header:hover { color: var(--danger); }

.btn-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
}
.btn-icon:hover { background: var(--bg); color: var(--primary); border-color: var(--primary); }

.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: 4px;
}

/* ── Page Body ──────────────────────────────────────────── */
.page-body {
  flex: 1;
  padding: 32px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}
.page-header h1 { margin-bottom: 4px; }
.page-header p  { font-size: .875rem; color: var(--text-secondary); }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow); }

.card-header {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.card-body { padding: 32px; }

/* ── Dashboard Specifics ────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}
@media (max-width: 1024px) { .dashboard-grid { grid-template-columns: 1fr; } }

.list-group { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
  text-decoration: none;
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--bg); }

.list-item-content { display: flex; flex-direction: column; gap: 2px; }
.list-item-title { font-size: .875rem; font-weight: 600; color: var(--text); }
.list-item-meta { font-size: .75rem; color: var(--text-muted); }

/* ── Stat Cards ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .75rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 20px;
}
.stat-trend.pos { color: var(--success); background: var(--success-light); }
.stat-trend.neg { color: var(--danger);  background: var(--danger-light); }

.stat-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.stat-icon.blue   { background: #EFF6FF; color: #3B82F6; }
.stat-icon.green  { background: #F0FDF4; color: #10B981; }
.stat-icon.orange { background: #FFFBEB; color: #F59E0B; }
.stat-icon.blue-light { background: #F8FAFC; color: #64748B; }

.stat-value { 
  font-size: 1.875rem; 
  font-weight: 700; 
  color: var(--text); 
  line-height: 1;
  letter-spacing: -0.025em;
}
.stat-label { 
  font-size: .875rem; 
  font-weight: 500;
  color: var(--text-secondary); 
  margin: 0;
}

/* ── Authentication ─────────────────────────────────────── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xl);
  padding: 48px 40px;
}
.auth-header { text-align: center; margin-bottom: 32px; }
.auth-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 16px;
  letter-spacing: -0.025em;
}
.auth-title { 
  font-size: 1.5rem; 
  font-weight: 700; 
  color: var(--text); 
  margin-bottom: 8px;
  letter-spacing: -0.025em;
}
.auth-subtitle { font-size: .875rem; color: var(--text-muted); }

.auth-form { display: flex; flex-direction: column; gap: 24px; }
.auth-link-sm { font-size: .8125rem; color: var(--primary); text-decoration: none; font-weight: 600; }
.auth-link-sm:hover { color: var(--primary-hover); }

.auth-footer {
  margin-top: 32px;
  text-align: center;
  font-size: .875rem;
  color: var(--text-muted);
}
.auth-link { color: var(--primary); font-weight: 600; text-decoration: none; }
.auth-link:hover { color: var(--primary-hover); }

.auth-copyright {
  margin-top: 32px;
  font-size: .75rem;
  color: var(--text-muted);
  text-align: center;
}

.input-wrapper { position: relative; display: flex; align-items: center; }
.input-icon { 
  position: absolute; 
  left: 14px; 
  color: var(--slate-400); 
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.form-control.with-icon { padding-left: 44px; }

/* ── Profile ────────────────────────────────────────────── */
.profile-header {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 40px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 32px;
  box-shadow: var(--shadow-sm);
}
.profile-avatar-large {
  width: 100px; height: 100px;
  border-radius: 50%;
  border: 4px solid #fff;
  box-shadow: var(--shadow-md);
  object-fit: cover;
}
.profile-info h1 { 
  font-size: 1.875rem; 
  font-weight: 700; 
  color: var(--text); 
  letter-spacing: -0.025em;
}
.profile-info p { color: var(--text-secondary); margin-top: 6px; font-size: 1rem; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  white-space: nowrap;
  text-decoration: none;
}
.btn-block { width: 100%; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
  color: #fff;
}

.btn-secondary {
  background: #fff;
  border-color: var(--border);
  color: var(--slate-700);
}
.btn-secondary:hover {
  background: var(--slate-50);
  border-color: var(--slate-300);
}

.btn-ghost {
  background: transparent;
  color: var(--slate-600);
}
.btn-ghost:hover { background: var(--slate-100); color: var(--slate-900); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #DC2626; color: #fff; transform: translateY(-1px); }

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-sm { padding: 6px 12px; font-size: .75rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; font-weight: 600; }

/* ── Forms / Inputs ─────────────────────────────────────── */
.form-group { margin-bottom: 24px; }
.form-label {
  display: block;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 8px;
}
.form-label .required { color: var(--danger); margin-left: 4px; }
.form-control {
  width: 100%;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--text);
  transition: var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37,99,235,.1);
}
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { cursor: pointer; }
.form-hint {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-top: 8px;
}

/* Checkbox & Radio custom */
.check-group { display: flex; flex-direction: column; gap: 8px; }
.check-item  { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check-item input[type="checkbox"],
.check-item input[type="radio"] {
  width: 16px; height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}
.check-item label { font-size: .875rem; color: var(--text-secondary); cursor: pointer; }

/* Toggle switch */
.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle {
  position: relative;
  width: 44px; height: 24px;
}
.toggle input { display: none; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border-input);
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  left: 3px; top: 3px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: var(--transition);
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }
.toggle-label { font-size: .875rem; color: var(--text-secondary); font-weight: 500; }

/* ── Table ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  text-align: left;
  padding: 12px 24px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
  background: var(--slate-50);
  white-space: nowrap;
}
tbody td {
  padding: 16px 24px;
  font-size: .875rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--slate-50); }
.table-actions { display: flex; gap: 8px; align-items: center; }

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger  { background: var(--danger-light);  color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-gray    { background: var(--slate-100); color: var(--slate-600); border: 1px solid var(--border); }

/* ── Alerts ─────────────────────────────────────────────── */
.alert {
  padding: 16px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 24px;
  border: 1px solid transparent;
}
.alert-success { background: var(--success-light); color: #166534; border-color: #bbf7d0; }
.alert-danger  { background: var(--danger-light);  color: #991b1b; border-color: #fecaca; }
.alert-warning { background: var(--warning-light); color: #92400e; border-color: #fef08a; }
.alert-info    { background: var(--primary-light); color: #1e40af; border-color: #bfdbfe; }

/* ── Empty State ────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  text-align: center;
}
.empty-state .empty-icon {
  width: 64px; height: 64px;
  background: var(--bg);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
  color: var(--text-muted);
}
.empty-state h3 { margin-bottom: 6px; }
.empty-state p  { font-size: .875rem; margin-bottom: 20px; max-width: 320px; }

/* ── Divider ────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* ── Modal / Overlay ────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--card);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow-xl);
  transform: scale(0.95) translateY(10px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.modal-title { 
  font-size: 1.125rem; 
  font-weight: 600; 
  color: var(--text);
}
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--slate-400);
  padding: 8px;
  border-radius: 8px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--slate-100); color: var(--slate-900); }
.modal-footer { 
  display: flex; 
  gap: 12px; 
  justify-content: flex-end; 
  margin-top: 32px; 
}

/* ── Form Builder ───────────────────────────────────────── */
.field-builder-list { display: flex; flex-direction: column; gap: 16px; }
.field-builder-item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: var(--transition);
  cursor: grab;
  box-shadow: var(--shadow-sm);
}
.field-builder-item:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.field-builder-item:active { cursor: grabbing; }
.field-builder-item.drag-over { border-color: var(--primary); background: var(--primary-light); }
.field-drag-handle {
  color: var(--slate-400);
  padding-top: 4px;
  cursor: grab;
  flex-shrink: 0;
}
.field-builder-body { flex: 1; }
.field-builder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.field-type-badge {
  font-size: .6875rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 4px 10px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.field-actions { display: flex; gap: 8px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.add-option-btn {
  background: var(--slate-50);
  border: 1px dashed var(--slate-300);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--slate-600);
  cursor: pointer;
  width: 100%;
  margin-top: 12px;
  transition: var(--transition);
}
.add-option-btn:hover { background: #fff; border-color: var(--primary); color: var(--primary); }
.option-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.option-row input { flex: 1; }
.option-remove {
  background: none; border: none;
  color: var(--slate-400); cursor: pointer;
  padding: 6px; border-radius: 6px;
  transition: var(--transition); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.option-remove:hover { color: var(--danger); background: var(--danger-light); }
.option-remove:hover { color: var(--danger); background: var(--danger-light); }

/* ── Charts container ───────────────────────────────────── */
.chart-wrap {
  position: relative;
  height: 240px;
  margin-top: 16px;
}
.analysis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin-top: 24px;
}

/* ── Copy link box ──────────────────────────────────────── */
.link-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}
.link-box input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: .8rem;
  color: var(--text-secondary);
}
.link-box button {
  flex-shrink: 0;
  background: var(--primary-light);
  border: none;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  transition: var(--transition);
}
.link-box button:hover { background: var(--primary); color: #fff; }

/* ── Avatar upload ──────────────────────────────────────── */
.avatar-upload {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 24px;
}
.avatar-preview {
  width: 80px; height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--slate-50);
  display: flex; 
  align-items: center; 
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ── Login Page ─────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f8fafc 0%, #eff6ff 100%);
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.05) 0%, transparent 70%);
  top: -200px; right: -200px;
  pointer-events: none;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  position: relative;
  z-index: 1;
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  margin-bottom: 32px;
}
.login-logo .logo-icon {
  width: 48px; height: 48px;
  background: var(--primary);
  border-radius: 14px;
  display: flex; 
  align-items: center; 
  justify-content: center;
  color: #fff;
}
.login-logo .logo-text {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.025em;
}
.login-logo .logo-text span { color: var(--primary); }
.login-headline {
  text-align: center;
  margin-bottom: 32px;
}
.login-headline h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: 8px; letter-spacing: -0.025em; }
.login-headline p  { font-size: .875rem; color: var(--text-secondary); }

/* ── Public Form Page ───────────────────────────────────── */
.public-page {
  min-height: 100vh;
  background: linear-gradient(180deg, #f8fafc 0%, #eff6ff 100%);
  padding: 60px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.public-header {
  text-align: center;
  margin-bottom: 40px;
}
.public-header .brand {
  font-size: .875rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.public-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px;
  width: 100%;
  max-width: 640px;
  box-shadow: var(--shadow-xl);
}
.public-card .form-title {
  font-size: 1.875rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 12px;
  letter-spacing: -0.025em;
}
.public-card .form-desc {
  font-size: 1rem;
  color: var(--slate-600);
  margin-bottom: 32px;
  line-height: 1.6;
}
.public-progress {
  height: 6px;
  background: var(--slate-100);
  border-radius: 99px;
  margin-bottom: 32px;
  overflow: hidden;
}
.public-progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
  transition: width .4s cubic-bezier(0.4, 0, 0.2, 1);
}
.public-footer {
  text-align: center;
  margin-top: 32px;
  font-size: .875rem;
  color: var(--slate-400);
}
.scale-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.scale-btn {
  width: 48px; height: 48px;
  border-radius: 12px;
  border: 1px solid var(--border-input);
  background: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
  color: var(--slate-600);
}
.scale-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}
.scale-btn.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}
.scale-btn input { display: none; }

/* ── Success screen ─────────────────────────────────────── */
.success-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 24px;
}
.success-icon {
  width: 72px; height: 72px;
  background: var(--success-light);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 20px;
  color: var(--success);
}
.success-icon svg { width: 36px; height: 36px; }

/* ── Misc utilities ─────────────────────────────────────── */
.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.items-center{ align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2       { gap: 8px; }
.gap-3       { gap: 12px; }
.gap-4       { gap: 16px; }
.mt-1        { margin-top: 4px; }
.mt-2        { margin-top: 8px; }
.mt-4        { margin-top: 16px; }
.mb-4        { margin-bottom: 16px; }
.mb-6        { margin-bottom: 24px; }
.text-sm     { font-size: .875rem; }
.text-xs     { font-size: .75rem; }
.text-muted  { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.font-semibold  { font-weight: 600; }
.w-full      { width: 100%; }
.hidden      { display: none !important; }

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

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1024px) {
  .form-row { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: 1fr; }
  .analysis-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    transform: translateX(-260px);
    width: 260px;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .main-content { margin-left: 0; }
  .menu-toggle { display: flex; }
  .page-body { padding: 20px 16px; }
  .header { padding: 0 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .form-row { grid-template-columns: 1fr; }
  .public-card { padding: 28px 20px; }
  .login-card { padding: 36px 24px; }

  /* Sidebar overlay */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.4);
    z-index: 99;
  }
  .sidebar-overlay.active { display: block; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .table-actions { flex-wrap: wrap; }
  h1 { font-size: 1.4rem; }
}
