/* ============================================
   ADG CRM - Design System & Styles
   Light premium theme with dark sidebar
   ============================================ */

/* --- CSS Custom Properties (Design Tokens) --- */
:root {
  /* ADG Brand */
  --adg-red: #D40000;
  --adg-red-hover: #B80000;
  --adg-red-light: #FEF2F2;
  --adg-red-glow: rgba(212, 0, 0, 0.08);

  /* Backgrounds */
  --bg-body: #F8F8FA;
  --bg-card: #FFFFFF;
  --bg-sidebar: #1A1A2E;
  --bg-sidebar-hover: #252542;
  --bg-sidebar-active: #2E2E50;
  --bg-input: #F4F4F6;
  --bg-input-focus: #FFFFFF;
  --bg-overlay: rgba(0, 0, 0, 0.4);

  /* Text */
  --text-primary: #111118;
  --text-secondary: #555566;
  --text-muted: #999AAB;
  --text-sidebar: #B0B0C0;
  --text-sidebar-active: #FFFFFF;
  --text-on-red: #FFFFFF;

  /* Borders */
  --border: #E8E8EC;
  --border-hover: #D0D0D8;
  --border-focus: #D40000;

  /* Status */
  --success: #16A34A;
  --success-bg: #F0FDF4;
  --warning: #D97706;
  --warning-bg: #FFFBEB;
  --danger: #DC2626;
  --danger-bg: #FEF2F2;
  --info: #2563EB;
  --info-bg: #EFF6FF;

  /* Premium accent */
  --gold: #92742C;
  --gold-bg: #FDF8EC;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* Border radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 20px rgba(212, 0, 0, 0.1);

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: 0.15s var(--ease-out);
  --transition-normal: 0.2s var(--ease-out);
  --transition-slow: 0.35s var(--ease-out);

  /* Layout */
  --sidebar-width: 260px;
  --header-height: 64px;
}


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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-body);
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

h1 { font-size: 28px; font-weight: 800; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
h4 { font-size: 16px; }

a {
  color: var(--adg-red);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--adg-red-hover); }

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

/* Monospace for dollar values and IDs */
.mono {
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  font-weight: 500;
}


/* --- App Layout --- */
/* Sidebar + main content side by side */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition-slow);
}

/* Logo area at top of sidebar */
.sidebar-brand {
  padding: var(--space-lg) var(--space-lg) var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand img {
  width: 32px;
  height: auto;
}

.sidebar-brand h2 {
  color: var(--text-sidebar-active);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  line-height: 1.3;
}

/* Navigation links */
.sidebar-nav {
  flex: 1;
  padding: var(--space-md) var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  color: var(--text-sidebar);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition-fast);
}

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

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

.sidebar-nav a svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-nav a.active svg,
.sidebar-nav a:hover svg {
  opacity: 1;
}

/* User section at bottom of sidebar */
.sidebar-user {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--adg-red);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

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

.sidebar-user-name {
  color: var(--text-sidebar-active);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  color: var(--text-sidebar);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-signout {
  background: none;
  border: none;
  color: var(--text-sidebar);
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.sidebar-signout:hover {
  color: var(--text-sidebar-active);
  background: var(--bg-sidebar-hover);
}

/* --- Mobile sidebar toggle --- */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: var(--space-md);
  left: var(--space-md);
  z-index: 200;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--bg-sidebar);
  border: none;
  color: white;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 90;
}


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

/* Page header with title and actions */
.page-header {
  padding: var(--space-xl) var(--space-2xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.page-header h1 {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: var(--space-xs);
}

.page-body {
  padding: 0 var(--space-2xl) var(--space-2xl);
}


/* --- Cards --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-xs);
  transition: all var(--transition-normal);
}

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}


/* --- Stat Cards (Dashboard) --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-xs);
}

.stat-card-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-sm);
}

.stat-card-value {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.stat-card-value.mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 28px;
}

.stat-card-change {
  font-size: 12px;
  font-weight: 500;
  margin-top: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.stat-card-change.up { color: var(--success); }
.stat-card-change.down { color: var(--danger); }


/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

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

.btn:active {
  transform: translateY(0);
}

/* Primary button - ADG red */
.btn-primary {
  background: var(--adg-red);
  color: var(--text-on-red);
  box-shadow: 0 1px 3px rgba(212, 0, 0, 0.2);
}

.btn-primary:hover {
  background: var(--adg-red-hover);
  box-shadow: 0 4px 12px rgba(212, 0, 0, 0.25);
}

/* Secondary button - white with border */
.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}

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

/* Ghost button - text only */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 12px;
}

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

