/* =====================================================
   MEAZUL COMUNICAÇÃO — DESIGN SYSTEM
   Versão: 1.0.0
   ===================================================== */

/* ---------- IMPORTS ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ---------- CSS VARIABLES ---------- */
:root {
  /* Primary Palette */
  --primary-50:  #eff6ff;
  --primary-100: #dbeafe;
  --primary-200: #bfdbfe;
  --primary-300: #93c5fd;
  --primary-400: #60a5fa;
  --primary-500: #3b82f6;
  --primary-600: #2563eb;
  --primary-700: #1d4ed8;
  --primary-800: #1e40af;
  --primary-900: #1e3a8a;

  /* Brand */
  --brand:       #1a56db;
  --brand-dark:  #1346c0;
  --brand-light: #eff6ff;

  /* Neutral */
  --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;

  /* Status Colors */
  --green-500: #22c55e;
  --green-100: #dcfce7;
  --green-700: #15803d;
  --yellow-500: #eab308;
  --yellow-100: #fef9c3;
  --yellow-700: #a16207;
  --red-500:   #ef4444;
  --red-100:   #fee2e2;
  --red-700:   #b91c1c;
  --orange-500: #f97316;
  --orange-100: #ffedd5;
  --orange-700: #c2410c;
  --purple-500: #a855f7;
  --purple-100: #f3e8ff;
  --purple-700: #7e22ce;

  /* Layout */
  --sidebar-width: 260px;
  --sidebar-collapsed: 68px;
  --topbar-height: 64px;

  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(0,0,0,.05);
  --shadow-sm: 0 1px 3px 0 rgba(0,0,0,.08), 0 1px 2px -1px rgba(0,0,0,.08);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -2px rgba(0,0,0,.08);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.08);

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;

  /* Transitions */
  --transition: all 0.2s ease;
  --transition-slow: all 0.3s ease;
}

/* ---------- RESET & BASE ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background-color: var(--gray-100);
  color: var(--gray-800);
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--brand-dark); }

h1,h2,h3,h4,h5,h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--gray-900);
  margin-bottom: 0;
}

/* ---------- LAYOUT WRAPPER ---------- */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ---------- SIDEBAR ---------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: var(--gray-900);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: var(--transition-slow);
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  min-height: var(--topbar-height);
}

.sidebar-brand-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
  color: #fff;
  font-weight: 800;
  letter-spacing: -1px;
}

.sidebar-brand-name {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: var(--transition);
}

.sidebar-brand-name span:first-child {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.3px;
  white-space: nowrap;
}

.sidebar-brand-name span:last-child {
  font-size: 11px;
  color: var(--gray-400);
  white-space: nowrap;
}

.sidebar.collapsed .sidebar-brand-name { opacity: 0; width: 0; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}

.sidebar-section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--gray-500);
  padding: 16px 20px 6px;
  white-space: nowrap;
  transition: var(--transition);
}

.sidebar.collapsed .sidebar-section-title { opacity: 0; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  color: var(--gray-400);
  font-size: 13.5px;
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
  border-radius: 0;
  position: relative;
}

.sidebar-nav a:hover {
  color: #fff;
  background: rgba(255,255,255,.06);
}

.sidebar-nav a.active {
  color: #fff;
  background: rgba(59,130,246,.2);
}

.sidebar-nav a.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--primary-500);
  border-radius: 0 3px 3px 0;
}

.sidebar-nav a .nav-icon {
  font-size: 17px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.sidebar-nav a .nav-badge {
  margin-left: auto;
  background: var(--primary-600);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  transition: var(--transition);
}

.sidebar.collapsed .nav-badge,
.sidebar.collapsed .nav-label { opacity: 0; width: 0; overflow: hidden; }

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.08);
  padding: 12px 18px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}

.sidebar-user:hover { background: rgba(255,255,255,.06); }

.sidebar-user-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  object-fit: cover;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary-500), var(--purple-500));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.sidebar-user-info {
  overflow: hidden;
  transition: var(--transition);
}

.sidebar-user-info span:first-child {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}

.sidebar-user-info span:last-child {
  display: block;
  font-size: 11px;
  color: var(--gray-500);
  white-space: nowrap;
}

.sidebar.collapsed .sidebar-user-info { opacity: 0; width: 0; }

/* ---------- MAIN AREA ---------- */
.main-area {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: var(--transition-slow);
}

.main-area.expanded {
  margin-left: var(--sidebar-collapsed);
}

/* ---------- TOPBAR ---------- */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  z-index: 900;
  box-shadow: var(--shadow-xs);
}

