/* ============================================
   PYNGYN WORKSPACE — Design System
   ============================================ */
:root {
  --primary: #F97316;
  --primary-50: #FFF7ED;
  --primary-100: #FFEDD5;
  --primary-500: #F97316;
  --primary-600: #EA580C;
  --primary-700: #C2410C;

  --slate-50: #F8FAFC;
  --slate-100: #F1F5F9;
  --slate-200: #E2E8F0;
  --slate-300: #CBD5E1;
  --slate-400: #94A3B8;
  --slate-500: #64748B;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1E293B;
  --slate-900: #0F172A;
  --slate-950: #020617;

  --success: #22C55E;
  --success-50: #F0FDF4;
  --warning: #F59E0B;
  --warning-50: #FFFBEB;
  --danger: #EF4444;
  --danger-50: #FEF2F2;
  --info: #3B82F6;
  --info-50: #EFF6FF;
  --purple: #8B5CF6;
  --purple-50: #F5F3FF;
  --pink: #EC4899;
  --pink-50: #FDF2F8;
  --teal: #14B8A6;
  --teal-50: #F0FDFA;

  --bg: #F8FAFC;
  --bg-elevated: #FFFFFF;
  --border: #E2E8F0;
  --text: #0F172A;
  --text-muted: #64748B;
  --text-soft: #94A3B8;

  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 10px 15px -3px rgba(15, 23, 42, 0.06), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 25px 50px -12px rgba(15, 23, 42, 0.12);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --sidebar-w: 256px;
  --sidebar-w-collapsed: 76px;
  --topbar-h: 68px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }

/* ===== APP LAYOUT ===== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas: "sidebar topbar" "sidebar main";
  height: 100vh;
  transition: grid-template-columns 0.3s ease;
}
.app.collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(2px); z-index: 55; }

/* ===== SIDEBAR ===== */
.sidebar {
  grid-area: sidebar;
  background: var(--slate-900);
  color: white;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.brand-mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary) 0%, #FB923C 100%);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 800; font-size: 16px;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
  flex-shrink: 0;
}
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.brand-tag { font-size: 10px; color: var(--primary); font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; }
.app.collapsed .brand-text { display: none; }

.ws-switcher {
  margin: 14px; padding: 10px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; transition: all 0.15s;
}
.ws-switcher:hover { background: rgba(255,255,255,0.08); }
.ws-avatar {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, #8B5CF6, #EC4899);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.ws-info { flex: 1; min-width: 0; }
.ws-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-plan { font-size: 11px; color: var(--slate-400); }
.app.collapsed .ws-info, .app.collapsed .ws-chev { display: none; }

.nav { flex: 1; overflow-y: auto; padding: 0 10px 20px; }
.nav::-webkit-scrollbar { width: 4px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }
.nav-section-label {
  font-size: 10px; font-weight: 600; color: var(--slate-500);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 18px 12px 8px;
}
.app.collapsed .nav-section-label { display: none; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--slate-300); cursor: pointer;
  position: relative;
  font-size: 13.5px; font-weight: 500;
  transition: all 0.15s; margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: white; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(249,115,22,0.15) 0%, rgba(249,115,22,0.04) 100%);
  color: white;
}
.nav-item.active::before {
  content: ''; position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px; background: var(--primary); border-radius: 0 3px 3px 0;
}
.nav-item .icon { width: 20px; height: 20px; flex-shrink: 0; stroke-width: 1.8; }
.nav-item .badge {
  margin-left: auto;
  background: var(--primary); color: white;
  font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 10px;
}
.nav-item .badge.muted { background: rgba(255,255,255,0.08); color: var(--slate-300); }
.app.collapsed .nav-item .label, .app.collapsed .nav-item .badge { display: none; }
.app.collapsed .nav-item { justify-content: center; }
.nav-item.ai-nav {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.08));
  border: 1px solid rgba(139, 92, 246, 0.2);
  color: white; margin-top: 8px;
}
.nav-item.ai-nav:hover { background: linear-gradient(135deg, rgba(99, 102, 241, 0.22), rgba(139, 92, 246, 0.12)); }

.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,0.06); }
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px;
  cursor: pointer; transition: all 0.15s;
}
.user-card:hover { background: rgba(255,255,255,0.04); }
.user-avatar {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #FB923C);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 13px;
  position: relative; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--slate-400); }
.app.collapsed .user-info { display: none; }
.app.collapsed .user-card { justify-content: center; }

.collapse-btn {
  position: absolute; top: 22px; right: -12px;
  width: 24px; height: 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  z-index: 50; box-shadow: var(--shadow-sm);
}
.collapse-btn:hover { background: var(--primary); color: white; border-color: var(--primary); }
.app.collapsed .collapse-btn svg { transform: rotate(180deg); }

/* ===== TOP BAR ===== */
.topbar {
  grid-area: topbar;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px;
  position: relative; z-index: 30;
}
.mobile-menu-btn {
  display: none;
  width: 40px; height: 40px; border-radius: 10px;
  align-items: center; justify-content: center;
  color: var(--text-muted);
}
.mobile-menu-btn:hover { background: var(--slate-100); color: var(--text); }
.mobile-menu-btn svg { width: 20px; height: 20px; }

.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.breadcrumb .crumb { color: var(--text); font-weight: 600; }
.breadcrumb svg { width: 14px; height: 14px; }
.topbar-spacer { flex: 1; }

.search { flex: 0 1 380px; position: relative; }
.search input {
  width: 100%; height: 40px;
  background: var(--slate-50);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 14px 0 40px;
  font-size: 13.5px;
  transition: all 0.15s;
}
.search input:focus { outline: none; background: white; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1); }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-soft); width: 16px; height: 16px; }
.search-kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); display: flex; gap: 3px; }
.search-kbd kbd {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  color: var(--text-muted);
  font-family: monospace;
}

