/* =========================================================
   CRM Factory — Global Design System
   Modern, clean, premium SaaS aesthetic
   ========================================================= */

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

/* ── Design Tokens ── */
:root {
  /* Brand (overridden per-tenant via inline styles) */
  --primary:        #4f46e5;
  --primary-hover:  #4338ca;
  --primary-light:  rgba(79, 70, 229, 0.08);
  --accent:         #4f46e5;

  /* Sidebar (overridden per-tenant) */
  --sidebar-bg:     #0f172a;
  --sidebar-text:   #ffffff;
  --sidebar-width:  260px;

  /* Neutrals */
  --gray-50:   #f8fafc;
  --gray-100:  #f1f5f9;
  --gray-200:  #e2e8f0;
  --gray-300:  #cbd5e1;
  --gray-400:  #94a3b8;
  --gray-500:  #64748b;
  --gray-600:  #475569;
  --gray-700:  #334155;
  --gray-800:  #1e293b;
  --gray-900:  #0f172a;

  /* Semantic */
  --success:   #10b981;
  --warning:   #f59e0b;
  --danger:    #ef4444;
  --info:      #3b82f6;

  /* Surface */
  --surface:   #ffffff;
  --body-bg:   #f8fafc;

  /* 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,.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,.05), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.06), 0 4px 6px rgba(0,0,0,.05);

  /* Radii */
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', ui-monospace, monospace;

  /* Transitions */
  --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--gray-800);
  background: var(--body-bg);
  margin: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--gray-900);
  margin-bottom: 0.5rem;
}

h1 { font-size: 1.875rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

p { margin-bottom: 1rem; color: var(--gray-600); }

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-hover); }

code, kbd, pre {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

code {
  background: var(--gray-100);
  color: var(--gray-700);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
}

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

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

.card-header {
  padding: 1rem 1.25rem;
  background: transparent;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.card-header h5, .card-header h6 { margin: 0; font-weight: 600; }

.card-body { padding: 1.25rem; }

.card-footer {
  padding: 0.75rem 1.25rem;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-100);
  color: var(--gray-500);
  font-size: 0.8125rem;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  vertical-align: middle;
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Primary */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 1px 3px rgba(79,70,229,.35);
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
  box-shadow: 0 3px 8px rgba(79,70,229,.4);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); box-shadow: none; }

/* Secondary */
.btn-secondary {
  background: var(--gray-700);
  border-color: var(--gray-700);
  color: #fff;
}
.btn-secondary:hover { background: var(--gray-800); border-color: var(--gray-800); color: #fff; }

/* Outline variants */
.btn-outline-primary {
  background: transparent;
  border-color: var(--primary);
  color: var(--primary);
}
.btn-outline-primary:hover {
  background: var(--primary);
  color: #fff;
}

.btn-outline-secondary {
  background: transparent;
  border-color: var(--gray-300);
  color: var(--gray-600);
}
.btn-outline-secondary:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
  color: var(--gray-800);
}

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

/* Success */
.btn-success {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
  box-shadow: 0 1px 3px rgba(16,185,129,.35);
}
.btn-success:hover {
  background: #059669;
  border-color: #059669;
  color: #fff;
  box-shadow: 0 3px 8px rgba(16,185,129,.4);
  transform: translateY(-1px);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--gray-600);
}
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-800); }

/* Sizes */
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; border-radius: var(--radius-lg); }

/* ── Forms ── */
.form-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 0.375rem;
  display: block;
}

.form-control, .form-select {
  display: block;
  width: 100%;
  padding: 0.5625rem 0.875rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--gray-800);
  background: #fff;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}

.form-control::placeholder { color: var(--gray-400); }

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
  outline: none;
}

.form-control:hover:not(:focus), .form-select:hover:not(:focus) {
  border-color: var(--gray-300);
}

.form-control-lg { padding: 0.75rem 1rem; font-size: 1rem; border-radius: var(--radius-lg); }
.form-select-lg { padding: 0.75rem 1rem; font-size: 1rem; border-radius: var(--radius-lg); }

