/* ============================================
   CRM System - Modern Design System 2024+
   ============================================ */

/* --- CSS Variables --- */
:root {
  --primary: #4a6cf7;
  --primary-dark: #3b5de7;
  --primary-light: #eef2ff;
  --primary-bg: rgba(74, 108, 247, .08);
  --success: #22c55e;
  --success-light: #f0fdf4;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --info: #3b82f6;
  --info-light: #eff6ff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --sidebar-w: 180px;
  --topbar-h: 44px;
  --tabbar-h: 40px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .05);
  --shadow: 0 1px 3px rgba(0, 0, 0, .1), 0 1px 2px rgba(0, 0, 0, .06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -2px rgba(0, 0, 0, .1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, .1), 0 4px 6px -4px rgba(0, 0, 0, .1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, .1), 0 8px 10px -6px rgba(0, 0, 0, .1);
  --transition: all .2s ease;
  --transition-slow: all .3s ease;
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: var(--transition);
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  outline: none;
}

input, select, textarea {
  font-family: inherit;
  font-size: 13px;
  color: var(--gray-800);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 9px 13px;
  outline: none;
  transition: var(--transition);
  width: 100%;
  background: #fff;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 108, 247, .12);
}

input::placeholder, textarea::placeholder {
  color: var(--gray-400);
}

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

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 5px;
  display: block;
  letter-spacing: .01em;
}

::selection {
  background: rgba(74, 108, 247, .2);
  color: var(--gray-900);
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}

/* --- Buttons --- */
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 9px 20px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  letter-spacing: .01em;
  box-shadow: 0 1px 2px rgba(74, 108, 247, .3);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(74, 108, 247, .35);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(74, 108, 247, .3);
}

.btn-outline {
  background: #fff;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 1px 3px rgba(74, 108, 247, .1);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
}

.btn-danger:hover {
  background: #dc2626;
  box-shadow: 0 4px 12px rgba(239, 68, 68, .3);
}

.btn-success {
  background: var(--success);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
}

.btn-success:hover {
  background: #16a34a;
  box-shadow: 0 4px 12px rgba(34, 197, 94, .3);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
  background: #fff;
  color: var(--gray-600);
  font-weight: 500;
  transition: var(--transition);
}

.btn-sm:hover {
  background: var(--gray-100);
  border-color: var(--gray-300);
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  background: #fff;
  color: var(--gray-600);
  transition: var(--transition);
  flex-shrink: 0;
}

.btn-icon:hover {
  background: var(--gray-100);
  border-color: var(--gray-300);
  color: var(--primary);
}

.btn-block {
  width: 100%;
  justify-content: center;
}

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

/* --- Login Pages --- */
.page {
  display: none;
}

.page.active {
  display: flex;
}

#login-page,
#forgot-password-page,
#register-page {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  position: relative;
  overflow: hidden;
}

#login-page::before,
#forgot-password-page::before,
#register-page::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .06);
  top: -200px;
  right: -100px;
}

#login-page::after,
#forgot-password-page::after,
#register-page::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .04);
  bottom: -100px;
  left: -100px;
}

.login-box {
  background: #fff;
  padding: 44px 40px;
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, .25);
  width: 100%;
  max-width: 400px;
  animation: fadeUp .5s cubic-bezier(.4, 0, .2, 1);
  position: relative;
  z-index: 1;
}

.login-logo {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  text-align: center;
  letter-spacing: -.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.login-logo-img {
  width: 56px;
  height: 56px;
}

.login-subtitle {
  text-align: center;
  color: var(--gray-500);
  margin: 8px 0 32px;
  font-size: 13px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-form input {
  padding: 11px 14px;
  font-size: 14px;
  border-radius: 10px;
}

.login-form .btn-primary {
  padding: 12px 20px;
  font-size: 14px;
  border-radius: 10px;
  margin-top: 4px;
}

.login-links {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  font-size: 13px;
}

.login-links a {
  color: var(--primary);
  font-weight: 500;
  cursor: pointer;
}

.login-links a:hover {
  color: var(--primary-dark);
}

.forgot-tab {
  flex: 1;
  text-align: center;
  padding: 10px 0;
  cursor: pointer;
  font-size: 14px;
  color: #999;
  border-bottom: 2px solid transparent;
  transition: all .2s;
}
.forgot-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- App Layout --- */
#app.active {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--gray-900);
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width .3s cubic-bezier(.4, 0, .2, 1);
  overflow: hidden;
}
.sidebar.collapsed {
  width: 60px;
}
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-item span:not(.nav-icon),
.sidebar.collapsed .nav-group-header span:not(.nav-icon),
.sidebar.collapsed .nav-arrow,
.sidebar.collapsed .nav-group-body {
  display: none !important;
}
.sidebar.collapsed .sidebar-brand {
  justify-content: center;
  padding: 0;
}
.sidebar.collapsed .sidebar-brand .brand-icon {
  margin: 0;
}
.sidebar.collapsed .nav-item,
.sidebar.collapsed .nav-group-header {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
  margin: 1px 4px;
}
.sidebar.collapsed .nav-icon {
  margin: 0;
}
.sidebar.collapsed .sidebar-footer {
  padding: 10px 4px;
}
.sidebar.collapsed .sidebar-toggle-btn svg {
  transform: rotate(180deg);
}
.sidebar.collapsed .nav-item,
.sidebar.collapsed .nav-group-header {
  position: relative;
}
.sidebar.collapsed .nav-item:hover,
.sidebar.collapsed .nav-group-header:hover {
  background: rgba(255, 255, 255, .15);
}
.sidebar-tooltip {
  position: fixed;
  left: 68px;
  background: #1e293b;
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  white-space: nowrap;
  z-index: 10000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  pointer-events: none;
  display: none;
}
.main-content.sidebar-collapsed {
  margin-left: 60px;
}

.sidebar-brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  flex-shrink: 0;
}

.brand-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-text {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  letter-spacing: -.3px;
}

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

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .12);
  border-radius: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  color: rgba(255, 255, 255, .65);
  font-size: 13px;
  transition: var(--transition);
  cursor: pointer;
  margin: 1px 6px;
  border-radius: var(--radius);
}

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

.nav-item.active {
  background: var(--primary);
  color: #fff;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(74, 108, 247, .35);
}

.nav-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  border-radius: 6px;
  background: rgba(255,255,255,0.1);
  padding: 4px;
  box-sizing: border-box;
}
.nav-icon svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.nav-group {
  margin: 2px 0;
}

.nav-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  color: rgba(255, 255, 255, .65);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  margin: 1px 6px;
  border-radius: var(--radius);
}

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

.nav-arrow {
  position: absolute;
  right: 10px;
  transition: transform .25s cubic-bezier(.4, 0, .2, 1);
  font-size: 10px;
}

.nav-group.open .nav-arrow {
  transform: rotate(90deg);
}

.nav-group-body {
  display: none;
  padding-left: 12px;
}

.nav-group.open .nav-group-body {
  display: block;
}

.nav-sub-item {
  display: block;
  padding: 6px 12px 6px 36px;
  color: rgba(255, 255, 255, .5);
  font-size: 12.5px;
  transition: var(--transition);
  border-radius: var(--radius);
  margin: 1px 6px;
}

.nav-sub-item:hover {
  background: rgba(255, 255, 255, .08);
  color: rgba(255, 255, 255, .9);
}

.nav-sub-item.active {
  color: var(--primary);
  font-weight: 500;
  background: rgba(74, 108, 247, .15);
}

.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-toggle-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.sidebar-toggle-btn:hover {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 200;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(74, 108, 247, .35);
  align-items: center;
  justify-content: center;
}