.topbar-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: all 0.15s;
  position: relative;
}
.icon-btn:hover { background: var(--slate-100); color: var(--text); }
.icon-btn.ai-btn { background: linear-gradient(135deg, #EEF2FF, #E0E7FF); color: #6366F1; border: 1px solid #C7D2FE; }
.icon-btn.ai-btn:hover { box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3); }
.icon-btn.chat-top-btn { background: linear-gradient(135deg, #D1FAE5, #A7F3D0); color: #047857; border: 1px solid #6EE7B7; }
.icon-btn.chat-top-btn:hover { box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3); }
.icon-btn svg { width: 18px; height: 18px; stroke-width: 2; }
.icon-btn .dot-badge {
  position: absolute; top: 8px; right: 8px;
  width: 8px; height: 8px;
  background: var(--danger);
  border: 2px solid var(--bg-elevated);
  border-radius: 50%;
  display: none;
}
.icon-btn .dot-badge.show { display: block; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border-radius: 10px;
  font-size: 13.5px; font-weight: 600;
  transition: all 0.15s; white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-600); }
.btn-secondary { background: var(--slate-100); color: var(--text); }
.btn-secondary:hover { background: var(--slate-200); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--slate-100); color: var(--text); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 14px; }
.divider-v { width: 1px; height: 28px; background: var(--border); margin: 0 4px; }

/* ===== MAIN ===== */
.main { grid-area: main; overflow-y: auto; background: var(--bg); }
.main::-webkit-scrollbar { width: 8px; }
.main::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 4px; }
.page { max-width: 1600px; margin: 0 auto; padding: 28px 32px 80px; }

.view { display: none; }
.view.active { display: block; }

.welcome { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.welcome h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 6px; }
.welcome h1 .wave { display: inline-block; animation: wave 2.5s infinite; transform-origin: 70% 70%; }
@keyframes wave {
  0%, 60%, 100% { transform: rotate(0); }
  10%, 30% { transform: rotate(14deg); }
  20% { transform: rotate(-8deg); }
}
.welcome p { color: var(--text-muted); font-size: 14px; }
.welcome-actions { display: flex; gap: 10px; flex-shrink: 0; }

