:root {
  --bg-dark: #090d16;
  --bg-sidebar: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --border-color: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --accent-cyan: #06b6d4;
  --accent-purple: #a855f7;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-title: 'Outfit', sans-serif;
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
}

.app-layout { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 100;
}

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; padding: 0 8px; }
.logo-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--accent-purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.brand-text h2 { font-family: var(--font-title); font-size: 18px; font-weight: 700; color: #fff; }
.brand-text span { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

.nav-menu { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: transparent; border: none;
  color: var(--text-muted); font-family: var(--font-main);
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: all 0.2s ease;
}

.nav-item i { font-size: 18px; }
.nav-item:hover { background-color: rgba(255, 255, 255, 0.05); color: #fff; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.15), rgba(168, 85, 247, 0.05));
  border-left: 3px solid var(--primary);
  color: #fff; font-weight: 600;
}

.pulse-badge {
  margin-left: auto; font-size: 10px; text-transform: uppercase;
  background: rgba(16, 185, 129, 0.2); color: var(--accent-emerald);
  padding: 2px 6px; border-radius: 10px; font-weight: 700;
}

.sidebar-footer { padding-top: 16px; border-top: 1px solid var(--border-color); }
.status-indicator { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background-color: var(--text-muted); }
.status-dot.green { background-color: var(--accent-emerald); box-shadow: 0 0 8px var(--accent-emerald); }

/* MAIN CONTENT */
.main-content {
  margin-left: 260px; flex: 1;
  display: flex; flex-direction: column;
  min-height: 100vh; padding: 32px 40px;
}

.top-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 32px; }
.header-title h1 { font-family: var(--font-title); font-size: 26px; font-weight: 700; }
.header-title p { color: var(--text-muted); font-size: 13px; }
.header-actions { display: flex; gap: 12px; }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm);
  font-family: var(--font-main); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all 0.2s ease; border: none;
}

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-hover)); color: #fff; box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4); }
.btn-secondary { background-color: var(--bg-card); color: var(--text-main); border: 1px solid var(--border-color); }
.btn-secondary:hover { background-color: var(--bg-card-hover); }
.link-btn { background: none; border: none; color: var(--primary); font-size: 13px; font-weight: 500; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* TAB PANES */
.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* METRICS GRID */
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 32px; }
.metric-card {
  background-color: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 20px;
  display: flex; align-items: center; gap: 16px;
}

.metric-icon { width: 48px; height: 48px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 22px; }
.metric-icon.blue { background: rgba(99, 102, 241, 0.15); color: var(--primary); }
.metric-icon.purple { background: rgba(168, 85, 247, 0.15); color: var(--accent-purple); }
.metric-icon.cyan { background: rgba(6, 182, 212, 0.15); color: var(--accent-cyan); }
.metric-icon.emerald { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }

.metric-data .metric-label { font-size: 12px; color: var(--text-muted); display: block; }
.metric-data h3 { font-family: var(--font-title); font-size: 22px; font-weight: 700; margin: 2px 0; }
.metric-data .metric-desc { font-size: 11px; color: var(--text-muted); }

/* TWO COL GRID */
.two-col-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.panel-card { background-color: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); overflow: hidden; }
.panel-header { padding: 16px 20px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.panel-header h3 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.panel-body { padding: 20px; }

/* CLIENT CARDS GRID */
.search-bar-row { margin-bottom: 24px; }
.search-input-wrap { position: relative; flex: 1; }
.search-input-wrap i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 18px; }
.search-input-wrap input {
  width: 100%; padding: 12px 14px 12px 42px;
  background-color: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); color: #fff; font-family: var(--font-main);
  font-size: 14px; outline: none; transition: border-color 0.2s ease;
}

.search-input-wrap input:focus { border-color: var(--primary); }

.clients-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 20px; }
.client-card {
  background-color: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 20px;
  display: flex; flex-direction: column; gap: 16px; transition: all 0.2s ease;
}

