/* ════════════════════════════════════════════════════════════════
   BumiRoster CRM/ERP — Premium Design System
   Dark Mode · Inter Font · Glassmorphism · Micro-animations
   ════════════════════════════════════════════════════════════════ */

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

/* ── CSS Variables (Design Tokens) ────────────────────────────── */
:root {
  /* Colors */
  --primary:         #6366f1;
  --primary-hover:   #4f46e5;
  --primary-light:   rgba(99,102,241,.15);
  --secondary:       #8b5cf6;
  --success:         #10b981;
  --success-light:   rgba(16,185,129,.12);
  --warning:         #f59e0b;
  --warning-light:   rgba(245,158,11,.12);
  --danger:          #ef4444;
  --danger-light:    rgba(239,68,68,.12);
  --info:            #06b6d4;
  --info-light:      rgba(6,182,212,.12);

  /* Backgrounds */
  --bg-base:         #0d1117;
  --bg-surface:      #161b27;
  --bg-card:         #1a2036;
  --bg-card-hover:   #1e2540;
  --bg-input:        #111827;
  --bg-sidebar:      #111827;
  --bg-topbar:       rgba(17,24,39,.9);
  --bg-modal:        #1a2036;

  /* Text */
  --text-primary:    #f1f5f9;
  --text-secondary:  #94a3b8;
  --text-muted:      #4b5563;
  --text-placeholder:#374151;

  /* Borders */
  --border:          rgba(255,255,255,.07);
  --border-hover:    rgba(255,255,255,.13);
  --border-focus:    rgba(99,102,241,.6);

  /* Shadows */
  --shadow-sm:       0 1px 3px rgba(0,0,0,.4);
  --shadow-md:       0 4px 16px rgba(0,0,0,.5);
  --shadow-lg:       0 12px 40px rgba(0,0,0,.6);
  --shadow-glow:     0 0 24px rgba(99,102,241,.25);

  /* Sidebar */
  --sidebar-width:   256px;
  --sidebar-collapsed: 68px;

  /* Topbar */
  --topbar-height:   60px;

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

  /* Transitions */
  --transition:      .2s ease;
  --transition-slow: .35s ease;
}

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

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

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

img, svg { display: block; }

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

.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition-slow);
  min-width: 0;
}

.app-layout.sidebar-collapsed .app-main {
  margin-left: var(--sidebar-collapsed);
}

/* ── Sidebar ───────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: width var(--transition-slow), transform var(--transition-slow);
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.1rem 1rem;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-height);
  flex-shrink: 0;
}

.brand-logo { flex-shrink: 0; }

.brand-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.brand-name {
  display: block;
  font-size: .9rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-version {
  display: block;
  font-size: .7rem;
  color: var(--text-muted);
  margin-top: .1rem;
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: .4rem;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem .75rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.nav-section { margin-bottom: 1.25rem; }

.nav-section-title {
  display: block;
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding: 0 .5rem;
  margin-bottom: .4rem;
  white-space: nowrap;
  overflow: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .6rem .75rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: .875rem;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
  overflow: hidden;
  margin-bottom: .1rem;
  position: relative;
}

.nav-item:hover {
  background: var(--primary-light);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}

.nav-icon { flex-shrink: 0; }
.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: .85rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-shrink: 0;
}

.sidebar-avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; overflow: hidden; }
.sidebar-user-name  { display: block; font-size: .8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role  { display: block; font-size: .7rem; color: var(--text-muted); text-transform: capitalize; }

.sidebar-logout {
  color: var(--text-muted);
  padding: .4rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: color var(--transition);
  flex-shrink: 0;
}

.sidebar-logout:hover { color: var(--danger); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 199;
  backdrop-filter: blur(2px);
}

/* Collapsed sidebar */
.app-layout.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed); }
.app-layout.sidebar-collapsed .brand-text,
.app-layout.sidebar-collapsed .nav-label,
.app-layout.sidebar-collapsed .nav-section-title,
.app-layout.sidebar-collapsed .sidebar-user-info,
.app-layout.sidebar-collapsed .sidebar-logout { display: none; }
.app-layout.sidebar-collapsed .nav-item { justify-content: center; padding: .65rem; }
.app-layout.sidebar-collapsed .sidebar-footer { justify-content: center; }