/* Danger button */
.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #B91C1C;
}

/* Small button */
.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* Icon-only button */
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
}

.btn svg {
  width: 18px;
  height: 18px;
}


/* --- Form Inputs --- */
.form-group {
  margin-bottom: var(--space-md);
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  background: var(--bg-input-focus);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--adg-red-glow);
}

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

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

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

/* Inline form row (two inputs side by side) */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.form-error {
  color: var(--danger);
  font-size: 12px;
  margin-top: var(--space-xs);
}


/* --- Badges / Pills --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-blue     { background: var(--info-bg);    color: var(--info); }
.badge-purple   { background: #F3F0FF;           color: #7C3AED; }
.badge-orange   { background: var(--warning-bg);  color: var(--warning); }
.badge-red      { background: var(--danger-bg);   color: var(--danger); }
.badge-green    { background: var(--success-bg);  color: var(--success); }
.badge-indigo   { background: #EEF2FF;           color: #6366F1; }
.badge-gold     { background: var(--gold-bg);     color: var(--gold); }
.badge-gray     { background: #F4F4F5;           color: #71717A; }

/* Stage count badge (small circle) */
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  background: var(--bg-input);
  color: var(--text-secondary);
}


/* --- Kanban Pipeline --- */
.kanban-wrapper {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  padding-bottom: var(--space-lg);
}

.kanban-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-height: 520px;
}

/* Column header with colored top border */
.kanban-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  border-top: 3px solid var(--info);
  background: var(--bg-card);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.kanban-column-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.kanban-column-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Column body (scrollable area for cards) */
.kanban-column-body {
  flex: 1;
  padding: var(--space-sm);
  background: var(--bg-body);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  min-height: 200px;
  transition: background var(--transition-fast);
}

/* Highlight column when dragging a card over it */
.kanban-column-body.drag-over {
  background: var(--adg-red-light);
  border-color: var(--adg-red);
  border-style: dashed;
}

/* Individual lead card in the kanban */
.kanban-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  cursor: grab;
  transition: all var(--transition-fast);
  user-select: none;
  position: relative;
}

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

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

/* Card is being dragged */
.kanban-card.dragging {
  opacity: 0.5;
  transform: rotate(2deg);
  box-shadow: var(--shadow-lg);
}

.kanban-card-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.kanban-card-project {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.kanban-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-sm);
}

.kanban-card-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.kanban-card-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 11px;
  color: var(--text-muted);
}

/* Hot lead indicator */
.kanban-card-hot {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--adg-red);
  box-shadow: 0 0 6px rgba(212, 0, 0, 0.4);
  animation: pulse-hot 2s infinite;
}

@keyframes pulse-hot {
  0%, 100% { box-shadow: 0 0 6px rgba(212, 0, 0, 0.4); }
  50% { box-shadow: 0 0 14px rgba(212, 0, 0, 0.6); }
}

/* Add lead button inside column */
.kanban-add-btn {
  width: 100%;
  padding: var(--space-sm);
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
}

.kanban-add-btn:hover {
  border-color: var(--adg-red);
  color: var(--adg-red);
  background: var(--adg-red-light);
}

/* Empty column state */
.kanban-empty {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
  color: var(--text-muted);
  font-size: 13px;
}


/* --- Pipeline Filters Bar --- */
.pipeline-filters {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
  max-width: 320px;
}

.search-input-wrapper svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.search-input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.search-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--adg-red-glow);
}

.filter-select {
  padding: 10px 36px 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--text-secondary);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-select:focus {
  outline: none;
  border-color: var(--border-focus);
}

/* Hot toggle */
.hot-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: all var(--transition-fast);
}

.hot-toggle:hover {
  border-color: var(--adg-red);
  color: var(--adg-red);
}

.hot-toggle.active {
  background: var(--adg-red-light);
  border-color: var(--adg-red);
  color: var(--adg-red);
}


/* --- Activity Timeline --- */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline-item {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border);
  position: relative;
}

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

.timeline-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.timeline-icon.note     { background: #F4F4F5; color: #71717A; }
.timeline-icon.call     { background: var(--info-bg); color: var(--info); }
.timeline-icon.email    { background: #F3F0FF; color: #7C3AED; }
.timeline-icon.sms      { background: var(--success-bg); color: var(--success); }
.timeline-icon.stage    { background: var(--gold-bg); color: var(--gold); }
.timeline-icon.system   { background: var(--bg-input); color: var(--text-muted); }

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

.timeline-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.timeline-body {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: var(--space-xs);
}

.timeline-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}


/* --- Table (Leads List View) --- */
.data-table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table thead {
  background: var(--bg-input);
}

.data-table th {
  padding: var(--space-md);
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast);
  white-space: nowrap;
}