/* --- Main Content --- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: visible;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  flex-shrink: 0;
  border-left: 1px solid var(--gray-200);
  height: 100%;
}

.topbar-bell {
  cursor: pointer;
  font-size: 18px;
  position: relative;
  padding: 5px;
  color: var(--gray-600);
  transition: var(--transition);
}

.topbar-bell:hover {
  color: var(--primary);
}

.topbar-bell .badge {
  position: absolute;
  top: 0;
  right: -2px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  border-radius: 10px;
  padding: 1px 5px;
  min-width: 16px;
  text-align: center;
  line-height: 14px;
}

.topbar-user {
  font-size: 13px;
  color: var(--gray-600);
  font-weight: 500;
}

/* --- Top Tab Bar (topmost row) --- */
.top-tabbar {
  height: var(--topbar-h);
  background: #eef1f6;
  border-bottom: 2px solid var(--gray-300);
  display: flex;
  align-items: stretch;
  position: sticky;
  top: 0;
  z-index: 50;
}

.tab-scroll {
  flex: 1;
  display: flex;
  align-items: stretch;
  overflow: hidden;
  min-width: 0;
}

.content-page {
  display: none;
  padding: 2px 10px;
  flex: 1;
  min-height: 0;
  overflow: visible;
}

#page-help {
  padding: 0 !important;
  position: relative !important;
  overflow: hidden !important;
}

#page-help.active {
  display: block !important;
}

#page-emails {
  padding: 0 !important;
}

#page-help #pageContent {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

/* --- Tab Bar --- */
.tab-bar {
  height: 100%;
  background: transparent;
  display: flex;
  align-items: stretch;
  padding: 0;
  overflow: hidden;
  flex: 1 1 0;
  min-width: 0;
}

.tab-bar::-webkit-scrollbar {
  height: 0;
}

.tab-overflow {
  display: none;
  align-items: center;
  flex-shrink: 0;
  position: relative;
  background: #fff;
  border-left: 1px solid var(--gray-200);
}

.tab-overflow-btn {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 12px;
  height: 100%;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  cursor: pointer;
  white-space: nowrap;
}

.tab-overflow-btn:hover {
  background: var(--primary-dark);
}

.tab-overflow-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: #fff;
  border: 1px solid var(--gray-300);
  border-radius: 0 0 8px 8px;
  box-shadow: var(--shadow-xl);
  min-width: 200px;
  max-height: 340px;
  overflow-y: auto;
  z-index: 200;
  display: none;
  padding: 4px;
}

.tab-overflow-menu.show {
  display: block;
}

.tab-overflow-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--gray-700);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.tab-overflow-item:hover {
  background: var(--gray-100);
  color: var(--primary);
}

.tab-overflow-item.active {
  color: var(--primary);
  background: var(--primary-light);
  font-weight: 500;
}

.tab-bar::-webkit-scrollbar {
  height: 0;
}

.tab-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  font-size: 12.5px;
  color: var(--gray-500);
  background: transparent;
  border: none;
  border-right: 1px solid var(--gray-200);
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s ease;
  flex-shrink: 0;
  position: relative;
}

.tab-item:hover {
  color: var(--gray-700);
  background: var(--gray-50);
}

.tab-item.active {
  color: var(--primary);
  background: var(--primary-light);
  font-weight: 500;
}

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

.tab-close {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  border-radius: 50%;
  color: var(--gray-400);
  transition: all .15s ease;
  margin-left: 2px;
}

.tab-close:hover {
  background: rgba(239, 68, 68, .15);
  color: var(--danger);
}

/* --- Tab Context Menu --- */
.tab-context-menu {
  position: fixed;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  padding: 4px;
  min-width: 140px;
  z-index: 9999;
  display: none;
}

.tab-context-menu.show {
  display: block;
}

.tab-ctx-item {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--gray-700);
  border-radius: 6px;
  cursor: pointer;
  transition: all .12s ease;
}

.tab-ctx-item:hover {
  background: var(--gray-100);
  color: var(--primary);
}

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

.search-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.search-group input,
.search-group select {
  min-width: 150px;
  width: auto;
  border-radius: var(--radius);
}

.action-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stat-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--gray-100);
  border-radius: 20px;
  font-size: 12px;
  color: var(--gray-600);
  font-weight: 500;
}

/* --- Stats --- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 10px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  border: 1px solid var(--gray-200);
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

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

.stat-card:nth-child(1)::before { background: var(--primary); }
.stat-card:nth-child(2)::before { background: var(--success); }
.stat-card:nth-child(3)::before { background: var(--warning); }
.stat-card:nth-child(4)::before { background: var(--danger); }
.stat-card:nth-child(5)::before { background: var(--info); }

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

.stat-card .stat-icon {
  font-size: 22px;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-card h3 {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.5px;
}

.stat-card p {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 2px;
}

/* --- Tables --- */
.table-wrap {
  overflow-x: auto;
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
}

/* --- Tables --- */
.table, .data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

.table th, .data-table th {
  background: var(--gray-50);
  padding: 6px 8px;
  text-align: left;
  font-weight: 600;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
  font-size: 12px;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.table td, .data-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}

.table tbody tr, .data-table tbody tr {
  transition: var(--transition);
}

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

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

.table .actions, .data-table .actions {
  white-space: nowrap;
  display: flex;
  gap: 4px;
}

.table .text-center { text-align: center; }
.table .action-btns { white-space: nowrap; }
.table .action-btns .btn { margin-right: 4px; }
.table a { color: var(--primary); text-decoration: none; }
.table a:hover { text-decoration: underline; }

/* --- Toolbar --- */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 4px;
  gap: 8px;
  flex-wrap: wrap;
}
.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.toolbar .form-control {
  width: auto;
  min-width: 160px;
}

/* --- Stats Grid --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 6px;
}
.stat-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  text-align: center;
  transition: var(--transition);
}
.stat-card .stat-value { font-size: 20px; font-weight: 700; color: var(--gray-800); }
.stat-card .stat-label { font-size: 12px; color: var(--gray-500); margin-top: 4px; }
.stat-card .stat-hint { font-size: 10px; color: var(--primary); margin-top: 2px; opacity: 0; transition: var(--transition); }
.stat-card.clickable { cursor: pointer; }
.stat-card.clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card.clickable:hover .stat-hint { opacity: 1; }
.stat-card.color-blue { border-left: 4px solid var(--primary); }
.stat-card.color-green { border-left: 4px solid var(--success); }
.stat-card.color-orange { border-left: 4px solid var(--warning); }
.stat-card.color-red { border-left: 4px solid var(--danger); }
.stat-card.color-purple { border-left: 4px solid #9b59b6; }
.stat-card.color-yellow { border-left: 4px solid #f1c40f; }

/* --- Card --- */
.card {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  margin-bottom: 14px;
  overflow: visible;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-header h3 { font-size: 15px; font-weight: 600; color: var(--gray-800); }
.card-body { padding: 8px; }

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-400);
  font-size: 14px;
}

/* --- Badge --- */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  background: var(--danger);
  color: #fff;
}
.badge-success { background: var(--success); }
.badge-warning { background: var(--warning); color: #fff; }
.badge-info { background: var(--info); }
.badge-primary { background: var(--primary); }
.badge-secondary { background: var(--gray-400); }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--gray-300);
  background: #fff;
  color: var(--gray-700);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.btn:hover { background: var(--gray-50); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { opacity: .9; }
.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-warning:hover { opacity: .9; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { opacity: .9; }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border-color: var(--gray-300); }
.btn-outline { background: transparent; border: 1px solid var(--gray-300); color: var(--gray-600); }
.btn-outline:hover { background: var(--gray-50); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { display: flex; width: 100%; }

/* --- Form Controls --- */
.form-control {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--gray-700);
  background: #fff;
  transition: var(--transition);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }
.form-control[readonly] { background: var(--gray-50); }
textarea.form-control { resize: vertical; }
select.form-control { appearance: auto; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--gray-600); margin-bottom: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }

