/* =====================================================
   NEXENTORA ADMIN PANEL — DESIGN SYSTEM
   Premium SaaS Dark Theme
   ===================================================== */

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

/* ── CSS Variables ── */
:root {
  /* Colors */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #fcfdfe;
  --bg-input: #ffffff;
  --bg-sidebar: #0f172a; /* Keeping sidebar dark for high contrast (Modern Look) */
  --bg-topbar: rgba(255, 255, 255, 0.9);

  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-white: #1e293b; /* In light mode, this maps to dark text for readability */

  --border-color: #e2e8f0;
  --border-light: #f1f5f9;
  --divider: rgba(0, 0, 0, 0.05);

  /* Accent Colors */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #3b82f6;
  --primary-bg: rgba(37, 99, 235, 0.05);

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.08);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.08);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.08);
  --info: #06b6d4;
  --info-bg: rgba(6, 182, 212, 0.08);
  --purple: #8b5cf6;
  --purple-bg: rgba(139, 92, 246, 0.08);
  --secondary: #64748b;
  --secondary-bg: rgba(100, 116, 139, 0.08);

  --whatsapp: #25d366;
  --whatsapp-bg: rgba(37, 211, 102, 0.08);

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #2563eb, #7c3aed);
  --gradient-success: linear-gradient(135deg, #10b981, #06b6d4);
  --gradient-danger: linear-gradient(135deg, #ef4444, #f97316);
  --gradient-info: linear-gradient(135deg, #06b6d4, #2563eb);

  /* Spacing */
  --sidebar-width: 260px;
  --sidebar-collapsed: 70px;
  --topbar-height: 64px;

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

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 12px rgba(0,0,0,0.03);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.06);
  --shadow-xl: 0 16px 48px rgba(0,0,0,0.1);
  --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.2);

  /* Transitions */
  --transition: all 0.2s ease;
  --transition-slow: all 0.3s ease;
}

[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #111827;
  --bg-card: #1e293b;
  --bg-card-hover: #1e294b;
  --bg-input: #0f172a;
  --bg-topbar: rgba(15, 23, 42, 0.9);
  
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-white: #f8fafc; /* In dark mode, text-white maps to light text */
  
  --border-color: #334155;
  --border-light: #1e293b;
  --divider: rgba(255, 255, 255, 0.05);

  --shadow: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.6);
  --bg-sidebar: #020617;
}

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

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

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

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

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 10px; }