.data-table th:hover {
  color: var(--text-primary);
}

.data-table th.sorted {
  color: var(--adg-red);
}

.data-table td {
  padding: var(--space-md);
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  white-space: nowrap;
}

.data-table tbody tr {
  cursor: pointer;
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: var(--adg-red-glow);
}


/* --- Slide-Over Panel (Add/Edit Lead) --- */
.slide-over-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.slide-over-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.slide-over {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  max-width: 100%;
  background: var(--bg-card);
  z-index: 210;
  transform: translateX(100%);
  transition: transform var(--transition-slow);
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.15);
}

.slide-over-backdrop.open .slide-over {
  transform: translateX(0);
}

.slide-over-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.slide-over-header h3 {
  font-size: 18px;
}

.slide-over-close {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.slide-over-close:hover {
  background: var(--bg-input);
  color: var(--text-primary);
}

/* Make the form a flex column so body scrolls and footer stays pinned */
.slide-over form,
.slide-over > .slide-over-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.slide-over-body {
  flex: 1;
  padding: var(--space-lg);
  overflow-y: auto;
  min-height: 0;
}

.slide-over-footer {
  padding: var(--space-lg);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  flex-shrink: 0;
}


/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  color: var(--text-primary);
  animation: toast-in 0.3s var(--ease-out);
  max-width: 400px;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.info    { border-left: 4px solid var(--info); }

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-xs);
  margin-left: auto;
}

@keyframes toast-in {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

@keyframes toast-out {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(100%); opacity: 0; }
}


/* --- Loading Spinner --- */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--adg-red);
  border-radius: var(--radius-full);
  animation: spin 0.6s linear infinite;
}

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

.page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  flex-direction: column;
  gap: var(--space-md);
  color: var(--text-muted);
}


/* --- Login Page --- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-body);
  padding: var(--space-lg);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl);
  box-shadow: var(--shadow-md);
}

.login-logo {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.login-logo img {
  width: 48px;
  height: auto;
  margin-bottom: var(--space-md);
}

.login-logo h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--text-primary);
}

.login-logo p {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: var(--space-xs);
}

.login-form .btn-primary {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  margin-top: var(--space-sm);
}

.login-footer {
  text-align: center;
  margin-top: var(--space-lg);
  font-size: 13px;
  color: var(--text-muted);
}

.login-footer a {
  color: var(--adg-red);
  font-weight: 500;
}

.login-error {
  background: var(--danger-bg);
  color: var(--danger);
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: var(--space-md);
  display: none;
}

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


/* --- Charts Area --- */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-xs);
}

.chart-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-md);
}


/* --- Empty States --- */
.empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-xl);
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: var(--space-md);
  opacity: 0.4;
}

.empty-state h3 {
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.empty-state p {
  font-size: 14px;
  max-width: 360px;
  margin: 0 auto var(--space-lg);
}


/* --- Utilities --- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.font-bold { font-weight: 700; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.hidden { display: none !important; }
.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


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

@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

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

@media (max-width: 768px) {
  /* Sidebar becomes a slide-out menu */
  .sidebar {
    transform: translateX(-100%);
  }

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

  .sidebar-overlay.open {
    display: block;
  }

  .mobile-menu-btn {
    display: flex;
  }

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

  .page-header {
    padding: 80px var(--space-lg) var(--space-lg);
    flex-direction: column;
    align-items: flex-start;
  }

  .page-body {
    padding: 0 var(--space-lg) var(--space-lg);
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
  }

  .slide-over {
    width: 100%;
  }

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

  .kanban-wrapper {
    grid-template-columns: 1fr;
  }

  .kanban-column {
    max-height: 400px;
  }

  .pipeline-filters {
    flex-direction: column;
    align-items: stretch;
  }

  .search-input-wrapper {
    max-width: 100%;
  }
}

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

  .stat-card-value {
    font-size: 26px;
  }
}


/* --- Page load animation --- */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-in {
  animation: fadeUp 0.4s var(--ease-out) both;
}

.animate-d1 { animation-delay: 0.05s; }
.animate-d2 { animation-delay: 0.1s; }
.animate-d3 { animation-delay: 0.15s; }
.animate-d4 { animation-delay: 0.2s; }
.animate-d5 { animation-delay: 0.25s; }
.animate-d6 { animation-delay: 0.3s; }