/* --- Page Header --- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.page-title { font-size: 20px; font-weight: 700; color: var(--gray-800); }
.action-buttons { display: flex; gap: 8px; }
.search-filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

/* --- Settings --- */
.settings-card {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  padding: 20px;
  margin-bottom: 14px;
  max-width: 560px;
}
.settings-card h3 { font-size: 16px; font-weight: 600; color: var(--gray-800); margin-bottom: 16px; }
.settings-card .form-group { margin-bottom: 14px; }
.settings-card .form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--gray-600); margin-bottom: 4px; }
.settings-card .form-group input,
.settings-card .form-group select {
  width: 100%;
  max-width: 260px;
}
.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
}
.setting-item:last-child { border-bottom: none; }
.setting-item label { font-size: 14px; color: var(--gray-700); }
.setting-hint { font-size: 12px; color: var(--gray-400); margin-left: 8px; }
.setting-item input[type="number"] { width: 80px; padding: 4px 8px; border: 1px solid var(--gray-300); border-radius: var(--radius); font-size: 13px; text-align: center; }

/* --- Toggle Switch --- */
.switch, .toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.switch input, .toggle input { opacity: 0; width: 0; height: 0; }
.slider, .toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--gray-300);
  border-radius: 24px;
  transition: var(--transition);
}
.slider::before, .toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  left: 2px; bottom: 2px;
  background: #fff;
  border-radius: 50%;
  transition: var(--transition);
}
.switch input:checked + .slider, .toggle input:checked + .toggle-slider { background: var(--primary); }
.switch input:checked + .slider::before, .toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  background: none; border: none;
  font-size: 20px; cursor: pointer;
  color: var(--gray-400);
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
}
.modal-close:hover { background: var(--gray-100); }
.modal-body { padding: 20px; overflow-y: auto; overflow-x: hidden; flex: 1; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* --- Toast --- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideInRight .3s ease;
  min-width: 200px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
.toast.info { background: var(--info); }

/* --- Pagination --- */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
}
.pagination-info { color: var(--gray-500); }
.pagination-btns { display: flex; gap: 4px; }

/* --- Activity List --- */
.activity-list { display: flex; flex-direction: column; gap: 10px; }
.activity-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-100);
}
.activity-icon { font-size: 16px; }
.activity-text { flex: 1; font-size: 13px; color: var(--gray-700); }
.activity-time { font-size: 12px; color: var(--gray-400); }

/* --- Funnel --- */
.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-item { display: flex; align-items: center; gap: 12px; }
.funnel-label { width: 60px; font-size: 13px; color: var(--gray-600); text-align: right; }
.funnel-bar {
  height: 28px;
  border-radius: 4px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  padding: 0 10px;
  min-width: 30px;
}

/* --- AI Tips --- */
.ai-tips { display: flex; flex-direction: column; gap: 10px; }
.ai-tip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  background: var(--primary-light);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--gray-700);
}
.ai-tip-icon { font-size: 16px; flex-shrink: 0; }

/* --- Kanban --- */
.kanban {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}
.kanban-column {
  background: var(--gray-50);
  border-radius: var(--radius-lg);
  padding: 14px;
}
.kanban-column-header {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary);
}
.kanban-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}
.kanban-card-title { font-size: 13px; font-weight: 600; color: var(--gray-800); margin-bottom: 4px; }
.kanban-card-meta { font-size: 12px; color: var(--gray-500); }

/* --- Help Center --- */
.help-layout {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
}
.help-tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-right: 2px solid var(--gray-200);
  width: 160px;
  min-width: 160px;
  background: linear-gradient(180deg, #f8f9ff 0%, #f0f4ff 100%);
  border-radius: 12px 0 0 12px;
  padding: 4px;
  flex-shrink: 0;
  overflow-y: auto;
}
.help-tab {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--gray-500);
  cursor: pointer;
  border-right: 2px solid transparent;
  margin-right: -2px;
  transition: var(--transition);
  border-radius: 8px 0 0 8px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}
.help-tab:hover { color: var(--primary); background: rgba(74,108,247,0.08); }
.help-tab.active { color: var(--primary); border-right-color: var(--primary); font-weight: 600; background: white; box-shadow: 2px 0 8px rgba(74,108,247,0.1); }
.help-content {
  position: absolute;
  top: 0;
  left: 160px;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  background: white;
  border-radius: 0 12px 12px 0;
  box-shadow: 0 2px 16px rgba(0,0,0,0.04);
}
.help-search-sticky {
  flex-shrink: 0;
  z-index: 10;
  background: white;
  padding: 16px 32px 12px 32px;
  border-bottom: 1px solid var(--gray-100);
}
.help-content-inner {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}
.help-content h3, .help-content-inner h3 { font-size: 22px; font-weight: 700; color: var(--gray-800); margin: 0 0 20px; padding-bottom: 14px; border-bottom: 3px solid var(--primary); display: inline-block; letter-spacing: 0.5px; }
.help-content h4, .help-content-inner h4 { font-size: 16px; font-weight: 600; color: var(--primary); margin: 28px 0 12px; padding: 8px 14px; border-left: 4px solid var(--primary); background: rgba(74,108,247,0.04); border-radius: 0 8px 8px 0; }
.help-content p, .help-content-inner p { font-size: 14px; color: var(--gray-600); line-height: 1.9; margin-bottom: 12px; }
.help-content ul, .help-content ol, .help-content-inner ul, .help-content-inner ol { padding-left: 24px; margin-bottom: 16px; }
.help-content li, .help-content-inner li { font-size: 14px; color: var(--gray-600); line-height: 2.2; padding: 2px 0; }
.help-content li strong, .help-content-inner li strong { color: var(--gray-800); font-weight: 600; }
.help-content .info-icon, .help-content-inner .info-icon { font-size: 14px; vertical-align: middle; margin-left: 4px; cursor: help; position: relative; }
.help-content .info-icon::after, .help-content-inner .info-icon::after { display: none !important; }
.help-content .info-icon:hover::after, .help-content-inner .info-icon:hover::after { opacity: 1; }
.help-content table, .help-content-inner table { width: 100%; border-collapse: collapse; margin: 16px 0; background: var(--gray-50); border-radius: 8px; overflow: hidden; border: 1px solid var(--gray-200); }
.help-content th, .help-content-inner th { background: var(--primary); color: white; padding: 10px 14px; text-align: left; font-weight: 600; font-size: 13px; }
.help-content td, .help-content-inner td { padding: 10px 14px; border-bottom: 1px solid var(--gray-200); font-size: 13px; color: var(--gray-600); }
.help-content tr:last-child td, .help-content-inner tr:last-child td { border-bottom: none; }
.help-content tr:hover td, .help-content-inner tr:hover td { background: rgba(74,108,247,0.02); }
.help-content .note, .help-content-inner .note { background: #fff3cd; border: 1px solid #ffc107; border-radius: 8px; padding: 12px 16px; margin: 12px 0; font-size: 13px; color: #856404; line-height: 1.8; }
.help-content .note strong, .help-content-inner .note strong { color: #664d03; }
.help-content h4:not(:first-child), .help-content-inner h4:not(:first-child) { margin-top: 32px; }
.help-content > h4, .help-content-inner > h4 { margin-top: 24px; }
.help-search { width: 100%; padding: 10px 14px 10px 36px; border: 1px solid var(--gray-200); border-radius: 8px; font-size: 13px; outline: none; transition: var(--transition); background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23999' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E") no-repeat 12px center; box-sizing: border-box; }
.help-search:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(74,108,247,0.1); }
.help-search-wrap { position: relative; margin-bottom: 12px; }
.help-search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; }

/* --- Status Tags --- */
.status-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}
.status-tag.active, .status-tag.success { background: var(--success-light); color: var(--success); }
.status-tag.inactive, .status-tag.secondary { background: var(--gray-100); color: var(--gray-500); }
.status-tag.pending, .status-tag.warning { background: var(--warning-light); color: var(--warning); }
.status-tag.new, .status-tag.info { background: var(--info-light); color: var(--info); }
.status-tag.danger { background: var(--danger-light); color: var(--danger); }