/* ===== STATS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  transition: all 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card.featured {
  background: linear-gradient(135deg, var(--slate-900) 0%, #1E293B 100%);
  border-color: transparent; color: white;
}
.stat-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.stat-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.stat-icon svg { width: 18px; height: 18px; }
.stat-icon.orange { background: var(--primary-50); color: var(--primary); }
.stat-icon.blue { background: var(--info-50); color: var(--info); }
.stat-icon.green { background: var(--success-50); color: var(--success); }
.stat-icon.purple { background: var(--purple-50); color: var(--purple); }
.stat-icon.pink { background: var(--pink-50); color: var(--pink); }
.stat-icon.dark { background: rgba(255,255,255,0.08); color: var(--primary); }
.stat-trend {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11.5px; font-weight: 600;
  padding: 3px 8px; border-radius: 20px;
  background: var(--success-50); color: var(--success);
}
.stat-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.stat-card.featured .stat-label { color: var(--slate-400); }
.stat-value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }

/* ===== SECTIONS ===== */
.section { margin-bottom: 32px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 16px;
}
.section-title { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.section-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

/* ===== PROJECTS ===== */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.project-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all 0.2s;
}
.project-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.project-cover {
  height: 84px; border-radius: 10px;
  margin-bottom: 14px; position: relative; overflow: hidden;
}
.project-cover.cover-1 { background: linear-gradient(135deg, #F97316 0%, #FB923C 50%, #FDBA74 100%); }
.project-cover.cover-2 { background: linear-gradient(135deg, #8B5CF6 0%, #A78BFA 50%, #C4B5FD 100%); }
.project-cover.cover-3 { background: linear-gradient(135deg, #14B8A6 0%, #2DD4BF 50%, #5EEAD4 100%); }
.project-cover.cover-4 { background: linear-gradient(135deg, #EC4899 0%, #F472B6 50%, #FBCFE8 100%); }
.project-cover.cover-5 { background: linear-gradient(135deg, #3B82F6 0%, #60A5FA 50%, #93C5FD 100%); }
.project-cover.cover-6 { background: linear-gradient(135deg, #F59E0B 0%, #FBBF24 50%, #FCD34D 100%); }
.project-cover-icon {
  position: absolute; bottom: -10px; right: 14px;
  width: 44px; height: 44px;
  background: white; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow); color: var(--primary);
}
.project-cover-icon svg { width: 22px; height: 22px; }
.project-name { font-size: 15px; font-weight: 700; margin-bottom: 2px; }
.project-cat { font-size: 11.5px; color: var(--text-muted); margin-bottom: 14px; }
.progress { height: 6px; background: var(--slate-100); border-radius: 10px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 10px; background: linear-gradient(90deg, var(--primary), #FB923C); }
.progress-bar.green { background: linear-gradient(90deg, var(--success), #4ADE80); }
.progress-bar.purple { background: linear-gradient(90deg, #8B5CF6, #A78BFA); }
.progress-bar.pink { background: linear-gradient(90deg, #EC4899, #F472B6); }
.progress-bar.blue { background: linear-gradient(90deg, #3B82F6, #60A5FA); }
.progress-text { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-muted); margin-bottom: 6px; }
.progress-text .pct { font-weight: 700; color: var(--text); }
.project-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }

.avatar-stack { display: flex; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--slate-200); color: white;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid white;
  margin-left: -8px; flex-shrink: 0;
}
.avatar:first-child { margin-left: 0; }
.avatar.cyan { background: linear-gradient(135deg, #06B6D4, #0EA5E9); }
.avatar.purple { background: linear-gradient(135deg, #8B5CF6, #A78BFA); }
.avatar.orange { background: linear-gradient(135deg, #F97316, #FB923C); }
.avatar.green { background: linear-gradient(135deg, #22C55E, #4ADE80); }
.avatar.pink { background: linear-gradient(135deg, #EC4899, #F472B6); }
.avatar.indigo { background: linear-gradient(135deg, #6366F1, #818CF8); }
.avatar.teal { background: linear-gradient(135deg, #14B8A6, #2DD4BF); }
.avatar.amber { background: linear-gradient(135deg, #F59E0B, #FBBF24); }
.avatar.rose { background: linear-gradient(135deg, #F43F5E, #FB7185); }
.avatar.more { background: var(--slate-200); color: var(--text-muted); }
.avatar.lg { width: 36px; height: 36px; font-size: 12px; border-width: 0; margin: 0; }
.avatar.sm { width: 22px; height: 22px; font-size: 9px; }
.avatar.xs { width: 18px; height: 18px; font-size: 8px; border-width: 1.5px; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px;
  border-radius: 6px;
  font-size: 11px; font-weight: 600;
}
.tag.priority-high { background: var(--danger-50); color: var(--danger); }
.tag.priority-medium { background: var(--warning-50); color: var(--warning); }
.tag.priority-low { background: var(--info-50); color: var(--info); }
.tag.status-active { background: var(--success-50); color: var(--success); }
.tag.status-progress { background: var(--primary-50); color: var(--primary); }
.tag.category { background: var(--slate-100); color: var(--slate-700); }
.tag .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ===== KANBAN ===== */
.kanban {
  display: grid;
  grid-template-columns: repeat(5, minmax(240px, 1fr));
  gap: 12px;
  overflow-x: auto;
}
.kanban-col { background: var(--slate-50); border-radius: var(--radius-lg); padding: 12px; min-height: 400px; }
.kanban-col-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 12px; }
.kanban-col-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }
.kanban-col-title .dot { width: 8px; height: 8px; border-radius: 50%; }
.kanban-col-title .dot.gray { background: var(--slate-400); }
.kanban-col-title .dot.blue { background: var(--info); }
.kanban-col-title .dot.amber { background: var(--warning); }
.kanban-col-title .dot.purple { background: var(--purple); }
.kanban-col-title .dot.green { background: var(--success); }
.kanban-count {
  background: white; color: var(--text-muted);
  font-size: 10.5px; font-weight: 700;
  padding: 1px 7px; border-radius: 10px;
  border: 1px solid var(--border);
}
.task-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
  cursor: grab;
  transition: all 0.15s;
  position: relative;
}
.task-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.task-card::before {
  content: ''; position: absolute;
  top: 0; left: 0; width: 3px; height: 100%;
  border-radius: 3px 0 0 3px;
}
.task-card.prio-high::before { background: var(--danger); }
.task-card.prio-medium::before { background: var(--warning); }
.task-card.prio-low::before { background: var(--info); }
.task-title { font-size: 13px; font-weight: 600; margin-bottom: 8px; line-height: 1.4; }
.task-meta { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--text-muted); }
.task-meta-item { display: inline-flex; align-items: center; gap: 3px; }
.task-meta-item svg { width: 11px; height: 11px; }
.task-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.task-progress { flex: 1; height: 4px; background: var(--slate-100); border-radius: 4px; overflow: hidden; margin-right: 8px; }
.task-progress-bar { height: 100%; background: var(--primary); border-radius: 4px; }

/* ===== CARDS / TABLES ===== */
.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.three-col { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 16px; }
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.card-title { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 18px; }
.chart-wrap { position: relative; height: 220px; }
.chart-wrap.lg { height: 300px; }
.chart-wrap.sm { height: 140px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 11.5px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 12px 16px;
  background: var(--slate-50);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px; vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--slate-50); }

/* ===== CALENDAR ===== */
.calendar { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--slate-50); border-bottom: 1px solid var(--border); }
.cal-head div { padding: 10px 12px; font-size: 11.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: 80px; }
.cal-day {
  border-right: 1px solid var(--slate-100);
  border-bottom: 1px solid var(--slate-100);
  padding: 6px 8px;
  position: relative;
}
.cal-day.muted { background: var(--slate-50); color: var(--text-soft); }
.cal-day.today .cal-num { background: var(--primary); color: white; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.cal-num { font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.cal-event {
  font-size: 10.5px; padding: 2px 6px; border-radius: 4px; margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600;
}
.cal-event.orange { background: var(--primary-50); color: var(--primary-700); }
.cal-event.blue { background: var(--info-50); color: var(--info); }
.cal-event.green { background: var(--success-50); color: var(--success); }
.cal-event.purple { background: var(--purple-50); color: var(--purple); }
.cal-event.pink { background: var(--pink-50); color: var(--pink); }

/* ===== TOAST ===== */
.toast-stack {
  position: fixed; top: 84px; left: 50%; transform: translateX(-50%);
  z-index: 250; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--slate-900); color: white;
  padding: 10px 16px 10px 12px; border-radius: 12px;
  box-shadow: var(--shadow-xl);
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 500;
  pointer-events: auto;
  animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 360px;
}
.toast.out { animation: toastOut 0.3s ease forwards; }
@keyframes toastIn { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes toastOut { to { transform: translateY(-20px); opacity: 0; } }
.toast-icon { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.toast-icon svg { width: 14px; height: 14px; }
.toast-icon.message { background: var(--primary); }
.toast-icon.warning { background: var(--warning); }
.toast-icon.success { background: var(--success); }
.toast-icon.danger { background: var(--danger); }
.toast-content { flex: 1; min-width: 0; }
.toast-title { font-weight: 600; font-size: 12.5px; }
.toast-sub { font-size: 11px; color: var(--slate-300); margin-top: 1px; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-elevated);
  border-radius: var(--radius-xl);
  width: 480px; max-width: 90vw;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  max-height: 90vh;
  display: flex; flex-direction: column;
}
.modal-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--slate-50);
  display: flex; justify-content: flex-end; gap: 8px;
  flex-shrink: 0;
}
.form-input {
  width: 100%; height: 38px;
  padding: 0 12px;
  background: var(--slate-50);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px; outline: none;
  transition: all 0.15s;
}
.form-input:focus { background: white; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1); }
textarea.form-input { height: auto; padding: 10px 12px; line-height: 1.4; }
.create-option {
  padding: 14px; border: 1px solid var(--border);
  border-radius: 10px; text-align: left;
  background: white; transition: all 0.15s; cursor: pointer;
}
.create-option:hover { border-color: var(--primary); background: var(--primary-50); }
.co-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.text-muted { color: var(--text-muted); }
.text-soft { color: var(--text-soft); }
.text-sm { font-size: 12.5px; }
.text-xs { font-size: 11.5px; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }

/* ============================================
   CHAT BUBBLES — Messenger-style, one per conversation
   ============================================ */
.chat-bubbles-bar {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: row-reverse;
  align-items: flex-end;
  gap: 8px;
  z-index: 90;
  max-width: calc(100vw - 32px);
  flex-wrap: wrap-reverse;
}
.chat-bubble-item {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
  background: var(--slate-700);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.2);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: none;
  padding: 0;
  user-select: none;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}
.chat-bubble-item:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.28);
}
.chat-bubble-item.active {
  transform: translateY(-4px) scale(1.08);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.32);
}
.chat-bubble-item.compose {
  background: linear-gradient(135deg, #10B981, #059669);
}
.chat-bubble-item.compose svg { width: 24px; height: 24px; }
.chat-bubble-item .bubble-presence {
  position: absolute;
  bottom: 2px; right: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2.5px solid white;
}
.bubble-presence.online { background: var(--success); }
.bubble-presence.away { background: var(--warning); }
.bubble-presence.busy { background: var(--danger); }
.bubble-presence.offline { background: var(--slate-300); }
.chat-bubble-item .bubble-badge {
  position: absolute;
  top: -2px; right: -2px;
  min-width: 20px; height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--danger);
  color: white;
  font-size: 10.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2.5px solid white;
  box-sizing: content-box;
  transform: scale(0);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.chat-bubble-item .bubble-badge.show { transform: scale(1); }
.chat-bubble-item .bubble-close {
  position: absolute;
  top: -4px; right: -4px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--slate-700);
  color: white;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2px solid white;
  font-size: 11px;
  line-height: 1;
}
.chat-bubble-item:hover .bubble-close { display: flex; }
.chat-bubble-item .bubble-close:hover { background: var(--danger); }
.chat-bubble-item .bubble-name-tag {
  position: absolute;
  bottom: -28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--slate-900);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.chat-bubble-item:hover .bubble-name-tag { opacity: 1; }
.chat-bubble-item.has-typing .bubble-presence {
  animation: typingPulse 1.4s infinite;
}
@keyframes typingPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); }
  50% { box-shadow: 0 0 0 4px rgba(34, 197, 94, 0); }
}

/* Chat window (one per open conversation) */
.chat-window {
  position: fixed;
  bottom: 84px;
  width: 340px;
  height: 520px;
  max-height: calc(100vh - 110px);
  background: var(--bg-elevated);
  border-radius: 14px;
  box-shadow: 0 16px 40px -8px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(15, 23, 42, 0.06);
  z-index: 89;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: chatWindowIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: bottom right;
}
@keyframes chatWindowIn {
  from { transform: translateY(20px) scale(0.95); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.chat-window.open { display: flex; }
.chat-window-closed {
  position: fixed;
  bottom: 84px;
  width: 340px;
  padding: 12px 16px;
  background: var(--slate-100);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 89;
  box-shadow: var(--shadow-md);
}

.cw-header {
  padding: 12px 14px;
  background: var(--slate-900);
  color: white;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}
.cw-header:hover { background: #1E293B; }
.cw-header::before {
  content: '';
  position: absolute;
  top: -30px; right: -20px;
  width: 100px; height: 100px;
  background: radial-gradient(circle, rgba(249, 115, 22, 0.2), transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
.cw-avatar {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  position: relative;
  color: white;
}
.cw-avatar .presence {
  position: absolute;
  bottom: -1px; right: -1px;
  width: 11px; height: 11px;
  border-radius: 50%;
  border: 2.5px solid var(--slate-900);
}
.cw-info { flex: 1; min-width: 0; }
.cw-name {
  font-size: 13.5px;
  font-weight: 700;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cw-name .ch-hash { color: var(--slate-400); font-weight: 600; }
.cw-status {
  font-size: 11px;
  color: var(--slate-300);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
}
.cw-status .dot { width: 6px; height: 6px; border-radius: 50%; }
.cw-status .dot.online { background: var(--success); }
.cw-status .dot.away { background: var(--warning); }
.cw-status .dot.busy { background: var(--danger); }
.cw-status .dot.offline { background: var(--slate-400); }
.cw-actions { display: flex; gap: 2px; position: relative; z-index: 2; }
.cw-actions button {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: transparent;
  color: var(--slate-300);
  display: flex; align-items: center; justify-content: center;
  border: none; cursor: pointer;
  transition: all 0.15s;
}
.cw-actions button:hover { background: rgba(255,255,255,0.1); color: white; }
.cw-actions button svg { width: 14px; height: 14px; }

/* Banner */
.cw-banner {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 600;
  flex-shrink: 0;
  animation: slideDown 0.3s ease;
}
@keyframes slideDown { from { transform: translateY(-10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.cw-banner.pending { background: var(--warning-50); color: #92400E; border-bottom: 1px solid #FCD34D; }
.cw-banner.request { background: var(--info-50); color: #1E40AF; border-bottom: 1px solid #93C5FD; }
.cw-banner.declined { background: var(--danger-50); color: #991B1B; border-bottom: 1px solid #FCA5A5; }
.cw-banner .pulse-dot { width: 7px; height: 7px; background: var(--warning); border-radius: 50%; animation: pulse-dot 1.5s infinite; }
@keyframes pulse-dot { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(1.3); } }
.cw-banner .banner-text { flex: 1; }
.cw-banner button.bb {
  height: 22px; padding: 0 8px; border-radius: 5px;
  font-size: 10.5px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 3px;
  border: none; cursor: pointer;
}
.cw-banner button.bb svg { width: 10px; height: 10px; }
.cw-banner button.bb.accept { background: var(--success); color: white; }
.cw-banner button.bb.accept:hover { background: #16A34A; }
.cw-banner button.bb.decline { background: white; color: var(--danger); border: 1px solid #FCA5A5; }

/* Messages */
.cw-dropzone {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}
.cw-dropzone.drag-over .dz-overlay { display: flex; }
.dz-overlay {
  display: none;
  position: absolute;
  inset: 8px;
  background: rgba(16, 185, 129, 0.95);
  color: white;
  border: 3px dashed white;
  border-radius: 12px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
  z-index: 5;
  font-weight: 600;
  font-size: 12px;
}
.dz-overlay svg { width: 28px; height: 28px; }
.cw-messages {
  height: 100%;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: radial-gradient(circle at 20% 30%, rgba(16, 185, 129, 0.04), transparent 40%), var(--bg);
}
.cw-messages::-webkit-scrollbar { width: 5px; }
.cw-messages::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 3px; }

.cw-day-divider { display: flex; align-items: center; gap: 8px; margin: 8px 0 4px; font-size: 10.5px; color: var(--text-soft); font-weight: 600; }
.cw-day-divider::before, .cw-day-divider::after { content: ''; flex: 1; height: 1px; background: var(--slate-200); }

.cw-msg { display: flex; gap: 8px; padding: 1px 0; max-width: 85%; }
.cw-msg.them { align-self: flex-start; }
.cw-msg.me { align-self: flex-end; flex-direction: row-reverse; }
.cw-msg-avatar { width: 26px; height: 26px; border-radius: 7px; display: flex; align-items: center; justify-content: center; color: white; font-size: 10px; font-weight: 700; flex-shrink: 0; align-self: flex-start; margin-top: 2px; }
.cw-msg.me .cw-msg-avatar { background: transparent; color: transparent; width: 0; margin: 0; }
.cw-msg-col { display: flex; flex-direction: column; min-width: 0; }
.cw-msg.me .cw-msg-col { align-items: flex-end; }
.cw-msg-author { font-size: 11.5px; font-weight: 700; margin-bottom: 1px; padding: 0 4px; }
.cw-msg.me .cw-msg-author { display: none; }
.cw-msg-bubble {
  padding: 6px 10px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
  word-wrap: break-word;
  color: var(--text);
}
.cw-msg.them .cw-msg-bubble { background: var(--bg-elevated); border: 1px solid var(--border); border-top-left-radius: 4px; }
.cw-msg.me .cw-msg-bubble { background: linear-gradient(135deg, #10B981, #059669); color: white; border-top-right-radius: 4px; }
.cw-msg .cw-msg-meta { font-size: 10px; color: var(--text-soft); margin-top: 1px; display: flex; align-items: center; gap: 3px; padding: 0 4px; }
.cw-msg.me .cw-msg-meta { justify-content: flex-end; }
.cw-msg .cw-msg-meta .read { color: #10B981; font-weight: 700; }
.cw-msg .cw-msg-meta .read.pending { color: var(--text-soft); font-weight: 400; }
.cw-msg-bubble .mention { background: rgba(16, 185, 129, 0.12); color: #047857; padding: 1px 4px; border-radius: 4px; font-weight: 600; }
.cw-msg.me .cw-msg-bubble .mention { background: rgba(255,255,255,0.22); color: white; }

.cw-msg-files { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.cw-msg-file { display: flex; align-items: center; gap: 6px; padding: 5px 6px; background: rgba(255,255,255,0.6); border: 1px solid var(--border); border-radius: 6px; font-size: 11.5px; }
.cw-msg.me .cw-msg-file { background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.2); }
.cw-msg-file-icon { width: 24px; height: 24px; border-radius: 5px; display: flex; align-items: center; justify-content: center; color: white; flex-shrink: 0; }
.cw-msg-file-icon svg { width: 12px; height: 12px; }
.cw-msg-file-icon.pdf { background: #EF4444; }
.cw-msg-file-icon.doc { background: #3B82F6; }
.cw-msg-file-icon.sheet { background: #10B981; }
.cw-msg-file-icon.image { background: #8B5CF6; }
.cw-msg-file-icon.file { background: #64748B; }
.cw-msg-file-info { flex: 1; min-width: 0; }
.cw-msg-file-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cw-msg-file-meta { font-size: 9.5px; opacity: 0.75; }

.cw-msg-system { align-self: center; max-width: 90%; padding: 4px 10px; background: var(--slate-100); border-radius: 8px; font-size: 10.5px; color: var(--text-muted); text-align: center; display: flex; align-items: center; gap: 4px; margin: 3px 0; }
.cw-msg-system svg { width: 10px; height: 10px; }
.cw-msg-system.success { background: var(--success-50); color: var(--success); }
.cw-msg-system.danger { background: var(--danger-50); color: var(--danger); }

.cw-typing { display: flex; gap: 8px; align-items: center; padding: 3px 0; align-self: flex-start; max-width: 85%; }
.cw-typing .cw-msg-avatar { background: linear-gradient(135deg, #8B5CF6, #EC4899); }
.cw-typing-bubble { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 12px; border-top-left-radius: 4px; padding: 6px 10px; display: flex; gap: 3px; }
.cw-typing-bubble .dot { width: 5px; height: 5px; background: var(--text-soft); border-radius: 50%; animation: typingDot 1.4s infinite; }
.cw-typing-bubble .dot:nth-child(2) { animation-delay: 0.2s; }
.cw-typing-bubble .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingDot { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-3px); opacity: 1; } }

/* Input */
.cw-input-wrap {
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  flex-shrink: 0;
  padding: 8px 10px 6px;
}
.cw-attach-preview-row { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.cw-attach-preview { display: flex; align-items: center; gap: 4px; padding: 3px 6px 3px 4px; background: var(--slate-50); border: 1px solid var(--border); border-radius: 6px; font-size: 11px; }
.cw-attach-preview .ic { width: 20px; height: 20px; border-radius: 4px; display: flex; align-items: center; justify-content: center; color: white; }
.cw-attach-preview .ic svg { width: 10px; height: 10px; }
.cw-attach-preview .ic.pdf { background: #EF4444; }
.cw-attach-preview .ic.doc { background: #3B82F6; }
.cw-attach-preview .ic.sheet { background: #10B981; }
.cw-attach-preview .ic.image { background: #8B5CF6; }
.cw-attach-preview .ic.file { background: #64748B; }
.cw-attach-preview .name { max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.cw-attach-preview .x { background: transparent; color: var(--text-muted); border: none; cursor: pointer; padding: 0; width: 14px; height: 14px; display: flex; align-items: center; justify-content: center; }
.cw-attach-preview .x:hover { color: var(--danger); }

.cw-input { display: flex; align-items: flex-end; gap: 4px; background: var(--slate-50); border: 1px solid var(--border); border-radius: 10px; padding: 4px; transition: all 0.15s; }
.cw-input:focus-within { background: white; border-color: #10B981; box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1); }
.cw-attach-btn, .cw-send-btn {
  width: 28px; height: 28px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; color: var(--text-muted);
  border: none; cursor: pointer; flex-shrink: 0;
  transition: all 0.15s;
}
.cw-attach-btn:hover { background: var(--slate-200); color: var(--text); }
.cw-attach-btn svg { width: 14px; height: 14px; }
.cw-input textarea { flex: 1; border: none; outline: none; background: transparent; resize: none; font-size: 13px; line-height: 1.4; min-height: 24px; max-height: 100px; padding: 5px 4px; font-family: inherit; }
.cw-send-btn { background: linear-gradient(135deg, #10B981, #059669); color: white; }
.cw-send-btn:hover:not(:disabled) { transform: scale(1.05); }
.cw-send-btn:disabled { background: var(--slate-200); color: var(--text-soft); cursor: not-allowed; }
.cw-send-btn svg { width: 12px; height: 12px; }

/* Closed state */
.cw-closed-banner {
  background: var(--slate-100);
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.cw-closed-banner svg { width: 14px; height: 14px; flex-shrink: 0; }
.cw-closed-banner strong { color: var(--text); display: block; font-size: 12.5px; }
.cw-closed-banner button { margin-left: auto; }

/* Chat list popup (from compose bubble) */
.chat-list-popup {
  position: fixed;
  bottom: 84px;
  right: 16px;
  width: 340px;
  max-height: 480px;
  background: var(--bg-elevated);
  border-radius: 14px;
  box-shadow: 0 16px 40px -8px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(15, 23, 42, 0.06);
  z-index: 91;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: chatWindowIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: bottom right;
}
.chat-list-popup-head { padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.chat-list-popup-title { font-size: 14px; font-weight: 700; }
.chat-list-popup-search { padding: 10px 12px; border-bottom: 1px solid var(--slate-100); position: relative; }
.chat-list-popup-search svg { position: absolute; left: 22px; top: 50%; transform: translateY(-50%); color: var(--text-soft); width: 13px; height: 13px; pointer-events: none; }
.chat-list-popup-search input { width: 100%; height: 34px; background: var(--slate-50); border: 1px solid var(--border); border-radius: 8px; padding: 0 10px 0 32px; font-size: 12.5px; outline: none; }
.chat-list-popup-search input:focus { background: white; border-color: #10B981; box-shadow: 0 0 0 3px rgba(16,185,129,0.1); }
.chat-list-popup-body { flex: 1; overflow-y: auto; padding: 6px 8px 10px; }
.chat-list-popup-body::-webkit-scrollbar { width: 4px; }
.chat-list-popup-body::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 2px; }
.chat-list-popup-section { font-size: 10.5px; font-weight: 700; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.06em; padding: 8px 8px 4px; display: flex; align-items: center; justify-content: space-between; }
.chat-list-popup-section .new-btn { color: #10B981; cursor: pointer; padding: 2px 6px; border-radius: 4px; }
.chat-list-popup-section .new-btn:hover { background: #D1FAE5; }
.chat-list-popup-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; transition: background 0.12s; }
.chat-list-popup-item:hover { background: var(--slate-50); }
.chat-list-popup-item .ci-avatar { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; font-size: 11.5px; flex-shrink: 0; position: relative; }
.chat-list-popup-item .ci-avatar.channel { background: linear-gradient(135deg, var(--slate-700), var(--slate-800)); }
.chat-list-popup-item .presence { position: absolute; bottom: -1px; right: -1px; width: 9px; height: 9px; border-radius: 50%; border: 2px solid white; }
.chat-list-popup-item .info { flex: 1; min-width: 0; }
.chat-list-popup-item .name { font-size: 13px; font-weight: 600; }
.chat-list-popup-item .sub { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-list-popup-empty { padding: 30px 16px; text-align: center; color: var(--text-muted); font-size: 12px; }

/* Mobile */
@media (max-width: 768px) {
  .chat-bubbles-bar { right: 12px; bottom: 12px; gap: 6px; }
  .chat-bubble-item { width: 50px; height: 50px; font-size: 12px; }
  .chat-bubble-item.compose svg { width: 20px; height: 20px; }
  .chat-window, .chat-list-popup { right: 8px; left: 8px; width: auto; bottom: 72px; }
  .chat-window { height: calc(100vh - 90px); }
}
@media (max-width: 480px) {
  .chat-bubble-item { width: 46px; height: 46px; }
  .chat-bubbles-bar { right: 8px; bottom: 8px; }
}

/* ============================================
   BUSINESS BRAIN PANEL
   ============================================ */
.brain-panel {
  position: fixed; top: 0; right: 0;
  height: 100vh; width: 420px;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  z-index: 100;
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.brain-panel.open { transform: translateX(0); }

.brain-head { padding: 16px 18px 12px; border-bottom: 1px solid var(--border); background: linear-gradient(135deg, #EEF2FF 0%, #F0F9FF 50%, #FAF5FF 100%); flex-shrink: 0; }
.brain-head-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.brain-head-left { display: flex; align-items: center; gap: 12px; }
.brain-orb {
  width: 38px; height: 38px; border-radius: 12px;
  background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 50%, #14B8A6 100%);
  display: flex; align-items: center; justify-content: center;
  color: white; position: relative;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}
.brain-orb::after { content: ''; position: absolute; inset: -3px; border-radius: 14px; background: linear-gradient(135deg, #6366F1, #14B8A6); opacity: 0.3; z-index: -1; animation: brainPulse 2s infinite; }
@keyframes brainPulse { 0%, 100% { transform: scale(1); opacity: 0.3; } 50% { transform: scale(1.15); opacity: 0; } }
.brain-orb svg { width: 18px; height: 18px; }
.brain-head-title { font-size: 14.5px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.brain-head-title .pro-badge { font-size: 9px; font-weight: 700; background: linear-gradient(135deg, #6366F1, #8B5CF6); color: white; padding: 1px 5px; border-radius: 4px; }
.brain-head-sub { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }
.brain-head-sub .live { width: 6px; height: 6px; background: var(--success); border-radius: 50%; animation: blink 1.5s infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.brain-tabs { display: flex; background: rgba(255, 255, 255, 0.7); backdrop-filter: blur(4px); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.brain-tab { flex: 1; height: 30px; padding: 0 10px; font-size: 12px; font-weight: 600; color: var(--text-muted); border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; transition: all 0.15s; cursor: pointer; border: none; background: transparent; }
.brain-tab:hover { color: var(--text); }
.brain-tab.active { background: linear-gradient(135deg, #6366F1, #8B5CF6); color: white; box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3); }
.brain-tab svg { width: 12px; height: 12px; }
.brain-tab .count { font-size: 10px; padding: 1px 5px; border-radius: 8px; background: rgba(255,255,255,0.25); color: white; }
.brain-tab:not(.active) .count { background: var(--slate-100); color: var(--text-muted); }

.brain-context { padding: 8px 16px 0; display: flex; gap: 4px; flex-wrap: wrap; flex-shrink: 0; }
.context-chip { font-size: 10px; font-weight: 600; color: var(--text-muted); background: white; border: 1px solid var(--border); padding: 2px 7px 2px 5px; border-radius: 10px; display: inline-flex; align-items: center; gap: 4px; }
.context-chip .dot { width: 5px; height: 5px; background: var(--success); border-radius: 50%; }
.context-chip.kb { color: #6366F1; border-color: #C7D2FE; background: #EEF2FF; }
.context-chip.kb .dot { background: #6366F1; }

.brain-view { display: none; flex: 1; flex-direction: column; min-height: 0; }
.brain-view.active { display: flex; }

.brain-body { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.brain-body::-webkit-scrollbar { width: 4px; }
.brain-body::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 2px; }

.brain-msg { display: flex; gap: 10px; max-width: 95%; }
.brain-msg.user { margin-left: auto; flex-direction: row-reverse; }
.brain-msg-avatar { width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: white; font-size: 11px; font-weight: 700; }
.brain-msg.bot .brain-msg-avatar { background: linear-gradient(135deg, #6366F1, #8B5CF6, #14B8A6); }
.brain-msg.user .brain-msg-avatar { background: var(--slate-200); color: var(--text); }
.brain-msg-content { background: var(--slate-50); padding: 10px 14px; border-radius: 12px; font-size: 13px; line-height: 1.5; }
.brain-msg.user .brain-msg-content { background: var(--primary); color: white; }
.brain-msg-content strong { font-weight: 700; }
.brain-msg-content em { font-style: italic; }
.brain-msg-content .hi { background: linear-gradient(135deg, #FEF3C7, #FED7AA); padding: 1px 5px; border-radius: 4px; font-weight: 700; }
.brain-msg-content .risk { color: #B45309; font-weight: 600; }
.brain-msg-content .good { color: var(--success); font-weight: 600; }

.msg-sources { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.msg-source { font-size: 10px; font-weight: 600; color: var(--text-muted); background: var(--slate-50); border: 1px solid var(--border); padding: 2px 7px; border-radius: 8px; display: inline-flex; align-items: center; gap: 3px; }
.msg-source svg { width: 9px; height: 9px; }
.msg-source.kb { color: #6366F1; border-color: #C7D2FE; background: #EEF2FF; }

.brain-suggestions { padding: 8px 16px 0; display: flex; flex-direction: column; gap: 6px; }
.brain-suggestion { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: white; border: 1px solid var(--border); border-radius: 10px; font-size: 12.5px; cursor: pointer; text-align: left; transition: all 0.15s; }
.brain-suggestion:hover { border-color: #6366F1; background: #EEF2FF; }
.brain-suggestion .ic { width: 22px; height: 22px; border-radius: 6px; background: #EEF2FF; color: #6366F1; display: flex; align-items: center; justify-content: center; }
.brain-suggestion .ic svg { width: 11px; height: 11px; }

.brain-input-wrap { padding: 12px 16px 16px; border-top: 1px solid var(--border); background: var(--bg-elevated); flex-shrink: 0; }
.brain-input { display: flex; align-items: flex-end; gap: 6px; background: var(--slate-50); border: 1px solid var(--border); border-radius: 12px; padding: 6px 6px 6px 12px; transition: all 0.15s; }
.brain-input:focus-within { background: white; border-color: #6366F1; box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12); }
.brain-input textarea { flex: 1; border: none; outline: none; background: transparent; resize: none; font-size: 13px; line-height: 1.4; min-height: 22px; max-height: 100px; padding: 6px 0; font-family: inherit; }
.brain-send-btn { width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(135deg, #6366F1, #8B5CF6); color: white; display: flex; align-items: center; justify-content: center; border: none; cursor: pointer; flex-shrink: 0; }
.brain-send-btn svg { width: 14px; height: 14px; }

/* Knowledge tab */
.kb-header { padding: 10px 14px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--slate-100); flex-shrink: 0; }
.kb-search { flex: 1; position: relative; }
.kb-search input { width: 100%; height: 32px; background: var(--slate-50); border: 1px solid var(--border); border-radius: 8px; padding: 0 10px 0 32px; font-size: 12.5px; outline: none; }
.kb-search input:focus { background: white; border-color: #6366F1; box-shadow: 0 0 0 3px rgba(99,102,241,0.1); }
.kb-search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-soft); width: 13px; height: 13px; }
.kb-add { width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(135deg, #6366F1, #8B5CF6); color: white; display: flex; align-items: center; justify-content: center; border: none; cursor: pointer; flex-shrink: 0; }
.kb-add svg { width: 14px; height: 14px; }

.kb-categories { padding: 8px 14px; display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--slate-100); flex-shrink: 0; }
.kb-categories::-webkit-scrollbar { height: 0; }
.kb-cat { font-size: 11px; font-weight: 600; color: var(--text-muted); padding: 4px 10px; border-radius: 12px; background: transparent; border: 1px solid transparent; white-space: nowrap; cursor: pointer; }
.kb-cat:hover { background: var(--slate-100); }
.kb-cat.active { background: #EEF2FF; color: #6366F1; border-color: #C7D2FE; }

.kb-list { flex: 1; overflow-y: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.kb-item { background: white; border: 1px solid var(--border); border-radius: 10px; padding: 12px; transition: all 0.15s; }
.kb-item:hover { border-color: #C7D2FE; box-shadow: var(--shadow-sm); }
.kb-item-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 6px; }
.kb-icon { width: 28px; height: 28px; border-radius: 7px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.kb-icon svg { width: 14px; height: 14px; }
.kb-icon.doc { background: #EEF2FF; color: #6366F1; }
.kb-icon.note { background: #FEF3C7; color: #B45309; }
.kb-icon.faq { background: #DBEAFE; color: #1E40AF; }
.kb-icon.decision { background: #FCE7F3; color: #BE185D; }
.kb-icon.persona { background: #D1FAE5; color: #047857; }
.kb-icon.url { background: #E0E7FF; color: #4338CA; }
.kb-item-title { font-size: 13px; font-weight: 600; flex: 1; line-height: 1.3; }
.kb-item-meta { font-size: 10.5px; color: var(--text-soft); display: flex; align-items: center; gap: 6px; }
.kb-item-content { font-size: 12px; color: var(--text-muted); line-height: 1.5; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.kb-item-tags { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 8px; }
.kb-tag { font-size: 10px; font-weight: 600; color: var(--text-muted); background: var(--slate-50); padding: 1px 6px; border-radius: 6px; }

.kb-type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kb-type-btn { padding: 12px; border: 1.5px solid var(--border); border-radius: 10px; text-align: left; transition: all 0.15s; cursor: pointer; background: white; }
.kb-type-btn:hover, .kb-type-btn.selected { border-color: #6366F1; background: #EEF2FF; }
.kb-type-btn .kb-icon { margin-bottom: 6px; }
.kb-type-btn .name { font-size: 12.5px; font-weight: 600; }
.kb-type-btn .desc { font-size: 10.5px; color: var(--text-soft); }

/* Brain quick grid (in dashboard) */
.brain-quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.brain-quick-card { padding: 12px; background: white; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; transition: all 0.15s; text-align: left; }
.brain-quick-card:hover { border-color: #C7D2FE; transform: translateY(-1px); }
.brain-quick-card .ic { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.brain-quick-card .ic svg { width: 14px; height: 14px; }
.brain-quick-card .btitle { font-size: 12.5px; font-weight: 600; }
.brain-quick-card .bdesc { font-size: 10.5px; color: var(--text-muted); margin-top: 1px; }

.brain-insight { padding: 14px 18px; border-bottom: 1px solid var(--slate-100); }
.brain-insight:last-child { border-bottom: none; }
.brain-insight-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.brain-insight-icon { width: 26px; height: 26px; border-radius: 7px; display: flex; align-items: center; justify-content: center; color: white; }
.brain-insight-icon svg { width: 13px; height: 13px; }
.brain-insight-icon.purple { background: linear-gradient(135deg, #6366F1, #8B5CF6); }
.brain-insight-icon.amber { background: linear-gradient(135deg, #F59E0B, #FB923C); }
.brain-insight-icon.green { background: linear-gradient(135deg, #22C55E, #4ADE80); }
.brain-insight-title { font-size: 12.5px; font-weight: 600; }
.brain-insight-time { font-size: 10.5px; color: var(--text-soft); margin-left: auto; }
.brain-insight-text { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

.docs-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.doc-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; transition: all 0.15s; }
.doc-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.doc-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.doc-icon svg { width: 20px; height: 20px; }
.doc-icon.orange { background: var(--primary-50); color: var(--primary); }
.doc-icon.blue { background: var(--info-50); color: var(--info); }
.doc-icon.green { background: var(--success-50); color: var(--success); }
.doc-icon.purple { background: var(--purple-50); color: var(--purple); }
.doc-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.doc-meta { font-size: 11.5px; color: var(--text-muted); }

.goals-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.okr-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.okr-title { font-size: 15px; font-weight: 700; margin-bottom: 12px; }
.okr-progress { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.okr-progress .progress { flex: 1; }
.okr-progress .pct { font-size: 13px; font-weight: 700; }
.okr-kr { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--slate-100); font-size: 13px; }
.okr-kr .progress { width: 100px; height: 4px; }

.crm-deal { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--slate-100); }
.crm-deal:last-child { border-bottom: none; }
.crm-deal:hover { background: var(--slate-50); }
.crm-co { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: white; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.crm-info { flex: 1; min-width: 0; }
.crm-name { font-size: 13px; font-weight: 600; }
.crm-co-name { font-size: 11.5px; color: var(--text-muted); }
.crm-amount { font-size: 13px; font-weight: 700; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1280px) {
  :root { --sidebar-w: 232px; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .projects-grid { grid-template-columns: repeat(3, 1fr); }
  .three-col { grid-template-columns: 1fr 1fr; }
  .three-col > .card:last-child { grid-column: 1 / -1; }
  .two-col { grid-template-columns: 1fr 1fr; }
  .kanban { grid-template-columns: repeat(5, 260px); }
  .search { flex: 0 1 280px; }
  .docs-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; --topbar-h: 64px; }
  .page { padding: 24px 20px 60px; }
  .welcome h1 { font-size: 24px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stat-value { font-size: 22px; }
  .projects-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .three-col { grid-template-columns: 1fr; }
  .three-col > .card:last-child { grid-column: auto; }
  .two-col { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: repeat(4, 280px); padding-bottom: 8px; }
  .search { display: none; }
  .breadcrumb { display: none; }
  .topbar { padding: 0 16px; gap: 8px; }
  .docs-grid { grid-template-columns: repeat(2, 1fr); }
  .goals-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .app { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
  .app.mobile-open { grid-template-columns: var(--sidebar-w) 1fr; }
  .app.mobile-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-xl); }
  .app.mobile-open .sidebar-overlay { display: block; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w); z-index: 60; transform: translateX(-100%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
  .app.collapsed .sidebar { transform: translateX(-100%); }
  .app.mobile-open.collapsed .sidebar { transform: translateX(0); }
  .collapse-btn { display: none; }
  .mobile-menu-btn { display: flex; }
  .page { padding: 20px 16px 60px; }
  .welcome { flex-direction: column; align-items: flex-start; gap: 14px; }
  .welcome h1 { font-size: 22px; }
  .welcome-actions { width: 100%; }
  .welcome-actions .btn { flex: 1; justify-content: center; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 20px; }
  .projects-grid { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: 1fr; }
  .kanban-col { min-height: auto; }
  .docs-grid { grid-template-columns: 1fr; }
  .chat-panel { width: 100vw; max-width: 100vw; }
  .chat-list { width: 100%; }
  .chat-panel.show-conv .chat-list { display: none; }
  .chat-back-btn { display: flex; }
  .chat-rail { width: 56px; }
  .chat-rail-btn .crb-label { display: none; }
  .brain-panel { width: 100vw; max-width: 100vw; }
}

@media (max-width: 480px) {
  :root { --topbar-h: 60px; }
  .brand { padding: 0 14px; }
  .ws-switcher { margin: 12px 10px 8px; padding: 8px 10px; }
  .topbar { padding: 0 12px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-icon { width: 32px; height: 32px; }
  .stat-value { font-size: 18px; }
  .welcome h1 { font-size: 20px; }
  .toast-stack { top: 70px; left: 12px; right: 12px; transform: none; }
  .modal { width: 95vw; }
  .cal-grid { grid-auto-rows: 60px; }
  .cal-num { font-size: 10px; }
}