/* ── Form Inputs ── */
.form-control {
  width: 100%;
  background: var(--bg-input, #fff);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  transition: var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}
.form-control::placeholder { color: var(--text-muted); }

.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-group { margin-bottom: 16px; }

/* Fix dropdown options for dark sidebar / dark theme */
select option,
.form-control option {
  background-color: var(--bg-card, #fff);
  color: var(--text-primary, #1e293b);
}
[data-theme="dark"] select option,
[data-theme="dark"] .form-control option {
  background-color: #1e293b;
  color: #f1f5f9;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

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

.admin-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding-top: var(--topbar-height);
  min-height: 100vh;
  transition: var(--transition-slow);
}

.admin-content.sidebar-collapsed {
  margin-left: var(--sidebar-collapsed);
}

.page-content {
  padding: 24px;
}

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

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-color);
  min-height: var(--topbar-height);
}

.sidebar-brand img {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.sidebar-brand-text h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #f8fafc; /* Always white — sidebar is always dark */
  white-space: nowrap;
  letter-spacing: -0.02em;
}

.sidebar-brand-text span {
  font-size: 0.65rem;
  color: #94a3b8; /* Explicit muted for dark sidebar */
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Sidebar nav text must also be explicit for always-dark sidebar */
.sidebar .nav-link {
  color: #94a3b8;
}
.sidebar .nav-link:hover {
  color: #f1f5f9;
}
.sidebar .nav-link.active {
  color: var(--primary-light);
}
.sidebar .nav-label {
  color: #64748b;
}

.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-arrow,
.sidebar.collapsed .nav-children { display: none; }

.sidebar.collapsed .sidebar-brand { justify-content: center; padding: 16px 8px; }
.sidebar.collapsed .nav-link { justify-content: center; padding: 12px 0; }
.sidebar.collapsed .nav-link .nav-icon { margin: 0; font-size: 1.1rem; }

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

.sidebar-nav::-webkit-scrollbar { width: 0; }

.nav-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 16px 18px 6px;
}

.nav-item { position: relative; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 450;
  transition: var(--transition);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
  position: relative;
}

.nav-link:hover {
  color: var(--text-white);
  background: rgba(99, 102, 241, 0.06);
}

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

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

.nav-icon {
  width: 20px;
  text-align: center;
  font-size: 0.9rem;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-text { flex: 1; white-space: nowrap; }

.nav-arrow {
  font-size: 0.65rem;
  transition: var(--transition);
  opacity: 0.5;
}

.nav-item.open > .nav-link .nav-arrow { transform: rotate(90deg); }

.nav-children {
  display: none;
  padding: 2px 0;
}

.nav-item.open > .nav-children { display: block; }

.nav-children .nav-link {
  padding: 7px 18px 7px 48px;
  font-size: 0.8rem;
  font-weight: 400;
}

.nav-children .nav-link::before { display: none; }

.nav-children .nav-link.active {
  background: transparent;
  color: var(--primary-light);
  font-weight: 500;
}

/* ── Topbar ── */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: var(--bg-topbar);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 999;
  transition: var(--transition-slow);
}

.topbar.sidebar-collapsed { left: var(--sidebar-collapsed); }

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.15rem;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.sidebar-toggle:hover { color: var(--text-white); background: var(--bg-tertiary); }

.topbar-search {
  position: relative;
}

.topbar-search input {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 14px 8px 36px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  width: 260px;
  transition: var(--transition);
  font-family: inherit;
}

.topbar-search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
  width: 320px;
}

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

.topbar-search i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.82rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-btn {
  position: relative;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.05rem;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius);
  transition: var(--transition);
}

.topbar-btn:hover { color: var(--text-white); background: var(--bg-secondary); }

.topbar-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  background: var(--danger);
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.topbar-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 4px 4px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.topbar-profile:hover { background: var(--bg-secondary); }

.topbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.topbar-user-info { line-height: 1.3; }
.topbar-user-name { font-size: 0.82rem; font-weight: 600; color: var(--text-primary); }
.topbar-user-role { font-size: 0.68rem; color: var(--text-muted); }

/* Profile Dropdown */
.profile-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 200px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 1001;
}

.profile-dropdown.show { display: block; }

.profile-dropdown a,
.profile-dropdown button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: var(--text-secondary);
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  border: none;
  background: none;
  width: 100%;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}

.profile-dropdown a:hover,
.profile-dropdown button:hover { background: var(--bg-tertiary); color: var(--text-white); }

.profile-dropdown .divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}

.profile-dropdown .text-danger { color: var(--danger) !important; }

/* ── Page Header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-white);
  letter-spacing: -0.02em;
}

.page-header p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 2px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary-light); }
.breadcrumb .separator { opacity: 0.4; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: var(--transition);
}

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--divider);
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-white);
}

.card-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  opacity: 0.04;
  transform: translate(30%, -30%);
}

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

.stat-card.primary { border-left: 3px solid var(--primary); }
.stat-card.primary::after { background: var(--primary); }
.stat-card.success { border-left: 3px solid var(--success); }
.stat-card.success::after { background: var(--success); }
.stat-card.warning { border-left: 3px solid var(--warning); }
.stat-card.warning::after { background: var(--warning); }
.stat-card.danger { border-left: 3px solid var(--danger); }
.stat-card.danger::after { background: var(--danger); }
.stat-card.info { border-left: 3px solid var(--info); }
.stat-card.info::after { background: var(--info); }
.stat-card.purple { border-left: 3px solid var(--purple); }
.stat-card.purple::after { background: var(--purple); }

.stat-info h3 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-white);
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-info p {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-info .stat-change {
  font-size: 0.72rem;
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

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

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

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

/* ── Grid System ── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }

/* ── Tables ── */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 12px;
}

.table-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-white);
}

.table-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.table-responsive {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background: var(--bg-primary);
  padding: 10px 16px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-color);
}

tbody td {
  padding: 12px 16px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--divider);
  vertical-align: middle;
}