/* --- Level Tags --- */
.level-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}
.level-tag.S { background: #e74c3c; }
.level-tag.A { background: #f39c12; }
.level-tag.B { background: #3498db; }
.level-tag.C { background: #95a5a6; }
.level-tag.D { background: #bdc3c7; }

/* --- Data Action Group --- */
.data-action-group { display: flex; gap: 10px; flex-wrap: wrap; }

/* --- Email specific --- */
.email-folders { display: flex; flex-direction: column; gap: 2px; }
.email-folder {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  color: var(--gray-600);
  transition: var(--transition);
}
.email-folder:hover { background: var(--gray-100); }
.email-folder.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.email-template-item {
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
  color: var(--gray-600);
  transition: var(--transition);
}
.email-template-item:hover { background: var(--gray-100); }
.email-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: var(--transition);
}
.email-item:hover { background: var(--gray-50); }
.email-item.selected { background: var(--primary-light); }
.email-item.unread { border-left: 3px solid var(--primary); }
.email-item-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
.email-from { font-size: 13px; font-weight: 600; color: var(--gray-800); }
.email-date { font-size: 12px; color: var(--gray-400); }
.email-subject { font-size: 13px; color: var(--gray-700); margin-bottom: 2px; }
.email-preview { font-size: 12px; color: var(--gray-400); }
.email-read-header { padding-bottom: 12px; border-bottom: 1px solid var(--gray-100); margin-bottom: 12px; }
.email-read-header h3 { font-size: 16px; color: var(--gray-800); margin-bottom: 8px; }
.email-read-meta { display: flex; gap: 16px; font-size: 12px; color: var(--gray-500); margin-bottom: 8px; }
.email-read-actions { display: flex; gap: 6px; }
.email-read-body pre { white-space: pre-wrap; font-size: 13px; color: var(--gray-700); line-height: 1.7; font-family: inherit; }

/* --- WhatsApp --- */
.wa-tabs { display: flex; gap: 0; margin-bottom: 0; }
.wa-tab {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}
.wa-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.wa-contact-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: var(--transition);
}
.wa-contact-item:hover { background: var(--gray-50); }
.wa-contact-item.selected { background: var(--primary-light); }
.wa-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}
.wa-contact-name { font-size: 13px; font-weight: 600; color: var(--gray-800); }
.wa-contact-last { font-size: 12px; color: var(--gray-400); }
.wa-messages { display: flex; flex-direction: column; gap: 6px; padding: 16px; flex: 1; overflow-y: auto; }
.wa-bubble {
  max-width: 70%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
}
.wa-bubble.sent {
  background: var(--primary-light);
  color: var(--gray-800);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.wa-bubble.received {
  background: var(--gray-100);
  color: var(--gray-800);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.wa-input-area {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--gray-200);
}
.wa-input-area input { flex: 1; }

/* --- Compose Overlay --- */
.compose-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
}
.compose-box {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 700px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
}
.compose-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
}
.compose-body { flex: 1; padding: 16px; overflow-y: auto; }
.compose-body textarea { width: 100%; min-height: 200px; border: none; outline: none; font-size: 14px; resize: none; }
.compose-toolbar {
  display: flex;
  gap: 4px;
  padding: 8px 16px;
  border-top: 1px solid var(--gray-100);
}
.compose-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--gray-100);
}

/* --- Topbar User Dropdown --- */
.topbar-user-dropdown {
  position: relative;
  display: inline-block;
}
.user-dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background: #fff;
  border: 1px solid #eef1f5;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  min-width: 150px;
  z-index: 10001;
  padding: 4px;
}
.user-dropdown-menu.show {
  display: block;
}
.user-dropdown-menu a {
  display: block;
  padding: 8px 14px;
  color: #555;
  text-decoration: none;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.user-dropdown-menu a:hover {
  background: #f5f7fa;
  color: #2563eb;
}

/* --- Info Tooltip Icons --- */
.info-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  border-radius: 50%;
  background: #e8f4f8;
  color: #5b9bd5;
  font-size: 12px;
  cursor: help;
  margin-left: 3px;
  vertical-align: middle;
  font-weight: normal;
  position: relative;
  font-family: Arial, sans-serif;
}
.info-icon-sm {
  display: inline-block;
  width: 14px;
  height: 14px;
  line-height: 14px;
  text-align: center;
  border-radius: 50%;
  background: #f0f0f0;
  color: #999;
  font-size: 10px;
  cursor: help;
  margin-left: 2px;
  vertical-align: middle;
}
.info-icon:hover, .info-icon-sm:hover {
  background: #5b9bd5;
  color: #fff;
}
.info-icon::after {
  display: none !important;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-line;
  width: max-content;
  max-width: 280px;
  min-width: 120px;
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  font-weight: normal;
}
.info-icon:hover::after {
  opacity: 1;
}

/* --- Batch Selection --- */
.batch-bar {
  padding: 8px 0;
  display: flex;
  gap: 8px;
  align-items: center;
}
.batch-bar .btn {
  font-size: 12px;
}