.topbar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-500);
  padding: 6px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  display: flex;
  align-items: center;
  transition: var(--transition);
}

.topbar-toggle:hover { background: var(--gray-100); color: var(--gray-700); }

.topbar-search {
  position: relative;
  flex: 1;
  max-width: 400px;
}

.topbar-search input {
  width: 100%;
  padding: 8px 14px 8px 38px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-full);
  font-size: 13.5px;
  background: var(--gray-50);
  color: var(--gray-700);
  transition: var(--transition);
  font-family: var(--font-sans);
  outline: none;
}

.topbar-search input:focus {
  border-color: var(--primary-400);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}

.topbar-search i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: 14px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.topbar-action-btn {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-500);
  font-size: 17px;
  transition: var(--transition);
}

.topbar-action-btn:hover { background: var(--gray-100); color: var(--gray-700); }

.topbar-action-btn .badge-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--red-500);
  border-radius: var(--radius-full);
  border: 2px solid #fff;
}

.topbar-divider {
  width: 1px;
  height: 28px;
  background: var(--gray-200);
  margin: 0 4px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.topbar-user:hover { background: var(--gray-100); }

.topbar-user-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary-500), var(--purple-500));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.topbar-user-info span:first-child {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
}

.topbar-user-info span:last-child {
  display: block;
  font-size: 11px;
  color: var(--gray-400);
}

/* ---------- PAGE CONTENT ---------- */
.page-content {
  padding: 28px 28px;
  flex: 1;
}

/* ---------- PAGE HEADER ---------- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 2px;
}

.page-subtitle {
  font-size: 13.5px;
  color: var(--gray-500);
}

.breadcrumb {
  background: none;
  padding: 0;
  margin-bottom: 4px;
  font-size: 12px;
}

.breadcrumb-item { color: var(--gray-400); }
.breadcrumb-item.active { color: var(--gray-700); font-weight: 500; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--gray-300); }

/* ---------- CARDS ---------- */
.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.card:hover { box-shadow: var(--shadow-md); }

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
}

.card-header-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
}

