:root {
  --bg-color: #0B0E17;
  --sidebar-bg: #0F121D;
  --card-bg: #141824;
  --card-border: rgba(255, 255, 255, 0.08);
  --header-bg: rgba(11, 14, 23, 0.8);
  
  --text-main: #FFFFFF;
  --text-muted: #94A3B8;
  
  --accent: #6366F1;
  --accent-hover: #4F46E5;
  
  --success: #22C55E;
  --warning: #F59E0B;
  --danger: #EF4444;
  
  --input-bg: #1B2033;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  
  --shadow-card: 0px 4px 20px -2px rgba(0, 0, 0, 0.4);
}

body.light-mode {
  --bg-color: #F8FAFC;
  --sidebar-bg: #FFFFFF;
  --card-bg: #FFFFFF;
  --card-border: rgba(0, 0, 0, 0.08);
  --header-bg: rgba(255, 255, 255, 0.8);
  
  --text-main: #0F172A;
  --text-muted: #64748B;
  
  --input-bg: #F1F5F9;
  
  --shadow-card: 0px 4px 20px -2px rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  overflow: hidden;
  transition: background-color 0.3s, color 0.3s;
}

.hidden { display: none !important; }

/* Utilities */
.mb-4 { margin-bottom: 24px; }
.mt-4 { margin-top: 24px; }
.p-0 { padding: 0 !important; }
.p-3 { padding: 16px; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--text-muted); }
.text-white { color: var(--text-main); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-center { text-align: center; }
.bg-inset { background-color: var(--input-bg); }
.rounded-lg { border-radius: var(--radius-lg); }

/* Overlay */
.overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(11, 14, 23, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.overlay.active { opacity: 1; pointer-events: auto; }
.login-box {
  width: 420px;
  text-align: center;
  padding: 40px;
}
.login-box p { color: var(--text-muted); margin-bottom: 24px; font-size: 14px; }

/* Layout */
.dashboard {
  display: flex;
  width: 100%;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s;
}
.sidebar-header {
  padding: 24px;
  height: 72px;
  display: flex;
  align-items: center;
}
.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 20px;
  color: var(--text-main);
  letter-spacing: -0.5px;
}
.cube-icon {
  background: var(--accent);
  color: #fff;
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.brand-logo .dot { color: var(--accent); }

.sidebar-menu {
  flex-grow: 1;
  padding: 0 16px;
  overflow-y: auto;
}
.menu-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin: 24px 0 12px 12px;
}
.nav-links {
  list-style: none;
}
.nav-links li {
  margin-bottom: 4px;
  cursor: pointer;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s;
}
.nav-item i { font-size: 16px; width: 20px; text-align: center; }
.nav-links li:hover .nav-item {
  color: var(--text-main);
  background: rgba(150, 150, 150, 0.05);
}
.nav-links li.active .nav-item {
  color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
}

.sidebar-footer { padding: 24px; }

/* Main Wrapper */
.main-wrapper {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Top Header */
.top-header {
  height: 72px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-border);
  z-index: 10;
  transition: background-color 0.3s;
}
.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
  position: relative;
}
.icon-btn:hover { background: rgba(150,150,150,0.1); color: var(--text-main); }
.indicator {
  position: absolute;
  top: 8px; right: 8px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--header-bg);
  display: none; /* hidden by default */
}

/* Dropdown */
.dropdown-menu {
  position: absolute;
  top: 55px; right: 0;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  width: 320px;
  max-height: 400px;
  display: none;
  flex-direction: column;
  z-index: 100;
}
.dropdown-menu.show { display: flex; }
.dropdown-header {
  padding: 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--card-border);
  font-size: 14px;
}
.dropdown-body {
  overflow-y: auto;
  max-height: 300px;
}
.dropdown-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--card-border);
  font-size: 13px;
}
.dropdown-item:last-child { border-bottom: none; }

.search-bar {
  display: flex;
  align-items: center;
  background: var(--input-bg);
  padding: 0 16px;
  border-radius: 20px;
  height: 40px;
  gap: 10px;
  border: 1px solid transparent;
  transition: 0.2s;
}
.search-bar:focus-within { border-color: rgba(99,102,241,0.5); }
.search-bar i { color: var(--text-muted); }
.search-bar input {
  background: transparent;
  border: none;
  color: var(--text-main);
  outline: none;
  width: 200px;
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.search-bar .shortcut {
  font-size: 10px;
  background: rgba(150,150,150,0.2);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-muted);
}
.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: 16px;
  padding-left: 24px;
  border-left: 1px solid var(--card-border);
  cursor: pointer;
}
.avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), #9333ea);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}
.user-info { display: flex; flex-direction: column; }
.user-info .name { font-size: 13px; font-weight: 600; }
.user-info .role { font-size: 11px; color: var(--text-muted); }