/* --- Dashboard Compact Grid --- */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
.card-sm {
  background: #fff;
  border: 1px solid #eef1f5;
  border-radius: 10px;
  overflow: hidden;
}
.card-header-sm {
  padding: 10px 14px;
  border-bottom: 1px solid #f0f2f5;
  background: #fafbfc;
}
.clickable-header {
  cursor: pointer;
  transition: background 0.15s;
}
.clickable-header:hover {
  background: #eef2f7;
}
.clickable-header .header-hint {
  font-weight: 400;
  font-size: 11px;
  color: #94a3b8;
  margin-left: 4px;
}
.clickable-header:hover .header-hint {
  color: #2563eb;
}
.card-header-sm h4 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: #2c3e50;
}
.card-body-sm {
  padding: 10px 14px;
}
.funnel-sm { display: flex; flex-direction: column; gap: 6px; }
.funnel-item-sm { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 3px 0; }
.funnel-item-sm:hover { background: #f5f7fa; border-radius: 4px; }
.funnel-label-sm { min-width: 40px; font-size: 12px; color: #666; }
.funnel-bar-sm { height: 20px; border-radius: 3px; display: flex; align-items: center; padding: 0 6px; transition: width 0.3s; }
.funnel-bar-sm span { font-size: 11px; color: #fff; font-weight: 500; }
.todo-list-sm { display: flex; flex-direction: column; gap: 4px; }
.todo-item-sm { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 4px; cursor: pointer; font-size: 12px; color: #333; transition: all 0.15s; }
.todo-item-sm:hover { background: #f5f7fa; }
.todo-icon-sm { font-size: 14px; flex-shrink: 0; }
.activity-list-sm { display: flex; flex-direction: column; gap: 4px; max-height: 180px; overflow-y: auto; }
.activity-item-sm { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 4px; cursor: pointer; font-size: 12px; color: #555; transition: all 0.15s; }
.activity-item-sm:hover { background: #f5f7fa; }
.activity-icon-sm { font-size: 13px; flex-shrink: 0; }
.activity-text-sm { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-time-sm { font-size: 11px; color: #999; flex-shrink: 0; }
.ai-tips-sm { display: flex; flex-direction: column; gap: 4px; }
.ai-tip-sm { padding: 4px 6px; border-radius: 4px; cursor: pointer; font-size: 12px; color: #555; transition: all 0.15s; }
.ai-tip-sm:hover { background: #f0f7ff; }
.ai-tip-sm span { display: flex; align-items: center; gap: 4px; }
@media (max-width: 768px) {
  .dash-grid { grid-template-columns: 1fr; gap: 12px; }
}
td.has-info { white-space: nowrap; }

/* --- Notification Panel --- */
.notification-panel {
  position: fixed;
  top: 60px;
  right: 20px;
  width: 320px;
  max-height: 400px;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--gray-200);
  z-index: 9999;
  display: none;
  overflow: hidden;
}
.notification-panel.show { display: block; }
.notif-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  font-weight: 600;
}
.notif-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--gray-400); }
.notif-list { max-height: 350px; overflow-y: auto; }
.notif-item {
  display: flex;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: var(--transition);
}
.notif-item:hover { background: var(--gray-50); }
.notif-item.unread { background: var(--primary-light); }
.notif-icon { font-size: 16px; flex-shrink: 0; margin-top: 2px; }
.notif-title { font-size: 13px; font-weight: 600; color: var(--gray-800); }
.notif-desc { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.notif-time { font-size: 11px; color: var(--gray-400); margin-top: 2px; }

/* --- Topbar --- */
.topbar-bell {
  position: relative;
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
}
.notification-toggle { position: relative; cursor: pointer; }

/* --- Dropdown --- */
.dropdown-inline { position: relative; display: inline-block; }
.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 100px;
  z-index: 200;
  padding: 4px 0;
}
.dropdown-menu.show { display: block; }
.dropdown-item {
  display: block;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--gray-700);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.dropdown-item:hover { background: var(--gray-50); }
.ctx-item:hover { background: #f1f5f9 !important; color: #0f172a !important; }
.dropdown-item.text-danger { color: var(--danger); }

/* --- Permission Grid --- */
.permission-grid { display: flex; flex-direction: column; gap: 10px; }
.permission-grid .perm-group {
  background: var(--gray-50);
  border-radius: 8px;
  padding: 8px 10px;
  border: 1px solid var(--gray-100);
}
.perm-group h5 {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  margin: 0 0 6px 0;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 6px;
}
.perm-group h5::before {
  content: '';
  width: 3px;
  height: 12px;
  background: var(--primary);
  border-radius: 2px;
  flex-shrink: 0;
}
.perm-group .perm-items {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 0;
}
.perm-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
  color: var(--gray-600);
  cursor: pointer;
}
.perm-item:hover { background: var(--gray-100); }
.perm-item input { cursor: pointer; margin: 0; width: 13px; height: 13px; }
.perm-item input:checked + .perm-label { color: var(--primary); font-weight: 500; }
.perm-item .perm-label { line-height: 1.3; }
.perm-item .perm-tag { font-size: 10px; color: #94a3b8; white-space: nowrap; }
.perm-item .perm-tag.custom { color: var(--primary); }

/* --- Role checkbox grid (multi-role selection) --- */
.role-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px 12px;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f8fafc;
}
.role-check-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  line-height: 1.3;
}
.role-check-item input { cursor: pointer; margin: 0; width: 14px; height: 14px; }
.role-check-label { user-select: none; }

/* --- Team list table --- */
.team-list-wrap { overflow-x: auto; }
.team-list-table { table-layout: auto; width: auto; min-width: 0; border-collapse: separate; border-spacing: 0; }
.team-list-table th, .team-list-table td { padding: 10px 14px; font-size: 13px; white-space: nowrap; }
.team-list-table th { white-space: nowrap; font-weight: 600; color: #475569; background: #f8fafc; border-bottom: 2px solid #e2e8f0; }
.team-list-table td { border-bottom: 1px solid #f1f5f9; }
.team-list-table tr:hover td { background: #f8fafc; }
.team-list-table .col-username { font-weight: 500; color: #1e293b; min-width: 110px; }
.team-list-table .col-name { min-width: 70px; }
.team-list-table .col-phone { min-width: 105px; }
.team-list-table .col-email { min-width: 140px; }
.team-list-table .col-dept { min-width: 70px; }
.team-list-table .col-group { min-width: 70px; }
.team-list-table .action-btns { position: relative; white-space: nowrap; }
.team-list-table .action-btns .team-dropdown-menu a { display: block; padding: 6px 12px; font-size: 12px; cursor: pointer; white-space: nowrap; }
.team-list-table .action-btns .team-dropdown-menu a:hover { background: #f3f4f6; }

/* --- Data Category List --- */
.data-category-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}
.data-cat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--gray-50);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--gray-700);
  cursor: pointer;
  transition: var(--transition);
}
.data-cat-item:hover { background: var(--gray-100); }
.data-cat-item input { cursor: pointer; }

/* --- Cards --- */
.card {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  padding: 22px;
  margin-bottom: 14px;
  transition: var(--transition);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--gray-800);
}

/* --- Forms --- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.fg {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.fg.full {
  grid-column: 1 / -1;
}

.form-hint {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 2px;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-100);
  justify-content: flex-end;
}

/* --- Tags / Badges --- */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
}

.tag-success {
  background: var(--success-light);
  color: #16a34a;
}

.tag-warning {
  background: var(--warning-light);
  color: #d97706;
}

.tag-danger {
  background: var(--danger-light);
  color: #dc2626;
}

.tag-info {
  background: var(--info-light);
  color: #2563eb;
}

.tag-primary {
  background: var(--primary-light);
  color: var(--primary);
}

.tag-default {
  background: var(--gray-100);
  color: var(--gray-600);
}

.stars {
  color: var(--warning);
  font-size: 12px;
  letter-spacing: 1px;
}

.star-empty {
  color: var(--gray-300);
}

.level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}

.level-s { background: #dc2626; }
.level-a { background: #f59e0b; }
.level-b { background: #3b82f6; }
.level-c { background: #22c55e; }
.level-d { background: #9ca3af; }

/* --- Notification Panel --- */
/* notification-panel styles consolidated above */

.notification-panel.show {
  display: block;
  animation: fadeDown .2s ease;
}

@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.notif-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--gray-200);
  font-weight: 600;
  font-size: 14px;
}

.notif-header a {
  font-size: 12px;
  color: var(--primary);
  cursor: pointer;
  font-weight: 500;
}

.notif-list {
  max-height: 380px;
  overflow-y: auto;
}

.notif-item {
  padding: 12px 18px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}

.notif-item:hover {
  background: var(--gray-50);
}

.notif-item.unread {
  background: var(--primary-bg);
  border-left: 3px solid var(--primary);
}

.notif-item .notif-time {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 4px;
}

.notif-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--gray-400);
  font-size: 13px;
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal-overlay.show {
  display: flex;
  animation: fadeIn .2s ease;
}

.modal-box {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 92%;
  max-width: 640px;
  max-height: 85vh;
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  animation: modalIn .25s cubic-bezier(.4, 0, .2, 1);
}

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

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--gray-200);
}

.modal-head h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--gray-800);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  font-size: 22px;
  color: var(--gray-400);
  border-radius: 8px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px;
}

.modal-body .form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.modal-body .fg {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.modal-body .fg.full {
  grid-column: 1 / -1;
}

/* --- Toast --- */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  box-shadow: var(--shadow-lg);
  animation: slideIn .35s cubic-bezier(.4, 0, .2, 1);
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast-success { background: #16a34a; }
.toast-error { background: #dc2626; }
.toast-warning { background: #d97706; }
.toast-info { background: #2563eb; }

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

/* --- Email - 3 Column Layout --- */
.email-layout {
  display: grid;
  grid-template-columns: 200px 350px 1fr;
  height: calc(100vh - var(--topbar-h) - 48px);
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}

.email-sidebar {
  border-right: 1px solid var(--gray-200);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  background: var(--gray-50);
}

.email-sidebar .folder {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--gray-600);
  transition: var(--transition);
  cursor: pointer;
}

.email-sidebar .folder:hover {
  background: var(--gray-200);
}

.email-sidebar .folder.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.email-sidebar .folder em {
  margin-left: auto;
  font-style: normal;
  font-size: 11px;
  color: var(--gray-400);
  background: var(--gray-200);
  padding: 1px 7px;
  border-radius: 10px;
}

.email-sidebar .folder-section {
  font-size: 11px;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 14px 0 5px;
  font-weight: 700;
}

.email-sidebar .folder-tool {
  padding: 7px 12px;
  font-size: 12px;
  color: var(--gray-500);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
}

.email-sidebar .folder-tool:hover {
  background: var(--gray-200);
  color: var(--primary);
}

.email-list-pane {
  border-right: 1px solid var(--gray-200);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.email-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.email-toolbar {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-200);
  align-items: center;
}

.email-toolbar input {
  flex: 1;
  min-width: 0;
}

.email-list {
  flex: 1;
  overflow-y: auto;
}

.email-item {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: var(--transition);
  align-items: flex-start;
}

.email-item:hover {
  background: var(--gray-50);
}

.email-item.unread {
  background: var(--primary-bg);
  border-left: 3px solid var(--primary);
}

.email-item .e-check {
  flex-shrink: 0;
  margin-top: 3px;
}

.email-item .e-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}

.email-item .e-body {
  flex: 1;
  min-width: 0;
}

.email-item .e-from {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
}

.email-item.unread .e-from {
  font-weight: 700;
}

.email-item .e-subject {
  font-size: 12px;
  color: var(--gray-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-item .e-preview {
  font-size: 11px;
  color: var(--gray-400);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-item .e-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex-shrink: 0;
}

.email-item .e-time {
  font-size: 11px;
  color: var(--gray-400);
}

.email-item .e-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}

/* Email Tabs */
.email-tabs {
  display: flex;
  gap: 0;
  background: #f1f3f5;
  border-bottom: 1px solid #ddd;
  overflow-x: auto;
}

.email-tab {
  padding: 8px 16px;
  font-size: 12px;
  cursor: pointer;
  border-right: 1px solid #ddd;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  background: #f8f9fa;
}

.email-tab.active {
  background: white;
  border-bottom: 2px solid var(--primary);
}

.email-tab-close {
  cursor: pointer;
  opacity: 0.5;
  font-size: 14px;
}

.email-tab-close:hover {
  opacity: 1;
}

.email-tab-content {
  flex: 1;
  overflow-y: auto;
}

.compose-tab-content {
  padding: 24px;
}

.compose-tab-form {
  max-width: 800px;
}

.compose-tab-form .form-group {
  margin-bottom: 16px;
}

.compose-tab-form .form-group label {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
  color: var(--gray-600);
}

.compose-tab-form textarea {
  min-height: 300px;
  resize: vertical;
}

.compose-tab-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-100);
}

.compose-attach-btn {
  display: flex;
  align-items: center;
  gap: 8px;
}

.compose-attach-name {
  font-size: 12px;
  color: var(--gray-500);
}

/* Email detail pane */
.email-read-pane {
  overflow-y: auto;
  padding: 24px;
}

.email-detail {
  display: none;
  padding: 0;
}

.email-detail.show {
  display: block;
}

.email-detail-header {
  padding: 24px;
  border-bottom: 1px solid var(--gray-100);
}

.email-detail-header h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--gray-900);
}

.email-detail-meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.email-detail-meta p {
  font-size: 12px;
  color: var(--gray-500);
}

.email-detail-meta strong {
  color: var(--gray-700);
}

.email-detail-body {
  padding: 24px;
  font-size: 14px;
  line-height: 1.9;
  color: var(--gray-700);
}

.email-detail-actions {
  padding: 14px 24px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  gap: 8px;
}

/* Email Compose Overlay */
.email-compose-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.email-compose-box {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 700px;
  max-width: 92vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  animation: modalIn .25s cubic-bezier(.4, 0, .2, 1);
}

.email-compose-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.email-compose-header h3 {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
}

.email-compose-fields {
  padding: 0 22px;
}

.email-compose-fields .fg {
  border-bottom: 1px solid var(--gray-100);
  padding: 9px 0;
  flex-direction: row;
  align-items: center;
}

.email-compose-fields .fg label {
  display: inline-block;
  width: 64px;
  font-size: 12px;
  color: var(--gray-500);
  flex-shrink: 0;
}

.email-compose-fields .fg input {
  border: none;
  border-radius: 0;
  padding: 5px 0;
  font-size: 13px;
  width: calc(100% - 68px);
  box-shadow: none;
}

.email-compose-fields .fg input:focus {
  box-shadow: none;
}

.email-compose-toolbar {
  display: flex;
  gap: 2px;
  padding: 7px 16px;
  border-bottom: 1px solid var(--gray-100);
  flex-wrap: wrap;
}

.email-compose-toolbar button {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 14px;
  transition: var(--transition);
  color: var(--gray-600);
}

.email-compose-toolbar button:hover {
  background: var(--gray-100);
  color: var(--primary);
}

.email-compose-toolbar select {
  border: none;
  font-size: 12px;
  padding: 2px 6px;
  color: var(--gray-600);
  background: transparent;
}

.email-editor {
  min-height: 220px;
  padding: 14px 18px;
  outline: none;
  font-size: 13px;
  line-height: 1.9;
  overflow-y: auto;
}

.email-compose-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 22px;
  border-top: 1px solid var(--gray-200);
}

.email-compose-footer .left {
  display: flex;
  gap: 6px;
}

/* --- WhatsApp - 3 Column Layout --- */
.wa-layout {
  display: grid;
  grid-template-columns: 56px 320px 1fr;
  height: calc(100vh - var(--topbar-h) - 48px);
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}

.wa-nav {
  background: var(--gray-900);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0;
  gap: 6px;
}

.wa-nav-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, .5);
  cursor: pointer;
  transition: var(--transition);
  font-size: 18px;
  position: relative;
}