/* ── Topbar ────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-height);
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  gap: 1rem;
  flex-shrink: 0;
}

.topbar-left { display: flex; align-items: center; gap: .75rem; }
.topbar-right { display: flex; align-items: center; gap: .5rem; }

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .4rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.sidebar-toggle:hover { background: var(--primary-light); color: var(--primary); }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .82rem;
  color: var(--text-muted);
}

.breadcrumb-home { display: flex; align-items: center; }
.breadcrumb-sep  { color: var(--text-muted); }
.breadcrumb-current { color: var(--text-secondary); font-weight: 500; }

.topbar-clock {
  font-size: .8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  display: none;
}

@media (min-width: 768px) { .topbar-clock { display: block; } }

.topbar-icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .45rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.topbar-icon-btn:hover { background: var(--primary-light); color: var(--primary); }

/* User menu */
.user-menu { position: relative; }

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: .6rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: .35rem .75rem .35rem .4rem;
  cursor: pointer;
  transition: all var(--transition);
}

.user-menu-trigger:hover { border-color: var(--border-hover); background: var(--primary-light); }

.user-avatar {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  font-size: .78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-info { display: none; }
@media (min-width: 640px) { .user-info { display: block; text-align: left; } }
.user-name { display: block; font-size: .82rem; font-weight: 600; color: var(--text-primary); line-height: 1.2; }
.user-role { display: block; font-size: .7rem; color: var(--text-muted); text-transform: capitalize; }
.user-chevron { color: var(--text-muted); transition: transform var(--transition); }
.user-menu-trigger[aria-expanded="true"] .user-chevron { transform: rotate(180deg); }

.user-dropdown {
  position: absolute;
  top: calc(100% + .5rem);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  z-index: 500;
  animation: dropIn .2s ease both;
}

@keyframes dropIn {
  from { opacity:0; transform: translateY(-8px) scale(.97); }
  to   { opacity:1; transform: translateY(0) scale(1); }
}

.dropdown-header { padding: .9rem 1rem; }
.dropdown-name   { font-size: .85rem; font-weight: 600; }
.dropdown-email  { font-size: .75rem; color: var(--text-muted); margin-top: .15rem; }
.dropdown-divider{ border: none; border-top: 1px solid var(--border); margin: 0; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .7rem 1rem;
  font-size: .85rem;
  color: var(--text-secondary);
  transition: all var(--transition);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.dropdown-item:hover { background: var(--primary-light); color: var(--text-primary); }
.dropdown-item-danger:hover { background: var(--danger-light); color: var(--danger); }

/* ── Page Content ──────────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 1.75rem 1.5rem;
  max-width: 100%;
  position: relative;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.page-subtitle {
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: .25rem;
}

.page-actions { display: flex; gap: .6rem; flex-wrap: wrap; }

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

.card:hover { border-color: var(--border-hover); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
  flex-wrap: wrap;
}

.card-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: .5rem;
}

.card-title svg { color: var(--primary); }
.card-body  { padding: 1.25rem; }
.card-footer{ padding: 1rem 1.25rem; border-top: 1px solid var(--border); }

/* Stat / KPI cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 70px; height: 70px;
  border-radius: 50%;
  opacity: .06;
  transform: translate(20px, -20px);
}

.stat-card.primary::before { background: var(--primary); }
.stat-card.success::before { background: var(--success); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.danger::before  { background: var(--danger);  }
.stat-card.info::before    { background: var(--info);    }

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

.stat-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-card.primary .stat-icon { background: var(--primary-light); color: var(--primary); }
.stat-card.success .stat-icon { background: var(--success-light); color: var(--success); }
.stat-card.warning .stat-icon { background: var(--warning-light); color: var(--warning); }
.stat-card.danger  .stat-icon { background: var(--danger-light);  color: var(--danger);  }
.stat-card.info    .stat-icon { background: var(--info-light);    color: var(--info);    }

.stat-label { font-size: .78rem; color: var(--text-muted); font-weight: 500; }

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-change {
  font-size: .75rem;
  display: flex;
  align-items: center;
  gap: .3rem;
}

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

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: .85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
  line-height: 1.4;
}

.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { flex-shrink: 0; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); box-shadow: var(--shadow-glow); }

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.btn-success:hover:not(:disabled) { background: #059669; border-color: #059669; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) { background: #dc2626; border-color: #dc2626; }

.btn-warning {
  background: var(--warning);
  color: #fff;
  border-color: var(--warning);
}
.btn-warning:hover:not(:disabled) { background: #d97706; }

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

.btn-icon {
  padding: .5rem;
  border-radius: var(--radius-md);
}

.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: .95rem; }

/* ── Forms ─────────────────────────────────────────────────────── */
.form-group  { margin-bottom: 1.1rem; }
.form-row    { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3  { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }

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

.required::after { content: ' *'; color: var(--danger); }

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: .65rem .9rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: .875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

.form-control::placeholder { color: var(--text-placeholder); }
.form-control:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.form-control:disabled { opacity: .5; cursor: not-allowed; }

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .8rem center;
  padding-right: 2.2rem;
}

select.form-control option { background: var(--bg-card); }

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

.form-hint { font-size: .75rem; color: var(--text-muted); margin-top: .3rem; }
.form-error{ font-size: .75rem; color: var(--danger);      margin-top: .3rem; }

/* Input group */
.input-group { position: relative; display: flex; }
.input-group .form-control { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.input-group .input-group-text {
  display: flex; align-items: center; padding: 0 .9rem;
  background: var(--bg-input); border: 1px solid var(--border);
  border-left: none; border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-muted); font-size: .85rem; white-space: nowrap;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

thead { background: rgba(255,255,255,.03); }

th {
  padding: .8rem 1rem;
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: .8rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }

.table-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.table-empty svg { margin: 0 auto .75rem; opacity: .3; }

/* ── Badges ────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .6rem;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger  { background: var(--danger-light);  color: var(--danger);  }
.badge-info    { background: var(--info-light);    color: var(--info);    }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-muted   { background: rgba(255,255,255,.06); color: var(--text-muted); }

/* ── Alerts ────────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .85rem 1rem;
  border-radius: var(--radius-md);
  font-size: .875rem;
  margin-bottom: 1rem;
}

.alert svg { flex-shrink: 0; }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid rgba(16,185,129,.25); }
.alert-warning { background: var(--warning-light); color: var(--warning); border: 1px solid rgba(245,158,11,.25); }
.alert-danger  { background: var(--danger-light);  color: var(--danger);  border: 1px solid rgba(239,68,68,.25);  }
.alert-info    { background: var(--info-light);    color: var(--info);    border: 1px solid rgba(6,182,212,.25);   }

/* ── Modal ─────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn .2s ease both;
}

@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

.modal {
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn .25s ease both;
}

.modal-sm { max-width: 400px; }
.modal-lg { max-width: 780px; }
.modal-xl { max-width: 960px; }

@keyframes modalIn {
  from { opacity:0; transform: translateY(20px) scale(.96); }
  to   { opacity:1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title { font-size: 1rem; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: .2rem .4rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.modal-close:hover { color: var(--danger); background: var(--danger-light); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .6rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── Toast Notifications ───────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: .85rem 1rem;
  min-width: 280px;
  max-width: 380px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: flex-start;
  gap: .7rem;
  pointer-events: all;
  animation: slideInRight .3s ease both;
}

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

.toast.removing { animation: slideOutRight .3s ease forwards; }

@keyframes slideOutRight {
  to { opacity:0; transform: translateX(40px); }
}

.toast-icon { flex-shrink: 0; margin-top: .1rem; }
.toast-content { flex: 1; }
.toast-title   { font-size: .85rem; font-weight: 600; }
.toast-message { font-size: .8rem; color: var(--text-muted); margin-top: .1rem; }
.toast-close   { background:none; border:none; color:var(--text-muted); cursor:pointer; padding:.2rem; }

.toast-success .toast-icon { color: var(--success); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-danger  .toast-icon { color: var(--danger);  }
.toast-info    .toast-icon { color: var(--info);    }

/* ── Search & Filters ──────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}

.search-box .search-icon {
  position: absolute;
  left: .75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-box .form-control { padding-left: 2.4rem; }

/* ── Pagination ────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .9rem 1.25rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: .75rem;
}

.page-info { font-size: .8rem; color: var(--text-muted); }

.page-btns { display: flex; gap: .35rem; }

.page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 .5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  font-weight: 500;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.page-btn:hover:not(:disabled) { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: .3; cursor: not-allowed; }

/* ── Loading States ────────────────────────────────────────────── */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--text-muted);
}

.spin {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

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

/* Skeleton loader */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: skeleton 1.5s ease infinite;
  border-radius: var(--radius-sm);
}

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

/* ── Pipeline (Leads Kanban) ───────────────────────────────────── */
.pipeline {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  min-height: 400px;
}

.pipeline-col {
  flex: 0 0 240px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.pipeline-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .25rem;
}

.pipeline-col-title {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.pipeline-count {
  font-size: .72rem;
  color: var(--text-muted);
}

.lead-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: .85rem;
  cursor: pointer;
  transition: all var(--transition);
}

.lead-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.lead-card-name  { font-size: .85rem; font-weight: 600; margin-bottom: .25rem; }
.lead-card-company { font-size: .75rem; color: var(--text-muted); }
.lead-card-value { font-size: .78rem; color: var(--success); margin-top: .5rem; font-weight: 600; }

/* ── Charts Container ──────────────────────────────────────────── */
.chart-wrap {
  position: relative;
  width: 100%;
  height: 280px;
}

/* ── Calendar overrides ────────────────────────────────────────── */
.fc { font-family: 'Inter', sans-serif; font-size: .85rem; }
.fc-theme-standard td, .fc-theme-standard th { border-color: var(--border); }
.fc-theme-standard .fc-scrollgrid { border-color: var(--border); }
.fc .fc-daygrid-day-number, .fc .fc-col-header-cell-cushion { color: var(--text-secondary); }
.fc .fc-toolbar-title { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.fc .fc-button-primary {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  border-radius: var(--radius-sm) !important;
  font-size: .8rem !important;
}
.fc .fc-button-primary:not(:disabled):active,
.fc .fc-button-primary.fc-button-active { background: var(--primary-hover) !important; }
.fc-daygrid-body { background: var(--bg-card); }
.fc-day-today    { background: var(--primary-light) !important; }

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

/* ── Utilities ─────────────────────────────────────────────────── */
.text-muted   { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger  { color: var(--danger);  }
.text-sm      { font-size: .82rem; }
.text-xs      { font-size: .75rem; }
.text-bold    { font-weight: 700; }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.d-flex       { display: flex; }
.align-center { align-items: center; }
.gap-1        { gap: .5rem; }
.gap-2        { gap: 1rem; }
.mt-1         { margin-top: .5rem; }
.mt-2         { margin-top: 1rem; }
.mb-1         { margin-bottom: .5rem; }
.mb-2         { margin-bottom: 1rem; }
.w-full       { width: 100%; }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-width: 240px; }
  .form-row-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
  }

  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: flex; }
  .sidebar-backdrop.open { display: block; }

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

  .page-content { padding: 1.25rem 1rem; }

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

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

  .pipeline { flex-direction: column; }
  .pipeline-col { flex: none; }

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

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .modal { margin: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .modal-overlay { align-items: flex-end; padding: 0; }
}