textarea.form-control { resize: vertical; min-height: 100px; }

.input-group {
  display: flex;
  align-items: stretch;
}

.input-group .form-control {
  border-radius: 0;
  flex: 1;
}

.input-group .form-control:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.input-group .form-control:last-child { border-radius: 0 var(--radius) var(--radius) 0; }

.input-group-text {
  padding: 0.5625rem 0.875rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-600);
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  white-space: nowrap;
  display: flex;
  align-items: center;
}

.input-group .form-control + .input-group-text,
.input-group .input-group-text + .form-control {
  border-left: none;
}

.input-group-text:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.input-group-text:last-child { border-radius: 0 var(--radius) var(--radius) 0; }

.input-group-lg .form-control { padding: 0.75rem 1rem; font-size: 1rem; }
.input-group-lg .input-group-text { padding: 0.75rem 1rem; font-size: 1rem; }

/* Checkbox & Radio */
.form-check { display: flex; align-items: center; gap: 0.5rem; padding: 0; margin: 0; }
.form-check-input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  border: 1.5px solid var(--gray-300);
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
  background: #fff;
  appearance: none;
  transition: all var(--transition);
  position: relative;
}
.form-check-input[type="radio"] { border-radius: 50%; }
.form-check-input:checked {
  background: var(--primary);
  border-color: var(--primary);
}
.form-check-input:checked::after {
  content: '';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.form-check-input[type="checkbox"]:checked::before {
  content: '';
  position: absolute;
  left: 2px; top: 2px;
  width: 8px; height: 5px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg);
}
.form-check-input[type="radio"]:checked::before {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: #fff;
  transform: translate(-50%, -50%);
}

.form-check-label { font-size: 0.875rem; color: var(--gray-700); cursor: pointer; }

/* Switch */
.form-switch .form-check-input {
  width: 2.25rem;
  height: 1.25rem;
  border-radius: 99px;
  background: var(--gray-300);
  border: none;
  position: relative;
  cursor: pointer;
  transition: background var(--transition);
}
.form-switch .form-check-input::before {
  content: '';
  position: absolute;
  left: 3px; top: 50%;
  width: 0.875rem; height: 0.875rem;
  border-radius: 50%;
  background: #fff;
  transform: translateY(-50%);
  transition: left var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.form-switch .form-check-input:checked {
  background: var(--primary);
}
.form-switch .form-check-input:checked::before {
  left: calc(100% - 3px - 0.875rem);
}

/* Color input */
.form-control-color {
  width: 3rem;
  height: 2.5rem;
  padding: 0.25rem;
  border-radius: var(--radius);
  cursor: pointer;
}
.form-control-color.w-100 { width: 100%; }

/* ── Tables ── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table th {
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

.table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  vertical-align: middle;
}

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

.table-hover tbody tr {
  transition: background var(--transition);
}
.table-hover tbody tr:hover td {
  background: var(--gray-50);
}

.table-light th { background: var(--gray-50); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25em 0.625em;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border-radius: 99px;
  white-space: nowrap;
}

.bg-primary   { background: rgba(79,70,229,.12) !important; color: #4f46e5 !important; }
.bg-success   { background: rgba(16,185,129,.12) !important; color: #059669 !important; }
.bg-warning   { background: rgba(245,158,11,.12) !important; color: #d97706 !important; }
.bg-danger    { background: rgba(239,68,68,.12) !important;  color: #dc2626 !important; }
.bg-info      { background: rgba(59,130,246,.12) !important; color: #2563eb !important; }
.bg-secondary { background: var(--gray-100) !important; color: var(--gray-600) !important; }
.bg-light     { background: var(--gray-100) !important; color: var(--gray-700) !important; }

/* ── Alerts ── */
.alert {
  padding: 0.875rem 1rem;
  border-radius: var(--radius);
  border: 1.5px solid transparent;
  font-size: 0.875rem;
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  margin-bottom: 1rem;
}

.alert-success {
  background: rgba(16,185,129,.08);
  border-color: rgba(16,185,129,.25);
  color: #065f46;
}
.alert-danger {
  background: rgba(239,68,68,.08);
  border-color: rgba(239,68,68,.25);
  color: #991b1b;
}
.alert-warning {
  background: rgba(245,158,11,.08);
  border-color: rgba(245,158,11,.25);
  color: #92400e;
}
.alert-info {
  background: rgba(59,130,246,.08);
  border-color: rgba(59,130,246,.25);
  color: #1e40af;
}

.btn-close {
  margin-left: auto;
  opacity: 0.5;
  font-size: 0.75rem;
  padding: 0.25rem;
  background: none;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
}
.btn-close:hover { opacity: 1; }
.btn-close::before { content: '✕'; }

/* ── Pagination ── */
.pagination { display: flex; align-items: center; gap: 0.25rem; list-style: none; padding: 0; margin: 0; }

.page-item .page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--gray-600);
  background: #fff;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  transition: all var(--transition);
  text-decoration: none;
}