tbody tr:hover { background: rgba(99,102,241,0.03); }
tbody tr:last-child td { border-bottom: none; }

.table-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.table-user-info .name { font-weight: 500; color: var(--text-white); font-size: 0.82rem; }
.table-user-info .sub { font-size: 0.72rem; color: var(--text-muted); }

.table-actions {
  display: flex;
  gap: 4px;
}

.table-actions .action-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: none;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  transition: var(--transition);
}

.table-actions .action-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.table-actions .action-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }

/* Standalone action-btn (outside .table-actions) */
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  background: none;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  transition: var(--transition);
  text-decoration: none;
}
.action-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.action-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-primary { background: var(--primary-bg); color: var(--primary-light); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-secondary { background: var(--secondary-bg); color: var(--secondary); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 550;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-sm { padding: 6px 12px; font-size: 0.75rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 12px 24px; font-size: 0.9rem; }

.btn-primary { background: var(--gradient-primary); color: white; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-glow); color: white; }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; color: white; }

.btn-warning { background: var(--warning); color: #1e293b; }
.btn-warning:hover { background: #d97706; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; color: white; }

.btn-info { background: var(--info); color: white; }
.btn-info:hover { background: #0891b2; color: white; }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary-light); background: var(--primary-bg); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-tertiary); color: var(--text-white); }

.btn-whatsapp { background: var(--whatsapp); color: white; }
.btn-whatsapp:hover { background: #1fba59; color: white; }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
}

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

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

.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 550;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-family: inherit;
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

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

select.form-control {
  appearance: none;
  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%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

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

.form-text {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-error {
  font-size: 0.72rem;
  color: var(--danger);
  margin-top: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.form-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.form-select-sm {
  padding: 6px 30px 6px 10px;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  width: 40px;
  height: 22px;
  cursor: pointer;
}

.toggle-switch input { display: none; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-tertiary);
  border-radius: 22px;
  transition: var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  transition: var(--transition);
}

.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

/* Search Input Filter */
.search-input {
  position: relative;
}

.search-input input {
  padding-left: 34px;
}

.search-input i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* ── Modals ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.show { display: flex; }

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalSlideIn 0.25s ease;
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-white);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.modal-close:hover { color: var(--text-white); background: var(--bg-tertiary); }

.modal-body { padding: 24px; }

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

/* ── Toast / Alerts ── */
.toast-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 420px;
  animation: toastSlideIn 0.3s ease;
  font-size: 0.82rem;
}

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

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

.toast-icon { font-size: 1rem; }
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--info); }

.toast-content { flex: 1; color: var(--text-primary); }

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  font-size: 0.9rem;
}

/* Alert Inline */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.82rem;
  margin-bottom: 16px;
}

.alert-success { background: var(--success-bg); border: 1px solid rgba(16,185,129,0.2); color: var(--success); }
.alert-error { background: var(--danger-bg); border: 1px solid rgba(239,68,68,0.2); color: var(--danger); }
.alert-warning { background: var(--warning-bg); border: 1px solid rgba(245,158,11,0.2); color: var(--warning); }
.alert-info { background: var(--info-bg); border: 1px solid rgba(6,182,212,0.2); color: var(--info); }

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

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

.pagination-links {
  display: flex;
  gap: 4px;
}

.pagination-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  transition: var(--transition);
  text-decoration: none;
}

.pagination-btn:hover { background: var(--bg-tertiary); color: var(--text-white); }
.pagination-btn.active { background: var(--primary); color: white; }

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
  overflow-x: auto;
}

.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
  white-space: nowrap;
  font-family: inherit;
}

.tab-btn:hover { color: var(--text-white); }

.tab-btn.active {
  color: var(--primary-light);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
}

.empty-state i {
  font-size: 3rem;
  color: var(--text-muted);
  opacity: 0.4;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ── Activity Timeline ── */
.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-color);
}

.timeline-item {
  position: relative;
  padding-bottom: 18px;
}

.timeline-item:last-child { padding-bottom: 0; }

.timeline-dot {
  position: absolute;
  left: -20px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 2px solid var(--primary);
}

.timeline-dot.success { border-color: var(--success); }
.timeline-dot.warning { border-color: var(--warning); }
.timeline-dot.danger { border-color: var(--danger); }