.client-card:hover { border-color: var(--primary); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3); }
.client-card-header { display: flex; justify-content: space-between; align-items: flex-start; }
.client-card-header h3 { font-family: var(--font-title); font-size: 18px; font-weight: 700; color: #fff; }
.client-actions { display: flex; gap: 6px; }
.icon-btn { background: none; border: none; color: var(--text-muted); font-size: 16px; cursor: pointer; padding: 4px; border-radius: 4px; }
.icon-btn:hover { color: #fff; background-color: var(--border-color); }

.tag-section-title { font-size: 11px; text-transform: uppercase; color: var(--text-muted); font-weight: 600; margin-bottom: 6px; display: block; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tag { font-size: 11px; padding: 4px 8px; border-radius: 4px; background-color: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.1); color: var(--text-main); }
.tag.colab { background: rgba(16, 185, 129, 0.15); border-color: rgba(16, 185, 129, 0.3); color: #6ee7b7; }
.tag.slack { background: rgba(224, 30, 90, 0.15); border-color: rgba(224, 30, 90, 0.3); color: #f472b6; }
.tag.email { background: rgba(99, 102, 241, 0.15); border-color: rgba(99, 102, 241, 0.3); color: #a5b4fc; }
.tag.domain { background: rgba(6, 182, 212, 0.15); border-color: rgba(6, 182, 212, 0.3); color: #67e8f9; }
.tag.vendor { background: rgba(168, 85, 247, 0.15); border-color: rgba(168, 85, 247, 0.3); color: #d8b4fe; }

.client-notes { font-size: 12px; color: var(--text-muted); font-style: italic; background: rgba(0,0,0,0.25); padding: 8px 10px; border-radius: var(--radius-sm); }

/* COLLABORATOR LIST IN FORM */
.collaborators-list { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.colab-row { display: flex; gap: 8px; align-items: center; }
.colab-row input { flex: 1; }

/* TIMELINE FEED */
.filter-toolbar { display: flex; gap: 16px; margin-bottom: 24px; }
.select-wrap select { padding: 12px 16px; background-color: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: #fff; font-family: var(--font-main); font-size: 14px; outline: none; cursor: pointer; }

.timeline-feed { display: flex; flex-direction: column; gap: 16px; }
.timeline-item { background-color: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.timeline-item-header { display: flex; justify-content: space-between; align-items: center; }
.timeline-meta { display: flex; align-items: center; gap: 10px; }
.channel-badge { font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 3px 8px; border-radius: 4px; }
.channel-badge.email { background: rgba(99, 102, 241, 0.2); color: #a5b4fc; }
.channel-badge.slack { background: rgba(224, 30, 90, 0.2); color: #f472b6; }
.client-tag { font-size: 12px; font-weight: 600; color: var(--accent-cyan); }
.timeline-date { font-size: 12px; color: var(--text-muted); }
.timeline-subject { font-size: 16px; font-weight: 600; color: #fff; }
.timeline-sender { font-size: 12px; color: var(--text-muted); }
.timeline-body { background-color: rgba(0, 0, 0, 0.25); border-left: 3px solid var(--primary); padding: 12px 16px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; white-space: pre-wrap; color: #cbd5e1; font-size: 13px; }

/* AI CHAT */
.chat-container { display: flex; height: calc(100vh - 180px); background-color: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); overflow: hidden; }
.chat-sidebar { width: 300px; border-right: 1px solid var(--border-color); padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.chat-sidebar h4 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; color: var(--accent-purple); }
.chat-sidebar p { font-size: 12px; color: var(--text-muted); }
.prompt-pills { display: flex; flex-direction: column; gap: 8px; }
.prompt-pill { background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 10px 12px; color: var(--text-main); font-family: var(--font-main); font-size: 12px; text-align: left; cursor: pointer; transition: all 0.2s ease; }
.prompt-pill:hover { background: rgba(99, 102, 241, 0.15); border-color: var(--primary); }
.ai-info-box { margin-top: auto; background: rgba(6, 182, 212, 0.08); border: 1px solid rgba(6, 182, 212, 0.2); padding: 12px; border-radius: var(--radius-sm); font-size: 11px; color: #67e8f9; display: flex; gap: 8px; }

.chat-main { flex: 1; display: flex; flex-direction: column; }
.chat-messages { flex: 1; padding: 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.chat-message { display: flex; gap: 12px; max-width: 85%; }
.chat-message.user { margin-left: auto; flex-direction: row-reverse; }
.chat-message .avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.chat-message.assistant .avatar { background: linear-gradient(135deg, var(--primary), var(--accent-purple)); color: #fff; }
.chat-message.user .avatar { background: var(--border-color); color: #fff; }
.message-content { background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border-color); padding: 14px 18px; border-radius: var(--radius-md); font-size: 13px; line-height: 1.6; white-space: pre-wrap; }
.chat-message.user .message-content { background: var(--primary); border-color: var(--primary-hover); color: #fff; }
.chat-input-row { padding: 16px 24px; border-top: 1px solid var(--border-color); display: flex; gap: 12px; }
.chat-input-row input { flex: 1; padding: 12px 16px; background-color: var(--bg-dark); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: #fff; font-family: var(--font-main); font-size: 14px; outline: none; }
.chat-input-row input:focus { border-color: var(--primary); }

/* MODAL */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; z-index: 1000; }
.modal-overlay.active { display: flex; }
.modal-box { background-color: var(--bg-sidebar); border: 1px solid var(--border-color); border-radius: var(--radius-md); width: 540px; max-width: 90%; box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-box.modal-lg { width: 620px; }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-family: var(--font-title); font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; }
.modal-box form { padding: 24px; display: flex; flex-direction: column; gap: 16px; max-height: 80vh; overflow-y: auto; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 500; }
.form-group small { font-size: 11px; color: var(--text-muted); }
.form-group input, .form-group textarea { padding: 10px 14px; background-color: var(--bg-dark); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: #fff; font-family: var(--font-main); font-size: 14px; outline: none; }
.form-group input:focus, .form-group textarea:focus { border-color: var(--primary); }
.modal-footer { display: flex; justify-content: flex-end; gap: 12px; margin-top: 12px; }

.spin { animation: spin 1s linear infinite; }
@keyframes spin { 100% { transform: rotate(360deg); } }
