/* ═══════════════════════════════════════════════════════════
   Lil Ballerine CRM — Design System v2.0
   Modern UI with animations, glassmorphism, smooth transitions
   ═══════════════════════════════════════════════════════════ */

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

:root {
  --primary: #667eea;
  --primary-dark: #5a6fd6;
  --secondary: #764ba2;
  --accent: #f093fb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --bg: #f0f2f8;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --sidebar-w: 260px;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 4px 16px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.06);
  --shadow-glow: 0 8px 32px rgba(102,126,234,.35);
  --transition: .2s cubic-bezier(.4,0,.2,1);
  --transition-slow: .4s cubic-bezier(.4,0,.2,1);
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Inline Tooltips ─────────────────────────────────────── */
.lb-label-with-tip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.lb-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #e0e7ff;
  color: #4338ca;
  font-size: 11px;
  font-weight: 700;
  cursor: help;
  user-select: none;
  border: 1px solid #c7d2fe;
  vertical-align: middle;
}

.lb-tip:focus-visible {
  outline: 2px solid #818cf8;
  outline-offset: 2px;
}

.lb-tip::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%) translateY(4px);
  width: min(320px, 80vw);
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.96);
  color: #fff;
  font-size: 12px;
  line-height: 1.45;
  box-shadow: 0 12px 24px rgba(15, 23, 42, .18);
  opacity: 0;
  pointer-events: none;
  white-space: normal;
  text-align: left;
  z-index: 3000;
  transition: opacity .18s ease, transform .18s ease;
}

.lb-tip::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  transform: translateX(-50%);
  border-width: 6px 6px 0 6px;
  border-style: solid;
  border-color: rgba(15, 23, 42, 0.96) transparent transparent transparent;
  opacity: 0;
  transition: opacity .18s ease;
}

.lb-tip:hover::after,
.lb-tip:hover::before,
.lb-tip:focus-visible::after,
.lb-tip:focus-visible::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  left: 0; top: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  z-index: 1000;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition-slow), width var(--transition-slow);
  display: flex;
  flex-direction: column;
}

.sidebar::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(255,255,255,.12) 0%, transparent 70%);
  pointer-events: none;
}

.sidebar::after {
  content: '';
  position: absolute;
  bottom: 80px; left: -40px;
  width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(255,255,255,.08) 0%, transparent 70%);
  pointer-events: none;
}

/* Sidebar Header */
.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  position: relative;
  z-index: 1;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
  min-height: 72px;
}

.sidebar-brand-logo {
  display: block;
  width: min(218px, 100%);
  max-height: 78px;
  object-fit: contain;
  filter: drop-shadow(0 8px 18px rgba(8, 15, 40, .18));
}

.sidebar-logo-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(102,126,234,.4);
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.3px;
  background: linear-gradient(135deg, #fff 0%, rgba(255,255,255,.75) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-subtitle {
  font-size: 11px;
  color: rgba(255,255,255,.45);
  letter-spacing: .3px;
  padding-left: 48px;
}

/* Branch badge */
.sidebar-branch {
  margin-top: 12px;
  padding: 8px 12px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  font-size: 12px;
  color: rgba(255,255,255,.7);
  display: flex; align-items: center; gap: 6px;
}

.sidebar-branch-dot {
  width: 7px; height: 7px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--success);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .6; transform: scale(.85); }
}

/* ── Sidebar Menu ─────────────────────────────────────────── */
.sidebar-menu {
  padding: 12px 0;
  flex: 1;
  position: relative;
  z-index: 1;
}

.menu-section { margin-bottom: 4px; }

.menu-section-title {
  padding: 10px 20px 6px;
  font-size: 10px;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
  font-weight: 700;
  letter-spacing: 1.2px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 10px 20px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  border-radius: 0 10px 10px 0;
  margin: 1px 8px 1px 0;
  position: relative;
  cursor: pointer;
}

.menu-item:hover {
  color: #fff;
  background: rgba(255,255,255,.15);
  border-left-color: rgba(255,255,255,.6);
  transform: translateX(3px);
}

.menu-item.active {
  color: #fff;
  background: rgba(255,255,255,.2);
  border-left-color: #fff;
  font-weight: 600;
}

.menu-item.active::after {
  content: '';
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  width: 6px; height: 6px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(255,255,255,.8);
}

.menu-item-icon {
  font-size: 16px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
  transition: transform var(--transition);
}

.menu-item:hover .menu-item-icon { transform: scale(1.15); }

.menu-item-text { font-size: 13.5px; }

/* Badge on menu item */
.menu-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  animation: badge-pop .3s ease;
}

@keyframes badge-pop {
  0% { transform: scale(0); }
  70% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ── Sidebar User ─────────────────────────────────────────── */
.sidebar-user {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.07);
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 1;
  cursor: pointer;
  transition: background var(--transition);
}

.sidebar-user:hover { background: rgba(255,255,255,.05); }

.sidebar-user-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,.2);
  overflow: hidden;
}

.sidebar-user-avatar img { width: 100%; height: 100%; object-fit: cover; }

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

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

.sidebar-user-role {
  font-size: 11px;
  color: rgba(255,255,255,.4);
}