.wa-nav-icon:hover,
.wa-nav-icon.active {
  background: rgba(255, 255, 255, .12);
  color: #fff;
}

.wa-nav-icon .badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--success);
  color: #fff;
  font-size: 9px;
  font-weight: 600;
  border-radius: 8px;
  padding: 1px 5px;
  min-width: 16px;
  text-align: center;
}

.wa-sidebar {
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.wa-panel-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 8px;
}

.wa-panel-header input {
  flex: 1;
  border: none;
  border-radius: 20px;
  background: var(--gray-100);
  padding: 8px 14px;
  font-size: 13px;
}

.wa-panel-header input:focus {
  box-shadow: none;
  background: var(--gray-200);
}

.wa-panel-header button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  transition: var(--transition);
  color: var(--gray-600);
}

.wa-panel-header button:hover {
  background: var(--gray-100);
}

.wa-panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--gray-200);
}

.wa-panel-tab {
  flex: 1;
  padding: 9px;
  text-align: center;
  font-size: 12px;
  border: none;
  background: none;
  color: var(--gray-500);
  font-weight: 600;
  transition: var(--transition);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.wa-panel-tab.active {
  color: var(--success);
  border-bottom-color: var(--success);
}

.wa-panel-list {
  flex: 1;
  overflow-y: auto;
}

.wa-contact {
  display: flex;
  gap: 11px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: var(--transition);
  align-items: center;
}

.wa-contact:hover {
  background: var(--gray-50);
}

.wa-contact.active {
  background: #e8f5e9;
}

.wa-contact .avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--gray-300);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  color: #fff;
  font-weight: 600;
}

.wa-contact .info {
  flex: 1;
  min-width: 0;
}

.wa-contact .name {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-800);
}

.wa-contact .preview {
  font-size: 12px;
  color: var(--gray-400);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wa-contact .meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex-shrink: 0;
}