.card-body { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ---------- KPI CARDS ---------- */
.kpi-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.kpi-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.kpi-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.kpi-card.kpi-blue::after   { background: linear-gradient(90deg, var(--primary-500), var(--primary-400)); }
.kpi-card.kpi-green::after  { background: linear-gradient(90deg, var(--green-500), #4ade80); }
.kpi-card.kpi-orange::after { background: linear-gradient(90deg, var(--orange-500), #fb923c); }
.kpi-card.kpi-purple::after { background: linear-gradient(90deg, var(--purple-500), #c084fc); }

.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 14px;
}

.kpi-icon.blue   { background: var(--primary-50);  color: var(--primary-600); }
.kpi-icon.green  { background: var(--green-100);   color: var(--green-700); }
.kpi-icon.orange { background: var(--orange-100);  color: var(--orange-700); }
.kpi-icon.purple { background: var(--purple-100);  color: var(--purple-700); }

.kpi-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1;
  margin-bottom: 4px;
}

.kpi-label {
  font-size: 13px;
  color: var(--gray-500);
  font-weight: 500;
}

.kpi-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  margin-top: 10px;
}

.kpi-change.up   { background: var(--green-100);  color: var(--green-700); }
.kpi-change.down { background: var(--red-100);    color: var(--red-700); }

/* ---------- STATUS BADGES ---------- */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .2px;
}

.badge-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-connected    { background: var(--green-100);  color: var(--green-700); }
.badge-connected::before { background: var(--green-500); }

.badge-disconnected { background: var(--red-100);    color: var(--red-700); }
.badge-disconnected::before { background: var(--red-500); }

.badge-waiting      { background: var(--yellow-100); color: var(--yellow-700); }
.badge-waiting::before { background: var(--yellow-500); animation: pulse-dot 1.5s infinite; }

.badge-connecting   { background: var(--primary-50); color: var(--primary-700); }
.badge-connecting::before { background: var(--primary-500); animation: pulse-dot 1s infinite; }

.badge-error        { background: var(--red-100);    color: var(--red-700); }
.badge-error::before { background: var(--red-500); }

.badge-open         { background: var(--primary-50); color: var(--primary-700); }
.badge-open::before { background: var(--primary-500); }

.badge-closed       { background: var(--gray-100);   color: var(--gray-600); }
.badge-closed::before { background: var(--gray-400); }

.badge-pending      { background: var(--yellow-100); color: var(--yellow-700); }
.badge-pending::before { background: var(--yellow-500); }

.badge-transferred  { background: var(--purple-100); color: var(--purple-700); }
.badge-transferred::before { background: var(--purple-500); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .6; transform: scale(1.3); }
}

/* ---------- TABLES ---------- */
.table-modern {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.table-modern thead th {
  padding: 10px 14px;
  background: var(--gray-50);
  color: var(--gray-500);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

.table-modern tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: var(--transition);
}

.table-modern tbody tr:hover {
  background: var(--gray-50);
}

.table-modern tbody tr:last-child {
  border-bottom: none;
}

.table-modern td {
  padding: 12px 14px;
  vertical-align: middle;
  color: var(--gray-700);
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-table-action {
  background: none;
  border: 1px solid var(--gray-200);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--gray-500);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-table-action:hover {
  background: var(--primary-50);
  border-color: var(--primary-300);
  color: var(--primary-600);
}

.btn-table-action.danger:hover {
  background: var(--red-100);
  border-color: #fca5a5;
  color: var(--red-700);
}

/* ---------- AVATARS ---------- */
.avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary-500), var(--purple-500));
}

.avatar-sm { width: 28px; height: 28px; font-size: 10px; }
.avatar-lg { width: 48px; height: 48px; font-size: 18px; }
.avatar-xl { width: 64px; height: 64px; font-size: 24px; }

.avatar-blue   { background: linear-gradient(135deg, var(--primary-500), var(--primary-700)); }
.avatar-green  { background: linear-gradient(135deg, var(--green-500), #16a34a); }
.avatar-purple { background: linear-gradient(135deg, var(--purple-500), #7e22ce); }
.avatar-orange { background: linear-gradient(135deg, var(--orange-500), #ea580c); }

/* ---------- BUTTONS ---------- */
.btn {
  font-family: var(--font-sans);
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: #fff;
  box-shadow: 0 4px 12px rgba(26,86,219,.35);
}

.btn-outline-primary {
  border-color: var(--primary-300);
  color: var(--brand);
}

.btn-outline-primary:hover {
  background: var(--primary-50);
  border-color: var(--brand);
  color: var(--brand);
}

.btn-danger { background: var(--red-500); border-color: var(--red-500); color: #fff; }
.btn-danger:hover { background: var(--red-700); border-color: var(--red-700); color: #fff; }

.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.btn-lg { padding: 11px 24px; font-size: 15px; }

/* ---------- FORMS ---------- */
.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-control, .form-select {
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: var(--font-sans);
  color: var(--gray-800);
  background: #fff;
  transition: var(--transition);
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary-400);
  box-shadow: 0 0 0 3px rgba(59,130,246,.1);
  outline: none;
}

.form-control::placeholder { color: var(--gray-400); }

.input-group-text {
  background: var(--gray-50);
  border-color: var(--gray-300);
  color: var(--gray-500);
  font-size: 13px;
}

/* ---------- TAGS ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 500;
  background: var(--gray-100);
  color: var(--gray-600);
  border: 1px solid var(--gray-200);
}

.tag-blue   { background: var(--primary-50);  color: var(--primary-700); border-color: var(--primary-200); }
.tag-green  { background: var(--green-100);   color: var(--green-700);  border-color: #bbf7d0; }
.tag-purple { background: var(--purple-100);  color: var(--purple-700); border-color: #e9d5ff; }
.tag-orange { background: var(--orange-100);  color: var(--orange-700); border-color: #fed7aa; }
.tag-red    { background: var(--red-100);     color: var(--red-700);   border-color: #fecaca; }

/* ---------- TIMELINE ---------- */
.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--gray-200);
}

.timeline-item {
  position: relative;
  padding-bottom: 20px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary-500);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--primary-200);
}

.timeline-item.success::before { background: var(--green-500); box-shadow: 0 0 0 2px #bbf7d0; }
.timeline-item.warning::before { background: var(--yellow-500); box-shadow: 0 0 0 2px #fef08a; }
.timeline-item.danger::before  { background: var(--red-500);    box-shadow: 0 0 0 2px #fecaca; }
.timeline-item.info::before    { background: var(--primary-500); box-shadow: 0 0 0 2px var(--primary-200); }

.timeline-time {
  font-size: 11px;
  color: var(--gray-400);
  font-weight: 500;
}

.timeline-text {
  font-size: 13px;
  color: var(--gray-700);
  margin-top: 2px;
}

/* ---------- EMPTY STATE ---------- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state-icon {
  font-size: 52px;
  color: var(--gray-300);
  margin-bottom: 16px;
}

.empty-state h5 {
  font-size: 16px;
  color: var(--gray-500);
  font-weight: 600;
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 13.5px;
  color: var(--gray-400);
  max-width: 300px;
  margin: 0 auto 20px;
}

/* ---------- MODALS ---------- */
.modal-content {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  border-bottom: 1px solid var(--gray-200);
  padding: 18px 24px;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
}

.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-200); background: var(--gray-50); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ---------- CHAT MESSAGES ---------- */
.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
}

.message-bubble {
  max-width: 72%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-bubble.sent { margin-left: auto; align-items: flex-end; }
.message-bubble.received { margin-right: auto; align-items: flex-start; }

.message-content {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  position: relative;
}

.message-bubble.sent .message-content {
  background: var(--brand);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message-bubble.received .message-content {
  background: #fff;
  border: 1px solid var(--gray-200);
  color: var(--gray-800);
  border-bottom-left-radius: 4px;
}

.message-meta {
  font-size: 10.5px;
  color: var(--gray-400);
  display: flex;
  align-items: center;
  gap: 4px;
}

.message-meta i { font-size: 11px; }

/* ---------- INSTANCE CARD ---------- */
.instance-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 18px;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.instance-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-200);
}

.instance-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.instance-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #25D366, #128C7E);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  flex-shrink: 0;
}

/* ---------- CONVERSATION LIST ITEM ---------- */
.conv-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.conv-item:hover { background: var(--gray-50); }
.conv-item.active { background: var(--primary-50); border-right: 3px solid var(--primary-500); }

.conv-item-content { flex: 1; min-width: 0; }

.conv-item-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 2px;
}

.conv-item-preview {
  font-size: 12.5px;
  color: var(--gray-400);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-item-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.conv-item-time {
  font-size: 11px;
  color: var(--gray-400);
}

.conv-unread {
  background: var(--brand);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* ---------- KANBAN ---------- */
.kanban-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
  min-height: 500px;
}

.kanban-column {
  min-width: 240px;
  background: var(--gray-100);
  border-radius: var(--radius-lg);
  padding: 14px;
  flex-shrink: 0;
}

.kanban-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--gray-200);
}

.kanban-column-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
}

.kanban-count {
  background: var(--gray-300);
  color: var(--gray-600);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: var(--radius-full);
}

.kanban-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: var(--transition);
}