.page-item .page-link:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
  color: var(--gray-800);
}

.page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ── Modals ── */
.modal-content {
  border: none;
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 50px rgba(0,0,0,.15);
  overflow: hidden;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-100);
  background: transparent;
}

.modal-title { font-size: 1rem; font-weight: 600; margin: 0; }

.modal-body { padding: 1.5rem; }

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
  gap: 0.5rem;
}

/* ── Utilities ── */
.text-muted { color: var(--gray-500) !important; }
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger)  !important; }
.text-warning { color: var(--warning) !important; }

.small, small { font-size: 0.8125rem; }

.border-bottom { border-bottom: 1px solid var(--gray-200) !important; }
.border-top    { border-top:    1px solid var(--gray-200) !important; }

/* ── Sidebar Layout ── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1040;
  transition: transform var(--transition-slow);
  display: flex;
  flex-direction: column;
}

/* Custom scrollbar for sidebar */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 99px; }

/* Brand / Logo area */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.125rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}

.sidebar-brand-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  color: rgba(255,255,255,.85);
}

.sidebar-brand-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--sidebar-text);
  opacity: 0.95;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Nav section */
.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
}

.sidebar-section-label {
  padding: 0.625rem 1.125rem 0.25rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
}

.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5625rem 1.125rem;
  margin: 0 0.5rem;
  border-radius: var(--radius);
  color: rgba(255,255,255,.6);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 450;
  transition: all var(--transition);
  position: relative;
}

.sidebar-nav-link:hover {
  color: rgba(255,255,255,.95);
  background: rgba(255,255,255,.08);
}

.sidebar-nav-link.active {
  color: #fff;
  background: rgba(255,255,255,.12);
  font-weight: 550;
}

.sidebar-nav-link.active::before {
  content: '';
  position: absolute;
  left: -0.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent, #fff);
  border-radius: 0 3px 3px 0;
}

.sidebar-nav-link i {
  font-size: 1rem;
  width: 1.25rem;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.8;
}

.sidebar-nav-link:hover i,
.sidebar-nav-link.active i { opacity: 1; }

/* Sidebar footer */
.sidebar-footer {
  padding: 0.75rem 0;
  border-top: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}

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

/* ── Top Bar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 900;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-900);
  margin: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* User avatar */
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

.user-name {
  font-size: 0.875rem;
  color: var(--gray-600);
  font-weight: 450;
}

/* ── Page Content ── */
.page-content {
  padding: 1.5rem;
  flex: 1;
}

