:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a2e;
  --bg-hover: #22223a;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --accent-glow: rgba(108, 92, 231, 0.3);
  --text-primary: #f0f0f5;
  --text-secondary: #9090a8;
  --text-muted: #606078;
  --border: #2a2a3e;
  --success: #00cec9;
  --warning: #fdcb6e;
  --danger: #e17055;
  --msg-user: #1e1e3a;
  --msg-ai: #0f0f1e;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Login Screen ── */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  padding: 20px;
}

.login-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-card .subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 32px;
}

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

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

.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-light);
  box-shadow: 0 0 20px var(--accent-glow);
}
.btn-danger {
  background: #e74c3c;
  color: white;
}
.btn-danger:hover {
  background: #c0392b;
  box-shadow: 0 0 20px rgba(231, 76, 60, 0.3);
}

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

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

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
}

.toggle-link {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.toggle-link a {
  color: var(--accent-light);
  text-decoration: none;
  cursor: pointer;
}

.toggle-link a:hover { text-decoration: underline; }

/* ── App Layout ── */
.app {
  display: flex;
  height: 100dvh;
}

/* ── Sidebar ── */
.sidebar {
  width: 280px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  font-size: 16px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-header .user-info {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.new-chat-btn {
  margin: 12px 16px;
  padding: 10px;
  background: var(--bg-tertiary);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.new-chat-btn:hover {
  border-color: var(--accent);
  color: var(--accent-light);
  background: rgba(108, 92, 231, 0.05);
}

.conversations-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.conv-item {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 2px;
}

.conv-item:hover { background: var(--bg-hover); }
.conv-item.active { background: var(--bg-tertiary); border: 1px solid var(--border); }

.conv-item .conv-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-item .conv-preview {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}

.sidebar-footer button {
  flex: 1;
  padding: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
}

.sidebar-footer button:hover { color: var(--text-primary); background: var(--bg-hover); }

/* ── Chat Area ── */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

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

.chat-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  scroll-behavior: smooth;
}

.message {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  max-width: 800px;
}

.message.user { flex-direction: row-reverse; margin-left: auto; }

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.message.assistant .message-avatar {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: white;
}

.message.user .message-avatar {
  background: var(--bg-tertiary);
  color: var(--accent-light);
  border: 1px solid var(--border);
}

.message-body {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.6;
  max-width: 85%;
}

.message.assistant .message-body {
  background: var(--msg-ai);
  border: 1px solid var(--border);
}

.message.user .message-body {
  background: var(--msg-user);
  border: 1px solid rgba(108, 92, 231, 0.2);
}

.message-body p { margin-bottom: 8px; }
.message-body p:last-child { margin-bottom: 0; }
.message-body code {
  background: rgba(108, 92, 231, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}
.message-body pre {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow-x: auto;
  margin: 8px 0;
}
.message-body pre code {
  background: none;
  padding: 0;
}

.message-body ul, .message-body ol {
  padding-left: 20px;
  margin: 8px 0;
}

.voice-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  animation: typing 1.2s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* ── Input Area ── */
.input-area {
  padding: 16px 24px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.input-wrapper {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 800px;
  margin: 0 auto;
}

.input-wrapper textarea {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  resize: none;
  outline: none;
  min-height: 48px;
  max-height: 160px;
  line-height: 1.5;
  transition: border-color 0.2s;
}

.input-wrapper textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-wrapper textarea::placeholder { color: var(--text-muted); }

.voice-btn, .send-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.voice-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.voice-btn:hover { border-color: var(--accent); color: var(--accent-light); }
.voice-btn.recording {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(225, 112, 85, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(225, 112, 85, 0); }
}

.send-btn {
  background: var(--accent);
  color: white;
}

.send-btn:hover { background: var(--accent-light); box-shadow: 0 0 16px var(--accent-glow); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Welcome Screen ── */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 40px;
}

.welcome h2 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.welcome p {
  color: var(--text-secondary);
  font-size: 15px;
  max-width: 400px;
  line-height: 1.6;
}

.welcome-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 32px;
  max-width: 600px;
  width: 100%;
}

.welcome-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
}

.welcome-card:hover {
  border-color: var(--accent);
  background: var(--bg-tertiary);
}

.welcome-card h4 { font-size: 13px; color: var(--accent-light); margin-bottom: 4px; }
.welcome-card p { font-size: 12px; color: var(--text-muted); }

/* ── Admin Panel ── */
.admin-section {
  padding: 24px;
  overflow-y: auto;
}

.admin-section h3 {
  font-size: 18px;
  margin-bottom: 16px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}

.admin-table th, .admin-table td {
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.admin-table th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.admin-table th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: color 0.15s;
}
.admin-table th.sortable:hover {
  color: var(--accent);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.badge-admin { background: rgba(108, 92, 231, 0.2); color: var(--accent-light); }
.badge-active { background: rgba(0, 206, 201, 0.2); color: var(--success); }
.badge-inactive { background: rgba(225, 112, 85, 0.2); color: var(--danger); }

.invite-code {
  font-family: monospace;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-light);
  background: var(--bg-tertiary);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  display: inline-block;
  letter-spacing: 2px;
}

/* ── Navigation Tabs ── */
.nav-tabs {
  display: flex;
  padding: 8px 12px;
  gap: 4px;
  border-bottom: 1px solid var(--border);
}

.nav-tab {
  flex: 1;
  padding: 8px 4px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nav-tab:hover { color: var(--text-secondary); background: var(--bg-hover); }
.nav-tab.active { color: var(--accent-light); background: rgba(108, 92, 231, 0.1); }
.nav-tab { position: relative; }
.nav-badge {
  position: absolute; top: 2px; right: 2px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--danger, #ef4444); color: white;
  font-size: 9px; font-weight: 700; line-height: 16px; text-align: center;
}

/* ── Employee Dashboard ── */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.dash-card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.dash-card-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 8px; }
.dash-card-value { font-size: 28px; font-weight: 700; color: var(--text-primary); }
.dash-card-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.dash-card.accent { border-color: var(--accent); }
.dash-card.warn { border-color: var(--warning, #f59e0b); }
.dash-card.danger { border-color: var(--danger, #ef4444); }
.dash-card.success { border-color: var(--success, #22c55e); }
.dash-section { margin-bottom: 24px; }
.dash-section-title { font-size: 14px; font-weight: 600; color: var(--text-secondary); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.dash-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; cursor: pointer; transition: border-color 0.2s; }
.dash-item:hover { border-color: var(--accent); }
.dash-item-icon { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.dash-item-info { flex: 1; min-width: 0; }
.dash-item-title { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-item-meta { font-size: 11px; color: var(--text-muted); }
.dash-item-badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.dash-loading { text-align: center; color: var(--text-muted); padding: 40px; }
.tab-loading {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 32px; color: var(--text-secondary); font-size: 13px;
}
.tab-loading-spinner {
  width: 18px; height: 18px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: tab-spin 0.8s linear infinite;
}
@keyframes tab-spin { to { transform: rotate(360deg); } }
.dash-quick-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }
.dash-quick-btn { padding: 8px 16px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-secondary); font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.dash-quick-btn:hover { border-color: var(--accent); color: var(--accent-light); background: rgba(108, 92, 231, 0.1); }

/* ── Pipeline Board ── */
.pipeline-stats { display: flex; gap: 12px; padding: 0 20px 16px; flex-wrap: wrap; }
.pipeline-stat { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 16px; min-width: 100px; }
.pipeline-stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 4px; }
.pipeline-stat-value { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.pipeline-stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.pipeline-stat.accent { border-color: var(--accent); }
.pipeline-stat.success { border-color: var(--success); }
.pipeline-stat.warn { border-color: var(--warning); }
.pipeline-board { display: flex; gap: 12px; padding: 0 20px 20px; overflow-x: auto; min-height: 300px; }
.pipeline-column { flex: 0 0 220px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 280px); }
.pipeline-col-header { padding: 12px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.pipeline-col-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; color: var(--text-secondary); }
.pipeline-col-count { font-size: 11px; color: var(--text-muted); background: var(--bg-tertiary); border-radius: 10px; padding: 2px 8px; }
.pipeline-col-body { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.pipeline-deal { background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; cursor: pointer; transition: border-color 0.2s; }
.pipeline-deal:hover { border-color: var(--accent); }
.pipeline-deal-name { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.pipeline-deal-company { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
.pipeline-deal-value { font-size: 12px; font-weight: 700; color: var(--success); }
.pipeline-deal-product { font-size: 10px; color: var(--text-muted); margin-top: 4px; }
.commission-summary { padding: 0 20px 20px; }
.commission-card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.commission-card h4 { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 12px; }
.commission-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.commission-item { text-align: center; }
.commission-item-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 4px; }
.commission-item-value { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.commission-item-value.green { color: var(--success); }

/* ── Panel Views ── */
.panel-view {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 280px;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  z-index: 50;
}

.panel-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

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

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.filter-bar select {
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
}

/* ── Training Cards ── */
.training-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

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

.training-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.training-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.training-card-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.category-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.cat-onboarding { background: rgba(0, 206, 201, 0.15); color: var(--success); }
.cat-sales { background: rgba(108, 92, 231, 0.15); color: var(--accent-light); }
.cat-qualification { background: rgba(253, 203, 110, 0.15); color: var(--warning); }
.cat-account_mgmt { background: rgba(99, 110, 114, 0.2); color: #b2bec3; }
.cat-processes { background: rgba(225, 112, 85, 0.15); color: var(--danger); }
.cat-products { background: rgba(0, 184, 148, 0.15); color: #00b894; }

.type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.type-pitch_deck { background: rgba(255, 107, 107, 0.15); color: #ff6b6b; }
.type-objection_handling { background: rgba(255, 159, 67, 0.15); color: #ff9f43; }
.type-product_knowledge { background: rgba(54, 174, 124, 0.15); color: #36ae7c; }
.type-process_guide { background: rgba(72, 149, 239, 0.15); color: #4895ef; }
.type-general { background: rgba(99, 110, 114, 0.15); color: #b2bec3; }

.progress-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.prog-not_started { background: var(--bg-tertiary); color: var(--text-muted); }
.prog-assigned { background: rgba(253, 203, 110, 0.15); color: var(--warning); }
.prog-in_progress { background: rgba(108, 92, 231, 0.15); color: var(--accent-light); }
.prog-completed { background: rgba(0, 206, 201, 0.15); color: var(--success); }

.priority-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* Referral Partners */
.referral-partners-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.partner-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}
.partner-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  font-size: 14px;
}
.partner-card-company {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.partner-card-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.partner-card-link input {
  cursor: pointer;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.status-active { background: var(--success); }
.status-inactive { background: var(--text-muted); }
.referral-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.rs-new { background: rgba(108, 92, 231, 0.15); color: var(--accent-light); }
.rs-contacted { background: rgba(253, 203, 110, 0.15); color: var(--warning); }
.rs-converted { background: rgba(0, 206, 201, 0.15); color: var(--success); }

.priority-dot.p-2 { background: var(--danger); }
.priority-dot.p-1 { background: var(--warning); }
.priority-dot.p-0 { background: var(--text-muted); }

/* ── Task Cards ── */
.task-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.2s;
}

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

.task-priority-bar {
  width: 4px;
  height: 40px;
  border-radius: 2px;
  flex-shrink: 0;
}

.task-priority-bar.urgent { background: var(--danger); }
.task-priority-bar.high { background: var(--warning); }
.task-priority-bar.normal { background: var(--accent); }
.task-priority-bar.low { background: var(--text-muted); }

.task-info { flex: 1; }
.task-title { font-size: 14px; font-weight: 600; }
.task-desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.task-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.task-actions {
  display: flex;
  gap: 6px;
}

.task-status-btn {
  padding: 4px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

.task-status-btn:hover { border-color: var(--accent); color: var(--accent-light); }
.task-status-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

.task-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

.task-stat-val { font-weight: 700; color: var(--accent-light); }

/* ── Process Cards ── */
.process-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

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

.process-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.process-name { font-size: 15px; font-weight: 600; }
.process-meta { display: flex; gap: 8px; margin-top: 8px; }

.type-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.type-manual { background: rgba(253, 203, 110, 0.15); color: var(--warning); }
.type-automated { background: rgba(0, 206, 201, 0.15); color: var(--success); }
.type-hybrid { background: rgba(108, 92, 231, 0.15); color: var(--accent-light); }

.step-count { font-size: 12px; color: var(--text-muted); }

/* ── Process Steps Display ── */
.process-steps-list {
  list-style: none;
  padding: 0;
  counter-reset: step-counter;
}

.process-steps-list li {
  counter-increment: step-counter;
  padding: 12px 16px 12px 48px;
  position: relative;
  border-left: 2px solid var(--border);
  margin-left: 16px;
}

.process-steps-list li:last-child { border-left-color: transparent; }

.process-steps-list li::before {
  content: counter(step-counter);
  position: absolute;
  left: -13px;
  top: 12px;
  width: 24px;
  height: 24px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
}

/* ── Modal Styles ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 200;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  padding: 40px 20px;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-height: fit-content;
  align-self: flex-start;
}

.modal-lg { max-width: 700px; }
.modal-xl { max-width: 900px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
}

.modal-close:hover { color: var(--text-primary); }

.modal-meta {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.modal-body {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-primary);
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 8px;
}

.modal-body h1, .modal-body h2, .modal-body h3 { margin: 16px 0 8px; }
.modal-body p { margin-bottom: 12px; }
.modal-body ul, .modal-body ol { padding-left: 24px; margin-bottom: 12px; }
.modal-body li { margin-bottom: 4px; }
.modal-body code { background: rgba(108, 92, 231, 0.15); padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.modal-body pre { background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; overflow-x: auto; margin: 8px 0; }

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

/* ── Admin Tabs ── */
.admin-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.admin-tab {
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.admin-tab:hover { color: var(--text-secondary); }
.admin-tab.active { color: var(--accent-light); border-bottom-color: var(--accent); }

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

.section-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.inline-form {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  align-items: center;
}

.admin-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

/* ── Form Styles ── */
.form-select {
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
}

.form-input {
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  flex: 1;
}

.form-textarea {
  width: 100%;
  padding: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  margin-top: 8px;
}

.form-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.create-form {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--accent-light);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover { background: var(--accent); color: white; }

.proc-step-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
  align-items: center;
}

.proc-step-input { flex: 1; }

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

.stat-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent-light);
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Order Cards ── */
.order-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 16px;
}

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

.order-card-info { flex: 1; min-width: 0; }

.order-number {
  font-family: monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-light);
}

.order-client {
  font-size: 15px;
  font-weight: 600;
  margin-top: 2px;
}

.order-product-name {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.order-card-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.order-amount {
  font-size: 16px;
  font-weight: 700;
  color: var(--success);
}

.order-status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.os-new { background: rgba(108, 92, 231, 0.15); color: var(--accent-light); }
.os-in_progress { background: rgba(253, 203, 110, 0.15); color: var(--warning); }
.os-fulfilled { background: rgba(0, 206, 201, 0.15); color: var(--success); }
.os-cancelled { background: rgba(225, 112, 85, 0.15); color: var(--danger); }

.progress-bar-container {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  margin-top: 8px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--success));
  transition: width 0.3s;
}

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

/* ── Fulfillment Checklist ── */
.fulfillment-checklist {
  list-style: none;
  padding: 0;
}

.fulfillment-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

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

.fi-checkbox {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
  font-size: 14px;
  color: transparent;
}

.fi-checkbox:hover { border-color: var(--accent); }
.fi-checkbox.checked { background: var(--success); border-color: var(--success); color: white; }
.fi-checkbox.skipped { background: var(--text-muted); border-color: var(--text-muted); color: white; }

.fi-info { flex: 1; }
.fi-title { font-size: 14px; font-weight: 500; }
.fi-title.done { text-decoration: line-through; color: var(--text-muted); }
.fi-desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.fi-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.fi-type-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 6px;
  font-weight: 600;
}

.fi-type-manual { background: rgba(253, 203, 110, 0.15); color: var(--warning); }
.fi-type-automated { background: rgba(0, 206, 201, 0.15); color: var(--success); }
.fi-type-hybrid { background: rgba(108, 92, 231, 0.15); color: var(--accent-light); }

.order-client-info {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 13px;
}

.order-client-info span { color: var(--text-muted); }
.order-client-info strong { color: var(--text-primary); }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state h4 { color: var(--text-secondary); margin-bottom: 8px; }

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

/* ── Mobile ── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
  }

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

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

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

  .menu-toggle { display: block; }

  .messages { padding: 16px; }
  .input-area { padding: 12px 16px 16px; }

  .message-body { max-width: 90%; }

  .welcome-cards { grid-template-columns: 1fr; }

  .panel-view { left: 0; }

  .panel-menu-toggle { display: block; }

  .nav-tabs { padding: 6px 8px; gap: 2px; }
  .nav-tab { font-size: 10px; padding: 6px 2px; }

  .modal-content { padding: 20px; margin: 20px 0; }
  .admin-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .admin-tab { white-space: nowrap; font-size: 12px; padding: 8px 12px; }

  .form-row { flex-direction: column; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .notif-panel { width: 100% !important; right: 0 !important; top: 50px !important; max-height: 60vh !important; }
}

/* ── Notifications ── */
.header-actions { display: flex; align-items: center; gap: 8px; }
.notif-bell { background: none; border: none; color: var(--text-secondary); cursor: pointer; position: relative; padding: 6px; border-radius: 6px; transition: all 0.2s; }
.notif-bell:hover { color: var(--accent); background: rgba(79,195,247,0.1); }
.notif-badge { position: absolute; top: 0; right: 0; background: var(--danger, #e53935); color: #fff; font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.notif-panel { position: fixed; top: 55px; right: 16px; width: 380px; max-height: 70vh; background: var(--bg-secondary, #1a1a2e); border: 1px solid var(--border, #333); border-radius: 12px; z-index: 1000; box-shadow: 0 8px 32px rgba(0,0,0,0.5); display: flex; flex-direction: column; overflow: hidden; }
.notif-panel-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border, #333); }
.notif-panel-header h4 { margin: 0; color: var(--text-primary, #fff); font-size: 14px; }
.notif-mark-all { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 12px; padding: 4px 8px; border-radius: 4px; }
.notif-mark-all:hover { background: rgba(79,195,247,0.1); }
.notif-panel-list { overflow-y: auto; max-height: 60vh; }
.notif-empty { text-align: center; color: var(--text-secondary, #888); padding: 32px 16px; font-size: 14px; }
.notif-item { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.04); cursor: pointer; transition: background 0.15s; }
.notif-item:hover { background: rgba(79,195,247,0.05); }
.notif-item.unread { background: rgba(79,195,247,0.04); }
.notif-item.unread .notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 6px; flex-shrink: 0; }
.notif-item .notif-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.notif-item-content { flex: 1; min-width: 0; }
.notif-item-title { font-size: 13px; font-weight: 600; color: var(--text-primary, #fff); margin-bottom: 2px; }
.notif-item-body { font-size: 12px; color: var(--text-secondary, #aaa); line-height: 1.4; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.notif-item-meta { font-size: 11px; color: var(--text-tertiary, #666); margin-top: 4px; }
.notif-item-dismiss { background: none; border: none; color: var(--text-secondary, #666); cursor: pointer; padding: 4px; font-size: 16px; line-height: 1; opacity: 0; transition: opacity 0.15s; flex-shrink: 0; }
.notif-item:hover .notif-item-dismiss { opacity: 1; }
.notif-priority-urgent .notif-item-title { color: var(--danger, #e53935); }
.notif-priority-high .notif-item-title { color: #ff9800; }

/* ── Background Task Messages ── */
.message.background-task .message-body {
  border-left: 3px solid var(--accent);
  padding-left: 14px;
}

.message.task-error .message-body {
  border-left: 3px solid var(--danger);
  padding-left: 14px;
}

/* ── Task Running Badge ── */
.task-running-badge {
  position: fixed;
  top: 12px;
  right: 80px;
  background: var(--accent);
  color: white;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  z-index: 500;
  display: none;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 12px var(--accent-glow);
  animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
  0%, 100% { box-shadow: 0 2px 12px var(--accent-glow); }
  50% { box-shadow: 0 2px 20px var(--accent-glow); }
}

/* ── Toast Notifications ── */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateX(100%);
  transition: opacity 0.3s ease, transform 0.3s ease;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.visible {
  opacity: 1;
  transform: translateX(0);
}
.toast.toast-success { border-left-color: #2ecc71; }
.toast.toast-error   { border-left-color: #e74c3c; }
.toast.toast-warning { border-left-color: #f39c12; }
.toast.toast-info    { border-left-color: #3498db; }
.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast-success .toast-icon { color: #2ecc71; }
.toast-error .toast-icon   { color: #e74c3c; }
.toast-warning .toast-icon { color: #f39c12; }
.toast-info .toast-icon    { color: #3498db; }
.toast-msg { flex: 1; line-height: 1.4; }
.toast-close {
  background: none; border: none; color: var(--text-secondary); cursor: pointer;
  font-size: 16px; padding: 0 0 0 8px; opacity: 0.6; flex-shrink: 0;
}
.toast-close:hover { opacity: 1; }

/* Legacy task toast (keep for backward compat) */
.task-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  color: var(--text-primary);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  z-index: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
}

.task-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Video Factory ── */
.video-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.video-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.video-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
  border-color: var(--accent);
}
.video-preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.batch-progress-bar {
  display: inline-block;
  width: 100px;
  height: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  overflow: hidden;
  vertical-align: middle;
}
.batch-progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}