.sidebar-logout {
  background: none; border: none;
  color: rgba(255,255,255,.35);
  cursor: pointer; font-size: 16px;
  padding: 4px;
  transition: color var(--transition), transform var(--transition);
}

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

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg);
  transition: margin-left var(--transition-slow);
}

/* ── Top Bar ──────────────────────────────────────────────── */
.top-bar {
  background: var(--surface);
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(8px);
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.4px;
}

.top-bar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.top-bar-btn {
  padding: 9px 18px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  transition: all var(--transition);
  box-shadow: 0 2px 8px rgba(102,126,234,.3);
  display: flex; align-items: center; gap: 6px;
}

.top-bar-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

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

.top-bar-btn.secondary {
  background: var(--surface2);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.top-bar-btn.secondary:hover {
  background: var(--border);
  box-shadow: var(--shadow);
}

/* ── Content Container ────────────────────────────────────── */
.content-container { padding: 24px 28px; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.8);
  transition: box-shadow var(--transition), transform var(--transition);
  overflow: hidden;
}

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

.card-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  display: flex; align-items: center; gap: 8px;
}

.card-body { padding: 20px 22px; }

/* Legacy .section compatibility */
.section {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.8);
  padding: 22px;
  margin-bottom: 20px;
  transition: box-shadow var(--transition);
}

.section:hover { box-shadow: var(--shadow-lg); }

.section h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 18px;
  display: flex; align-items: center; gap: 8px;
}

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

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.8);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  border-radius: 0 var(--radius) 0 80px;
  opacity: .08;
  transition: opacity var(--transition);
}

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

.stat-card:hover::before { opacity: .15; }

.stat-card.blue::before  { background: var(--primary); }
.stat-card.green::before { background: var(--success); }
.stat-card.orange::before{ background: var(--warning); }
.stat-card.purple::before{ background: var(--secondary); }
.stat-card.red::before   { background: var(--danger); }

.stat-card-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  margin-bottom: 14px;
}

.stat-card.blue   .stat-card-icon { background: rgba(102,126,234,.12); }
.stat-card.green  .stat-card-icon { background: rgba(16,185,129,.12); }
.stat-card.orange .stat-card-icon { background: rgba(245,158,11,.12); }
.stat-card.purple .stat-card-icon { background: rgba(118,75,162,.12); }
.stat-card.red    .stat-card-icon { background: rgba(239,68,68,.12); }

.stat-card h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 6px;
}

.stat-card .value {
  font-size: 30px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -1px;
  line-height: 1;
  margin-bottom: 8px;
}

.stat-card.blue   .value { color: var(--primary); }
.stat-card.green  .value { color: var(--success); }
.stat-card.orange .value { color: var(--warning); }
.stat-card.purple .value { color: var(--secondary); }
.stat-card.red    .value { color: var(--danger); }

.stat-trend {
  font-size: 12px;
  color: var(--text-light);
  display: flex; align-items: center; gap: 4px;
}

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

/* Animated counter */
@keyframes count-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.stat-card .value { animation: count-up .5s ease both; }
.stat-card:nth-child(2) .value { animation-delay: .1s; }
.stat-card:nth-child(3) .value { animation-delay: .2s; }
.stat-card:nth-child(4) .value { animation-delay: .3s; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px;
  border: none; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13.5px; font-weight: 600;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  box-shadow: 0 2px 8px rgba(102,126,234,.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 2px 8px rgba(16,185,129,.3);
}

.btn-success:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(16,185,129,.4); }

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  box-shadow: 0 2px 8px rgba(239,68,68,.3);
}

.btn-danger:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(239,68,68,.4); }

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

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

.btn-ghost {
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

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

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
}