/* ── Stat Cards ── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  overflow: hidden;
  position: relative;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--stat-accent, var(--primary));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

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

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

.stat-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 0.375rem;
}

.stat-value {
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1;
  color: var(--gray-900);
  margin: 0;
}

/* ── Section / Page Headers ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.page-header-left { display: flex; align-items: baseline; gap: 0.75rem; }

.page-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--gray-900);
  margin: 0;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--gray-500);
  margin: 0;
}

/* Record count pill */
.record-count {
  display: inline-flex;
  align-items: center;
  padding: 0.2em 0.6em;
  background: var(--gray-100);
  color: var(--gray-500);
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* ── Search bar ── */
.search-bar {
  position: relative;
  flex: 1;
  max-width: 280px;
}

.search-bar .bi-search {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: 0.875rem;
  pointer-events: none;
}

.search-bar .form-control {
  padding-left: 2.25rem;
}

/* ── Settings Hub ── */
.settings-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 1.25rem;
  background: var(--surface);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  transition: all var(--transition);
  gap: 0.75rem;
  box-shadow: var(--shadow-xs);
}

.settings-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light), var(--shadow-sm);
  transform: translateY(-2px);
  color: inherit;
}

.settings-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  background: var(--primary-light);
  color: var(--primary);
}

.settings-card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--gray-800);
  margin: 0;
}

.settings-card-desc {
  font-size: 0.8125rem;
  color: var(--gray-500);
  margin: 0;
}

/* ── Section titles ── */
.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gray-500);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1.5px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── Module / Field Items (sortable lists) ── */
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  transition: background var(--transition);
  gap: 1rem;
}

.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--gray-50); }

.list-item-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

.drag-handle {
  color: var(--gray-300);
  cursor: grab;
  font-size: 1rem;
  flex-shrink: 0;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition);
}

.drag-handle:hover { color: var(--gray-500); }
.drag-handle:active { cursor: grabbing; }

.list-item-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.list-item-label {
  font-weight: 500;
  color: var(--gray-800);
  font-size: 0.9375rem;
}

.list-item-meta {
  font-size: 0.8rem;
  color: var(--gray-400);
}

/* ── Builder Wizard ── */
.step-wizard {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 2rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.step-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex: 1;
}

.step-item:last-child { flex: none; }

.step-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 700;
  border: 2px solid var(--gray-200);
  background: #fff;
  color: var(--gray-400);
  flex-shrink: 0;
  transition: all var(--transition);
}

.step-circle.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(79,70,229,.15);
}

.step-circle.done {
  border-color: var(--success);
  background: var(--success);
  color: #fff;
}

.step-circle.done::before { content: '✓'; }

.step-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--gray-500);
}

.step-label.active { color: var(--primary); font-weight: 600; }
.step-label.done   { color: var(--success); }

.step-connector {
  flex: 1;
  height: 2px;
  background: var(--gray-200);
  margin: 0 0.5rem;
  border-radius: 99px;
  transition: background var(--transition);
}

.step-connector.done { background: var(--success); }

/* Builder panels */
.builder-step { display: none; }
.builder-step.active { display: block; }

/* Module cards in builder */
.module-card {
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 0.875rem 1rem;
  cursor: grab;
  transition: all var(--transition);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.module-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  transform: translateY(-1px);
}

.module-card:active { cursor: grabbing; }

.module-card.selected {
  border-color: var(--success);
  background: rgba(16,185,129,.04);
}

.module-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.module-card-name { font-weight: 600; font-size: 0.9rem; color: var(--gray-800); }
.module-card-desc { font-size: 0.8rem; color: var(--gray-400); }

/* Drop zones */
.drop-zone {
  min-height: 180px;
  padding: 0.75rem;
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius-lg);
  background: var(--gray-50);
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.drop-zone.active-target {
  border-color: var(--primary);
  background: var(--primary-light);
}

.drop-zone-selected {
  border-color: var(--success);
  background: rgba(16,185,129,.04);
}

/* Sidebar preview in builder */
.sidebar-preview {
  border-radius: var(--radius-lg);
  padding: 1rem;
  min-height: 280px;
  overflow: hidden;
}

.sidebar-preview-brand {
  font-weight: 700;
  font-size: 0.9375rem;
  color: rgba(255,255,255,.9);
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
  margin-bottom: 0.75rem;
}