.wa-contact .time {
  font-size: 10px;
  color: var(--gray-400);
}

.wa-contact .unread {
  background: var(--success);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  border-radius: 8px;
  padding: 1px 6px;
}

.wa-main {
  display: flex;
  flex-direction: column;
  background: #e5ddd5;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d1d5db' fill-opacity='.15'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.wa-chat-header {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 18px;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
}

.wa-chat-header .avatar {
  width: 38px;
  height: 38px;
}

.wa-chat-header .info {
  flex: 1;
}

.wa-chat-header .name {
  font-size: 14px;
  font-weight: 600;
}

.wa-chat-header .status {
  font-size: 11px;
  color: var(--success);
  font-weight: 500;
}

.wa-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wa-bubble {
  max-width: 65%;
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.55;
  position: relative;
}

.wa-bubble.in {
  background: #fff;
  align-self: flex-start;
  border-bottom-left-radius: 3px;
  box-shadow: var(--shadow-sm);
}

.wa-bubble.out {
  background: #dcf8c6;
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}

.wa-bubble .time {
  font-size: 10px;
  color: var(--gray-400);
  text-align: right;
  margin-top: 4px;
}

.wa-chat-input {
  display: flex;
  gap: 10px;
  padding: 12px 18px;
  background: #f0f0f0;
  align-items: center;
}

.wa-chat-input input {
  flex: 1;
  border-radius: 22px;
  padding: 9px 16px;
  border: none;
  font-size: 13px;
}

.wa-chat-input input:focus {
  box-shadow: none;
}

.wa-chat-input button {
  border-radius: 50%;
  width: 40px;
  height: 40px;
  border: none;
  background: var(--success);
  color: #fff;
  font-size: 18px;
  flex-shrink: 0;
  transition: var(--transition);
}

.wa-chat-input button:hover {
  background: #16a34a;
  box-shadow: 0 2px 8px rgba(34, 197, 94, .35);
}

.wa-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--gray-400);
  background: var(--gray-50);
}

.wa-empty-icon {
  font-size: 72px;
  margin-bottom: 18px;
  opacity: .35;
}

/* --- Pipeline --- */
.pipeline {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  overflow-x: auto;
}

.pipeline-col {
  background: var(--gray-50);
  border-radius: var(--radius-lg);
  padding: 14px;
  min-width: 220px;
}

.pipeline-col h4 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--primary);
  display: flex;
  justify-content: space-between;
  color: var(--gray-800);
}

.pipeline-col h4 span {
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 600;
}

.pipeline-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 12px 14px;
  border: 1px solid var(--gray-200);
  margin-bottom: 8px;
  cursor: pointer;
  transition: var(--transition);
}

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

/* --- Timeline --- */
.timeline {
  position: relative;
  padding-left: 30px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--gray-200);
}

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

.timeline-item::before {
  content: '';
  position: absolute;
  left: -23px;
  top: 5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 2px var(--gray-200);
  z-index: 1;
}

.timeline-item .tl-time {
  font-size: 11px;
  color: var(--gray-400);
  margin-bottom: 5px;
  font-weight: 500;
}

.timeline-item .tl-content {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 13px 16px;
}

.timeline-item .tl-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
  color: var(--gray-800);
}

.timeline-item .tl-desc {
  font-size: 12px;
  color: var(--gray-600);
  line-height: 1.6;
}

.timeline-item .tl-actions {
  margin-top: 8px;
  display: flex;
  gap: 6px;
}

/* --- Settings --- */
.settings-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
}

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-nav-item {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--gray-600);
  cursor: pointer;
  transition: var(--transition);
}

.settings-nav-item:hover {
  background: var(--gray-100);
}

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

.settings-section {
  margin-bottom: 22px;
}

.settings-section h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-800);
}

.member-list,
.role-list,
.dept-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--gray-50);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  transition: var(--transition);
}

.list-item:hover {
  border-color: var(--gray-300);
  background: #fff;
}

.list-item .li-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.list-item .li-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--gray-800);
}

.list-item .li-detail {
  font-size: 11px;
  color: var(--gray-500);
}

.list-item .li-actions {
  display: flex;
  gap: 5px;
}

/* --- Dashboard --- */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
}

.dash-card {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}

.dash-card-header {
  padding: 15px 20px;
  border-bottom: 1px solid var(--gray-100);
  font-weight: 600;
  font-size: 14px;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dash-card-body {
  padding: 16px 20px;
}

/* Funnel */
.funnel {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.funnel-item {
  position: relative;
}

.funnel-bar {
  padding: 9px 16px;
  border-radius: var(--radius);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  transition: var(--transition);
}

.funnel-bar:hover {
  transform: scaleY(1.05);
}

/* Activity */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--gray-100);
}

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

.activity-badge {
  font-size: 10px;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.activity-text {
  flex: 1;
  font-size: 12px;
  color: var(--gray-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-time {
  font-size: 11px;
  color: var(--gray-400);
  flex-shrink: 0;
}

/* --- AI --- */
.ai-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 14px;
}

.ai-input {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.ai-input input {
  flex: 1;
}

.ai-result {
  min-height: 70px;
  font-size: 13px;
  line-height: 1.8;
  color: var(--gray-700);
  padding: 14px;
  background: var(--gray-50);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
}

.ai-loading {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--gray-500);
  font-size: 13px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--gray-300);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

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

/* --- Import/Export Modals --- */
.upload-area {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-lg);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--gray-50);
}

.upload-area:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.upload-area.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: scale(1.01);
}

.upload-icon {
  font-size: 42px;
  color: var(--gray-400);
  margin-bottom: 12px;
}

.upload-text {
  font-size: 14px;
  color: var(--gray-600);
  font-weight: 500;
  margin-bottom: 4px;
}

.upload-hint {
  font-size: 12px;
  color: var(--gray-400);
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--gray-50);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
}

.file-item .fi-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
}

.file-item .fi-size {
  font-size: 11px;
  color: var(--gray-400);
}

.file-item .fi-remove {
  color: var(--gray-400);
  cursor: pointer;
  transition: var(--transition);
}

.file-item .fi-remove:hover {
  color: var(--danger);
}

/* --- Form Modals (Beautiful Layouts) --- */
.form-modal .modal-body {
  padding: 24px 28px;
}

.form-modal .form-grid {
  gap: 18px;
}

.form-modal .fg label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-modal .fg input,
.form-modal .fg select,
.form-modal .fg textarea {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
}

.form-modal .fg input:focus,
.form-modal .fg select:focus,
.form-modal .fg textarea:focus {
  box-shadow: 0 0 0 3px rgba(74, 108, 247, .1);
}

.form-modal .form-actions {
  padding: 18px 28px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* --- Report / Grids --- */
.report-grid,
.team-grid,
.customs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
}

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

  .wa-layout {
    grid-template-columns: 56px 260px 1fr;
  }

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

  .email-layout {
    grid-template-columns: 180px 300px 1fr;
  }

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

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .3s cubic-bezier(.4, 0, .2, 1);
  }

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

  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

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

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

  .wa-layout {
    grid-template-columns: 1fr;
  }

  .wa-nav {
    display: none;
  }

  .wa-sidebar {
    display: none;
  }

  .email-layout {
    grid-template-columns: 1fr;
  }

  .email-sidebar {
    display: none;
  }

  .email-list-pane {
    border-right: none;
  }

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

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

  .search-group {
    flex-direction: column;
  }

  .search-group input,
  .search-group select {
    min-width: auto;
    width: 100%;
  }

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

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

  .top-tabbar {
    padding: 0 10px;
  }

  .topbar-actions {
    padding: 0 10px;
    gap: 10px;
  }

  .content-page {
    padding: 16px;
  }

  .notification-panel {
    right: 10px;
    left: 10px;
    width: auto;
  }

  .modal-box {
    width: 95%;
    max-height: 90vh;
  }

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

  .report-grid,
  .team-grid,
  .customs-grid {
    grid-template-columns: 1fr;
  }
}

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

  .btn-group {
    flex-direction: column;
    width: 100%;
  }

  .btn-group .btn-primary,
  .btn-group .btn-outline,
  .btn-group .btn-danger {
    width: 100%;
    justify-content: center;
  }

  .topbar-title {
    font-size: 14px;
  }

  .login-box {
    padding: 32px 24px;
    margin: 16px;
  }

  .login-logo {
    font-size: 26px;
  }

  .email-compose-box {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
}