.badge-success, .badge-active  { background: rgba(16,185,129,.12); color: #059669; }
.badge-warning, .badge-expiring{ background: rgba(245,158,11,.12);  color: #d97706; }
.badge-danger,  .badge-urgent  { background: rgba(239,68,68,.12);   color: #dc2626; }
.badge-info                    { background: rgba(59,130,246,.12);  color: #2563eb; }
.badge-purple                  { background: rgba(118,75,162,.12);  color: #7c3aed; }
.badge-gray                    { background: rgba(100,116,139,.1);  color: #475569; }

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  background: var(--surface2);
  padding: 11px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(102,126,234,.04); }

tbody td {
  padding: 12px 14px;
  color: var(--text);
  vertical-align: middle;
}

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 12.5px; font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: .4px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  font-family: inherit;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(102,126,234,.15);
}

.form-control::placeholder { color: var(--text-light); }

select.form-control { cursor: pointer; }

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

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

.quick-action-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 14px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.quick-action-btn:hover {
  border-color: var(--primary);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  transform: translateY(-4px);
  box-shadow: var(--shadow-glow);
}

.quick-action-icon {
  font-size: 32px;
  transition: transform var(--transition);
}

.quick-action-btn:hover .quick-action-icon { transform: scale(1.15) rotate(-5deg); }

.quick-action-text { font-size: 13px; font-weight: 600; }

/* ── List Items ───────────────────────────────────────────── */
.clients-list { list-style: none; padding: 0; margin: 0; }

.clients-list li {
  padding: 13px 4px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  transition: background var(--transition);
  border-radius: var(--radius-sm);
  gap: 12px;
}

.clients-list li:last-child { border-bottom: none; }
.clients-list li:hover { background: var(--surface2); padding-left: 8px; }

.client-name { font-weight: 600; color: var(--text); font-size: 14px; }
.client-info { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }

/* ── Modals ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,20,40,.55);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fade-in .2s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--surface);
  border-radius: 18px;
  box-shadow: 0 24px 80px rgba(0,0,0,.2);
  width: 100%; max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modal-in .25s cubic-bezier(.34,1.56,.64,1);
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(.92) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.modal-title { font-size: 17px; font-weight: 700; color: var(--text); }

.modal-close {
  width: 32px; height: 32px;
  background: var(--surface2);
  border: none; border-radius: 8px;
  cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  color: var(--text-muted);
}

.modal-close:hover { background: var(--danger); color: #fff; transform: rotate(90deg); }

.modal-body { padding: 22px 24px; }
.modal-footer {
  padding: 16px 24px 22px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
}

/* ── Notifications / Toasts ───────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border-radius: 12px;
  padding: 14px 18px;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary);
  display: flex; align-items: center; gap: 12px;
  min-width: 280px; max-width: 380px;
  pointer-events: all;
  animation: toast-in .3s cubic-bezier(.34,1.56,.64,1);
  font-size: 13.5px;
}

.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(60px) scale(.9); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateX(60px) scale(.9); }
}

.toast.hiding { animation: toast-out .25s ease forwards; }

/* ── Loading States ───────────────────────────────────────── */
.loading {
  text-align: center;
  padding: 32px;
  color: var(--text-light);
  font-size: 13.5px;
}

.skeleton {
  background: linear-gradient(90deg, #f0f2f8 25%, #e8eaf0 50%, #f0f2f8 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}

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

.skeleton-text  { height: 14px; margin-bottom: 8px; }
.skeleton-title { height: 20px; width: 60%; margin-bottom: 12px; }
.skeleton-avatar{ width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; }

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

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

/* ── Page Entrance Animation ──────────────────────────────── */
@keyframes page-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.content-container { animation: page-in .35s ease both; }

/* Stagger children */
.stats-grid > * { animation: page-in .4s ease both; }
.stats-grid > *:nth-child(1) { animation-delay: .05s; }
.stats-grid > *:nth-child(2) { animation-delay: .1s; }
.stats-grid > *:nth-child(3) { animation-delay: .15s; }
.stats-grid > *:nth-child(4) { animation-delay: .2s; }

/* ── Welcome Banner ───────────────────────────────────────── */
.welcome-banner {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 20px;
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-glow);
}

.welcome-banner::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 180px; height: 180px;
  background: rgba(255,255,255,.08);
  border-radius: 50%;
}

.welcome-banner::after {
  content: '';
  position: absolute;
  bottom: -60px; right: 80px;
  width: 140px; height: 140px;
  background: rgba(255,255,255,.05);
  border-radius: 50%;
}

.welcome-banner h2 {
  font-size: 20px; font-weight: 700;
  margin-bottom: 4px;
  position: relative; z-index: 1;
}

.welcome-banner p {
  font-size: 13.5px;
  opacity: .8;
  position: relative; z-index: 1;
}

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

.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.35); }

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

  .sidebar {
    transform: translateX(-260px);
    width: 260px;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 40px rgba(0,0,0,.3);
  }

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

  .content-container { padding: 16px; }

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

  .quick-actions { grid-template-columns: repeat(3, 1fr); }

  .top-bar { padding: 12px 16px; }

  .page-title { font-size: 18px; }
}

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

/* ── Utility ──────────────────────────────────────────────── */
.text-muted  { color: var(--text-muted); }
.text-light  { color: var(--text-light); }
.text-success{ color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning{ color: var(--warning); }
.text-primary{ color: var(--primary); }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Toggle Switch ────────────────────────────────────────── */
.toggle {
  position: relative;
  display: inline-block;
  width: 42px; height: 24px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border);
  border-radius: 24px;
  cursor: pointer;
  transition: background var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 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(18px); }

/* ── Avatar ───────────────────────────────────────────────── */
.avatar {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
}

.avatar-sm  { width: 32px; height: 32px; font-size: 12px; }
.avatar-md  { width: 40px; height: 40px; font-size: 15px; }
.avatar-lg  { width: 52px; height: 52px; font-size: 19px; }
.avatar-xl  { width: 72px; height: 72px; font-size: 26px; }

/* ── Search Input ─────────────────────────────────────────── */
.search-wrap {
  position: relative;
  display: flex; align-items: center;
}

.search-wrap .search-icon {
  position: absolute; left: 12px;
  color: var(--text-light); font-size: 15px;
  pointer-events: none;
}

.search-wrap .form-control { padding-left: 36px; }

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state-icon { font-size: 48px; margin-bottom: 12px; opacity: .5; }
.empty-state-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.empty-state-text  { font-size: 13.5px; }