.sidebar-preview-item {
  padding: 0.4375rem 0.625rem;
  border-radius: var(--radius);
  margin-bottom: 0.25rem;
  font-size: 0.8125rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: rgba(255,255,255,.7);
}

.sidebar-preview-item.active {
  background: rgba(255,255,255,.15);
  color: #fff;
}

/* ── Color preset chips ── */
.color-preset {
  display: inline-flex;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.color-preset:hover {
  transform: scale(1.15);
  border-color: var(--gray-200);
}

/* ── Record detail field display ── */
.field-display-item {
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--gray-100);
}

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

.field-display-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-400);
  margin-bottom: 0.25rem;
}

.field-display-value {
  font-size: 0.9375rem;
  color: var(--gray-800);
  font-weight: 450;
}

.field-display-value.empty { color: var(--gray-300); font-style: italic; }

/* ── Admin Layout ── */
.admin-navbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  background: var(--gray-900);
  border-bottom: 1px solid rgba(255,255,255,.06);
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.admin-navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9375rem;
}

.admin-navbar-brand i {
  width: 32px;
  height: 32px;
  background: var(--primary);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.admin-navbar-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.admin-navbar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.4375rem 0.75rem;
  border-radius: var(--radius);
  color: rgba(255,255,255,.65);
  font-size: 0.875rem;
  font-weight: 450;
  text-decoration: none;
  transition: all var(--transition);
}

.admin-navbar-nav .nav-link:hover {
  color: #fff;
  background: rgba(255,255,255,.08);
}

.admin-navbar-nav .nav-link.active {
  color: #fff;
  background: rgba(255,255,255,.12);
}

.admin-content {
  padding: 1.75rem 1.5rem;
  min-height: calc(100vh - 60px);
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* ── Tenant cards ── */
.tenant-card {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
}

.tenant-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--gray-300);
}

.tenant-card-body { padding: 1.25rem; flex: 1; }

.tenant-card-footer {
  padding: 0.75rem 1.25rem;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-100);
}

.tenant-stat {
  text-align: center;
  padding: 0.5rem;
}

.tenant-stat-value {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--gray-800);
  display: block;
}

.tenant-stat-label {
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-400);
}

/* ── Empty states ── */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--gray-400);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}

.empty-state-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-500);
  margin-bottom: 0.5rem;
}

.empty-state-desc {
  font-size: 0.875rem;
  color: var(--gray-400);
  margin-bottom: 1.5rem;
}

/* ── Mobile ── */
@media (max-width: 767.98px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 1050;
    box-shadow: 4px 0 24px rgba(0,0,0,.3);
  }

  .sidebar.show { transform: translateX(0); }

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

  .topbar { padding: 0 1rem; }
  .page-content { padding: 1rem; }

  .admin-content { padding: 1rem; }

  .step-wizard { overflow-x: auto; padding: 1rem; }
  .step-label { display: none; }

  .page-header { flex-direction: column; align-items: flex-start; }
}

/* ── Backdrop for mobile sidebar ── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1049;
  backdrop-filter: blur(2px);
}

.sidebar-backdrop.show { display: block; }

/* ── Sortable ghost ── */
.sortable-ghost {
  opacity: 0.4;
  background: var(--primary-light) !important;
  border: 1.5px dashed var(--primary) !important;
}

/* ── Bootstrap overrides ── */
.btn-group > .btn {
  border-radius: 0;
}
.btn-group > .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.btn-group > .btn:last-child  { border-radius: 0 var(--radius) var(--radius) 0; }
.btn-group-sm > .btn { border-radius: 0; }
.btn-group-sm > .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.btn-group-sm > .btn:last-child  { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* Ensure Bootstrap form-check works */
.form-check.form-switch { gap: 0.625rem; }

/* Row gutter fix */
.g-3 { --bs-gutter-x: 1rem; --bs-gutter-y: 1rem; }
.g-4 { --bs-gutter-x: 1.5rem; --bs-gutter-y: 1.5rem; }