/* --- Clickable Items --- */
.clickable { cursor: pointer; transition: var(--transition); }
.clickable:hover { opacity: 0.85; }

/* --- Todo List --- */
.todo-list { display: flex; flex-direction: column; gap: 8px; }
.todo-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--gray-50);
  border-radius: var(--radius);
  transition: var(--transition);
}
.todo-item.clickable:hover { background: var(--gray-100); transform: translateX(4px); }
.todo-icon { font-size: 16px; flex-shrink: 0; }
.todo-text { font-size: 13px; color: var(--gray-700); line-height: 1.4; }
.todo-text strong { color: var(--gray-900); }

/* --- Funnel Clickable --- */
.funnel-item.clickable { cursor: pointer; padding: 8px 12px; border-radius: var(--radius); transition: var(--transition); }
.funnel-item.clickable:hover { background: var(--gray-50); transform: translateX(4px); }

/* --- Activity Clickable --- */
.activity-item.clickable { cursor: pointer; padding: 10px 12px; border-radius: var(--radius); transition: var(--transition); }
.activity-item.clickable:hover { background: var(--gray-50); transform: translateX(4px); }

/* --- AI Tips Clickable --- */
.ai-tip.clickable { cursor: pointer; padding: 12px 14px; border-radius: var(--radius); transition: var(--transition); }
.ai-tip.clickable:hover { background: var(--gray-50); transform: translateX(4px); }
.ai-tip.clickable em { color: var(--primary); font-size: 11px; margin-left: 6px; }

/* --- Toolbar Responsive --- */
.toolbar-filters > * {
  flex: 0 1 auto;
  min-width: 0;
}

.toolbar-filters > select,
.toolbar-filters > input[type="date"] {
  max-width: 110px;
}

.toolbar-date-group > * {
  flex: 0 1 auto;
  min-width: 0;
}

.toolbar-actions > * {
  flex: 0 1 auto;
  min-width: 0;
}

.toolbar-actions {
  justify-content: flex-start !important;
}

.toolbar > .toolbar-filters,
.toolbar > .toolbar-actions {
  justify-content: flex-start;
}

.toolbar-filters > select,
.toolbar-filters > input[type="date"] {
  width: auto;
}

@media (max-width: 768px) {
  .toolbar-filters > select,
  .toolbar-filters > input[type="date"],
  .toolbar-date-group > select,
  .toolbar-date-group > input[type="date"] {
    max-width: none;
    width: 100%;
  }
}

/* --- AI工具箱 --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.feature-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 22px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}
.feature-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}
.feature-card .card-icon {
  font-size: 36px;
  margin-bottom: 12px;
}
.feature-card h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 6px;
}
.feature-card p {
  font-size: 13px;
  color: var(--gray-500);
  line-height: 1.6;
}
.policy-item {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.policy-title {
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 6px;
}
.policy-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--gray-500);
  align-items: center;
}
.policy-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}
#ai-tool-content .btn { margin: 0; }
#ai-tool-content .card-body { padding: 16px; }
@media (max-width: 768px) {
  .card-grid { grid-template-columns: 1fr; }
  #ai-tool-content .btn { width: 100%; text-align: center; }
}

/* Email hover icons - Alibaba Mail style */
.em-hover-icons {
  display: none !important;
}
div:hover > .em-hover-icons,
.em-hover-icons:hover {
  display: flex !important;
}
div:hover > .em-time-text {
  display: none !important;
}
div:hover > .em-hover-icons + .em-time-text {
  display: none !important;
}

/* Email context menu */
.em-ctx-menu {
  position: fixed;
  z-index: 10000;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  padding: 4px 0;
  min-width: 180px;
}
.em-ctx-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  color: #374151;
  transition: background .12s;
}
.em-ctx-menu-item:hover {
  background: #f3f4f6;
}
.em-ctx-menu-item.danger {
  color: #ef4444;
}
.em-ctx-menu-divider {
  height: 1px;
  background: #f0f0f0;
  margin: 4px 0;
}

/* Compose window fullscreen */
.em-compose-fullscreen {
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  top: 0 !important;
  left: 0 !important;
}

/* Rich text editor placeholder */
[contenteditable=true]:empty:before {
  content: attr(data-placeholder);
  color: #9ca3af;
  pointer-events: none;
}
[contenteditable=true]:focus {
  outline: none;
}

/* Search input placeholder on dark background */
.em-topbar input::placeholder {
  color: rgba(255,255,255,0.5);
}

/* Business Details Form Styles */
.biz-detail-field {
  font-size: 12px !important;
  padding: 6px 8px !important;
}

.biz-detail-remark {
  font-size: 12px !important;
  min-height: 60px !important;
}

.biz-detail-cargo-attr {
  width: auto !important;
  margin-right: 4px;
}

/* Form Grid Layout */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Section Headers */
.biz-section-header {
  font-size: 12px;
  font-weight: 500;
  color: #666;
  margin-bottom: 6px;
  margin-top: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #e5e7eb;
}

/* Compact Form Groups */
.form-group-compact {
  margin-bottom: 8px;
}

.form-group-compact label {
  font-size: 11px !important;
  margin-bottom: 2px !important;
}

/* Modal Body Scroll */
.modal-body {
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

/* Column Resize Handle */
.col-resize-handle {
  position: absolute;
  right: -1px;
  top: 0;
  bottom: 0;
  width: 3px;
  cursor: col-resize;
  background: transparent;
  z-index: 10;
}

.col-resize-handle:hover {
  background: #4a6cf7;
}

.col-resize-handle:active {
  background: #3b5de7;
}

/* Table Header with resize */
.table th {
  position: relative;
  user-select: none;
  border-right: 1px solid #f0f0f0;
}

.table th:last-child {
  border-right: none;
}

.table th:hover {
  background: #f9fafb;
}

.table th:hover .col-resize-handle {
  background: #d1d5db;
}

/* Multi-Select Dropdown */
.multi-select-dropdown {
  position: relative;
  display: inline-block;
}

.multi-select-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  min-width: 80px;
  max-width: 150px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.multi-select-btn:hover {
  border-color: #9ca3af;
}

.multi-select-btn.has-value {
  border-color: #4a6cf7;
  background: #eef2ff;
}

.multi-select-btn .arrow {
  margin-left: auto;
  font-size: 10px;
  color: #9ca3af;
}

.multi-select-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 140px;
  max-height: 200px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1000;
  padding: 4px 0;
}

.multi-select-menu.show {
  display: block;
}

.multi-select-search {
  padding: 6px 8px;
  border-bottom: 1px solid #e5e7eb;
}

.multi-select-search-input {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 12px;
  outline: none;
  box-sizing: border-box;
}

.multi-select-search-input:focus {
  border-color: #4a6cf7;
}

.multi-select-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
  color: #374151;
}

.multi-select-option:hover {
  background: #f3f4f6;
}

.multi-select-option input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: #4a6cf7;
  cursor: pointer;
}

.multi-select-option.selected {
  background: #eef2ff;
  color: #4a6cf7;
}

.multi-select-count {
  background: #4a6cf7;
  color: #fff;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 8px;
  margin-left: 2px;
}