.kanban-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-300);
}

/* ---------- FLOW EDITOR ---------- */
.flow-editor-wrap {
  display: flex;
  height: calc(100vh - var(--topbar-height) - 70px);
  gap: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--gray-200);
  background: #fff;
}

.flow-panel-left {
  width: 220px;
  border-right: 1px solid var(--gray-200);
  background: var(--gray-50);
  padding: 16px;
  overflow-y: auto;
  flex-shrink: 0;
}

.flow-canvas {
  flex: 1;
  background: #f0f4ff;
  background-image: radial-gradient(var(--gray-300) 1px, transparent 1px);
  background-size: 24px 24px;
  position: relative;
  overflow: hidden;
}

.flow-panel-right {
  width: 260px;
  border-left: 1px solid var(--gray-200);
  background: #fff;
  padding: 16px;
  overflow-y: auto;
  flex-shrink: 0;
}

.flow-node {
  position: absolute;
  min-width: 180px;
  background: #fff;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  cursor: move;
  transition: border-color .15s;
}

.flow-node:hover, .flow-node.selected {
  border-color: var(--primary-400);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

.flow-node-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.flow-node-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

.flow-node-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--gray-800);
}

.flow-node-body {
  font-size: 11.5px;
  color: var(--gray-500);
  line-height: 1.4;
}

.flow-connector {
  position: absolute;
  pointer-events: none;
}

.flow-block-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
  background: #fff;
  cursor: grab;
  margin-bottom: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--gray-700);
  transition: var(--transition);
}

.flow-block-item:hover {
  border-color: var(--primary-300);
  background: var(--primary-50);
  color: var(--primary-700);
}

.flow-block-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

/* ---------- NAV TABS ---------- */
.nav-tabs-modern {
  border-bottom: 2px solid var(--gray-200);
  gap: 0;
  margin-bottom: 0;
}

.nav-tabs-modern .nav-link {
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--gray-500);
  border-radius: 0;
  transition: var(--transition);
}

.nav-tabs-modern .nav-link:hover { color: var(--gray-800); background: none; }

.nav-tabs-modern .nav-link.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  background: none;
  font-weight: 600;
}