.timeline-content h4 {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.timeline-content p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Progress Bar ── */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 6px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 6px;
  background: var(--gradient-primary);
  transition: width 0.5s ease;
}

.progress-fill.success { background: var(--gradient-success); }

.progress-text {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
}

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

.chart-container-sm { height: 200px; }

/* ── Pipeline / Kanban ── */
.pipeline,
.pipeline-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.pipeline-column,
.pipeline-col {
  min-width: 240px;
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 14px;
  overflow: hidden;
}

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

.pipeline-header h4 {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pipeline-count {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
}

.pipeline-body {
  padding: 8px;
  min-height: 100px;
}

.pipeline-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: var(--transition);
}

.pipeline-card:hover { border-color: var(--primary); background: var(--bg-card-hover); }

.pipeline-card h5 {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-white);
  margin-bottom: 6px;
}

.pipeline-card p {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.pipeline-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

/* ── Confirm Dialog ── */
.confirm-dialog .modal {
  max-width: 400px;
  text-align: center;
}

.confirm-dialog .confirm-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--danger-bg);
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin: 0 auto 16px;
}

.confirm-dialog h3 { margin-bottom: 8px; }
.confirm-dialog p { color: var(--text-muted); }

/* ── Flex Utilities ── */
.d-flex { display: flex; }
.d-grid { display: grid; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-col { flex-direction: column; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-5 { gap: 20px; }

/* ── Spacing Utilities ── */
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 24px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 24px; }

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary-light); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-white { color: var(--text-white) !important; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fs-sm { font-size: 0.75rem; }
.fs-lg { font-size: 1.1rem; }

/* ── Quick Actions ── */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 500;
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
  text-decoration: none;
}

.quick-action i { font-size: 1.2rem; }
.quick-action:hover { border-color: var(--primary); color: var(--primary-light); background: var(--primary-bg); }

/* ── Login Page ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(99,102,241,0.08), transparent 70%);
  border-radius: 50%;
}

.login-page::after {
  content: '';
  position: absolute;
  bottom: -30%;
  right: -10%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(139,92,246,0.06), transparent 70%);
  border-radius: 50%;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 36px;
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow-xl);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo img {
  width: 50px;
  height: 50px;
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.login-logo h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-white);
  margin-bottom: 4px;
}

.login-logo p {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.login-card .btn-primary {
  width: 100%;
  justify-content: center;
  padding: 12px;
  font-size: 0.88rem;
}

/* ── Mobile Responsive ── */
.mobile-nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
}

/* Tablet < 1024px */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar-search input { width: 180px; }
  .topbar-search input:focus { width: 220px; }
}

/* Mobile < 768px */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 1001;
    width: var(--sidebar-width);
  }

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

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

  .admin-content {
    margin-left: 0 !important;
  }

  .topbar {
    left: 0 !important;
  }

  .mobile-nav-toggle { display: block; }

  .page-content { padding: 16px; }
  .page-header { flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; }

  .stat-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

  .table-header { flex-direction: column; align-items: flex-start; }
  .table-filters { width: 100%; }

  .topbar-search { display: none; }
  .topbar-user-info { display: none; }

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

  .pipeline { flex-direction: column; }
  .pipeline-column { min-width: 100%; }

  .modal { margin: 10px; max-width: calc(100% - 20px); }

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

  .tabs { gap: 0; }
  .tab-btn { padding: 8px 12px; font-size: 0.75rem; }

  .pagination { flex-direction: column; align-items: center; }
}

/* Small Mobile < 480px */
@media (max-width: 480px) {
  .login-card { padding: 24px; margin: 10px; }
  .stat-card { padding: 14px; }
  .stat-info h3 { font-size: 1.3rem; }
  .card { padding: 14px; }
  .btn-group { flex-direction: column; }
  .btn-group .btn { width: 100%; justify-content: center; }
}

/* Print */
@media print {
  .sidebar, .topbar, .toast-container { display: none !important; }
  .admin-content { margin-left: 0 !important; padding-top: 0 !important; }
  .page-content { padding: 0 !important; }
  body { background: white; color: #1e293b; }
  .card { border: 1px solid #e2e8f0; }
}