/* Main Content Area */
.main-content {
  flex-grow: 1;
  padding: 32px;
  overflow-y: auto;
}
.breadcrumbs {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
  font-weight: 500;
}
#breadcrumb-current { color: var(--text-main); }
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 32px;
}
.page-header h1 { font-size: 28px; font-weight: 700; margin-bottom: 8px; letter-spacing: -0.5px; }
.page-header .subtitle { color: var(--text-muted); font-size: 15px; }
.header-actions { display: flex; gap: 12px; align-items: center; }

/* Components */
.vela-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
  transition: background-color 0.3s;
}
.vela-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--input-bg);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  border-radius: var(--radius-md);
  outline: none;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px;
  transition: 0.2s;
}
.vela-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(99,102,241,0.2); }
.vela-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s;
  font-family: 'Plus Jakarta Sans', sans-serif;
  text-decoration: none;
  box-sizing: border-box;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-secondary { background: var(--input-bg); color: var(--text-main); border: 1px solid var(--card-border); }
.btn-secondary:hover { background: rgba(150,150,150,0.1); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #DC2626; }
.btn-sm { padding: 8px 12px; font-size: 13px; }

/* Switch Toggle */
.switch-toggle {
  display: flex;
  background: var(--input-bg);
  border-radius: var(--radius-md);
  padding: 4px;
  border: 1px solid var(--card-border);
}
.switch-toggle .vela-btn { padding: 6px 16px; border: none; box-shadow: none; border-radius: var(--radius-sm); }
.switch-toggle .btn-primary { background: var(--card-bg); color: var(--text-main); box-shadow: 0 1px 3px rgba(0,0,0,0.1); border: 1px solid var(--card-border); }
.switch-toggle .btn-secondary { background: transparent; color: var(--text-muted); border: 1px solid transparent; }

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
}
.stat-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
  overflow: hidden;
}
.stat-top { display: flex; justify-content: space-between; align-items: flex-start; }
.icon-box {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.icon-box.purple { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.icon-box.green { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.icon-box.cyan { background: rgba(6, 182, 212, 0.15); color: #06b6d4; }
.icon-box.yellow { background: rgba(234, 179, 8, 0.15); color: #eab308; }

.trend-pill {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: var(--input-bg);
}
.trend-pill.positive { color: var(--success); }
.trend-pill.warning { color: var(--warning); }

.stat-mid { display: flex; flex-direction: column; gap: 8px; }
.stat-mid .label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.stat-mid h3 { font-size: 32px; font-weight: 700; letter-spacing: -1px; line-height: 1; }

.stat-bottom { height: 40px; margin-top: 10px; opacity: 0.6; }
.sparkline { width: 100%; height: 100%; }
.sparkline.purple { stroke: #a855f7; }
.sparkline.green { stroke: #22c55e; }
.sparkline.cyan { stroke: #06b6d4; }
.sparkline.yellow { stroke: #eab308; }

/* Table */
.card-header { padding: 20px 24px; border-bottom: 1px solid var(--card-border); }
.card-header h3 { font-size: 16px; font-weight: 600; }
.vela-table { width: 100%; border-collapse: collapse; }
.vela-table th, .vela-table td { padding: 16px 24px; text-align: left; border-bottom: 1px solid var(--card-border); }
.vela-table th { font-size: 11px; font-weight: 700; color: var(--text-muted); letter-spacing: 1px; }
.vela-table td { font-size: 14px; font-weight: 500; }
.vela-table tr:last-child td { border-bottom: none; }

/* Status Badges */
.status-badge { padding: 6px 12px; border-radius: 6px; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.status-badge::before { content:''; display:block; width:6px; height:6px; border-radius:50%; }
.badge-connected { background: rgba(34, 197, 94, 0.1); color: var(--success); }
.badge-connected::before { background: var(--success); }
.badge-qr { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.badge-qr::before { background: var(--warning); }
.badge-error { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.badge-error::before { background: var(--danger); }
.badge-loading { background: rgba(99, 102, 241, 0.1); color: var(--accent); }
.badge-loading::before { background: var(--accent); }

/* Chat Container */
.filter-bar { display: flex; gap: 16px; align-items: center; }
.select-sm { width: 220px; }
.chat-wrapper { display: flex; flex-direction: column; gap: 20px; max-height: 600px; overflow-y: auto; padding: 24px; }
.message-bubble { max-width: 60%; padding: 16px 20px; border-radius: 16px; font-size: 14px; line-height: 1.5; }
.msg-in { background: var(--input-bg); align-self: flex-start; border-bottom-left-radius: 4px; border: 1px solid var(--card-border); }
.msg-out { background: var(--accent); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; box-shadow: 0 4px 12px rgba(99,102,241,0.2); }
.msg-out .msg-meta { color: rgba(255,255,255,0.8); }
.msg-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); margin-top: 8px; gap: 24px; font-weight: 500; }

/* Checkbox Grid for Bulk Accounts */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}
.checkbox-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--input-bg);
  border: 1px solid var(--card-border);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: 0.2s;
  user-select: none;
}
.checkbox-card:hover {
  border-color: rgba(99,102,241,0.5);
}
.checkbox-card input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.checkbox-card span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

/* Grid Forms */
.content-grid-2-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
.form-panel { padding: 0; }
.form-body { padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 600; color: var(--text-muted); }

/* Toasts */
.toast-container { position: fixed; bottom: 32px; right: 32px; z-index: 2000; display: flex; flex-direction: column; gap: 12px; }
.toast { background: var(--card-bg); border: 1px solid var(--card-border); color: var(--text-main); padding: 16px 24px; border-radius: var(--radius-md); box-shadow: var(--shadow-card); animation: slideIn 0.3s forwards; font-weight: 500; font-size: 14px; }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Premium Login Design */
.login-wrapper {
  display: flex;
  width: 1000px;
  max-width: 100%;
  height: 600px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.login-left {
  flex: 1;
  background: linear-gradient(135deg, rgba(99,102,241,0.9) 0%, rgba(139,92,246,0.9) 100%), url('https://images.unsplash.com/photo-1550751827-4bd374c3f58b?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80') center/cover;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: white;
  position: relative;
}
.login-left::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.2);
}
.login-left > * { position: relative; z-index: 1; }
.login-branding {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 24px;
  font-weight: 700;
}
.login-hero-text h2 { font-size: 36px; font-weight: 700; margin-bottom: 16px; line-height: 1.2; color: #fff; }
.login-hero-text p { font-size: 16px; color: rgba(255,255,255,0.8); line-height: 1.6; max-width: 80%; }
.login-footer-text { font-size: 13px; color: rgba(255,255,255,0.6); }

.login-right {
  flex: 1;
  background: var(--card-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}
.login-form-container { width: 100%; max-width: 360px; }
.login-form-container h3 { font-size: 28px; font-weight: 700; margin-bottom: 8px; color: var(--text-main); }
.login-form-container p { font-size: 14px; color: var(--text-muted); margin-bottom: 32px; }

.input-with-icon { position: relative; }

@keyframes slideUpFade {
  0% { opacity: 0; transform: translateY(40px) scale(0.95); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 768px) {
  .login-wrapper { flex-direction: column; height: auto; }
  .login-left { padding: 32px; min-height: 250px; }
  .login-right { padding: 32px; }
}

.mobile-menu-btn { display: none; }

@media (max-width: 1024px) {
  .dashboard { grid-template-columns: 1fr; }
  .mobile-menu-btn { display: flex; }
  
  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    bottom: 0;
    width: 260px;
    z-index: 9999;
    transition: left 0.3s;
    box-shadow: var(--shadow-card);
  }
  .sidebar.open { left: 0; }
  
  .table-container { overflow-x: auto; }
  .content-grid, .content-grid-2-3 { grid-template-columns: 1fr; }
  .top-header { flex-direction: column; gap: 16px; padding: 16px; height: auto; align-items: flex-start; }
  .header-left, .header-right { width: 100%; justify-content: space-between; }
  .search-bar { width: 100%; max-width: none; }
  .main-wrapper { padding: 12px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .overlay .vela-card { width: 95% !important; padding: 20px; }
}