/* ---------- QR CODE AREA ---------- */
.qr-container {
  width: 220px;
  height: 220px;
  background: #fff;
  border: 3px solid var(--gray-200);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

.qr-container.generating::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.8);
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-code-img {
  width: 200px;
  height: 200px;
  object-fit: contain;
}

.qr-corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: var(--primary-500);
  border-style: solid;
}

.qr-corner.tl { top: 8px; left: 8px; border-width: 3px 0 0 3px; }
.qr-corner.tr { top: 8px; right: 8px; border-width: 3px 3px 0 0; }
.qr-corner.bl { bottom: 8px; left: 8px; border-width: 0 0 3px 3px; }
.qr-corner.br { bottom: 8px; right: 8px; border-width: 0 3px 3px 0; }

/* ---------- HEALTH INDICATOR ---------- */
.health-bar {
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--gray-200);
  overflow: hidden;
  margin-top: 4px;
}

.health-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width .5s ease;
}

.health-bar-fill.good   { background: linear-gradient(90deg, var(--green-500), #4ade80); }
.health-bar-fill.medium { background: linear-gradient(90deg, var(--yellow-500), #fbbf24); }
.health-bar-fill.bad    { background: linear-gradient(90deg, var(--red-500),   #f87171); }

/* ---------- SCROLLBAR ---------- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ---------- UTILITIES ---------- */
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.text-xs  { font-size: 11px; }
.text-sm  { font-size: 12.5px; }
.text-base{ font-size: 14px; }

.border-dashed { border-style: dashed !important; }

.rounded-xl { border-radius: var(--radius-xl) !important; }

.shadow-hover { transition: box-shadow .2s; }
.shadow-hover:hover { box-shadow: var(--shadow-md); }

.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

/* ---------- LOADING SKELETON ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- NOTIFICATION TOAST ---------- */
.toast-container { z-index: 9999; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 992px) {
  :root {
    --sidebar-width: var(--sidebar-collapsed);
  }

  .sidebar-brand-name,
  .nav-label,
  .nav-badge,
  .sidebar-section-title,
  .sidebar-user-info {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .page-content { padding: 16px; }
  .topbar-search { display: none; }
}

/* ---------- LOGIN PAGE ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  background: #f1f5f9;
}

.login-left {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 50%, #2563eb 100%);
  position: relative;
  overflow: hidden;
}

.login-left::before {
  content: '';
  position: absolute;
  top: -30%;
  right: -10%;
  width: 60%;
  padding-bottom: 60%;
  background: rgba(255,255,255,.05);
  border-radius: 50%;
}

.login-left::after {
  content: '';
  position: absolute;
  bottom: -20%;
  left: -10%;
  width: 50%;
  padding-bottom: 50%;
  background: rgba(255,255,255,.04);
  border-radius: 50%;
}

.login-right {
  width: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: #fff;
}

.login-box { width: 100%; max-width: 380px; }
.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.login-logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  font-weight: 800;
}

.login-feature-list {
  list-style: none;
  padding: 0;
  margin: 0;
  position: relative;
  z-index: 1;
}

.login-feature-list li {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
  color: #fff;
}

.login-feature-icon {
  width: 44px;
  height: 44px;
  background: rgba(255,255,255,.15);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

@media (max-width: 900px) {
  .login-left { display: none; }
  .login-right { width: 100%; }
}

/* ---------- INBOX SPECIFIC ---------- */
.inbox-wrap {
  display: flex;
  height: calc(100vh - var(--topbar-height));
  background: #fff;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--gray-200);
}

.inbox-sidebar {
  width: 320px;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.inbox-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.inbox-detail {
  width: 280px;
  border-left: 1px solid var(--gray-200);
  flex-shrink: 0;
  overflow-y: auto;
}

.chat-input-area {
  border-top: 1px solid var(--gray-200);
  padding: 12px 16px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #fff;
}

.chat-input {
  flex: 1;
  border: 1px solid var(--gray-200);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-family: var(--font-sans);
  resize: none;
  outline: none;
  transition: var(--transition);
  max-height: 120px;
}

.chat-input:focus {
  border-color: var(--primary-400);
  box-shadow: 0 0 0 3px rgba(59,130,246,.08);
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  background: var(--brand);
  border: none;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.chat-send-btn:hover { background: var(--brand-dark); }

/* ---------- CODE BLOCK ---------- */
.code-block {
  background: var(--gray-900);
  border-radius: var(--radius-md);
  padding: 16px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: #e2e8f0;
  overflow-x: auto;
  max-height: 300px;
  overflow-y: auto;
}
