* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #6366f1; --primary-hover: #5457e5;
  --bg: #f5f7fa; --card-bg: #ffffff; --sidebar-bg: #ffffff;
  --border: #e5e7eb; --text: #111827; --text-secondary: #6b7280;
  --text-muted: #9ca3af; --success: #22c55e; --warning: #f59e0b;
  --danger: #ef4444; --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh; display: flex;
}
.sidebar {
  width: 220px; min-width: 220px; background: var(--sidebar-bg);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  padding: 16px 0; height: 100vh; position: sticky; top: 0;
}
.sidebar .logo { padding: 8px 20px 20px; font-size: 18px; font-weight: 700; color: var(--primary); border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.sidebar .nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: var(--text-secondary); text-decoration: none; font-size: 14px; transition: all .15s; cursor: pointer; border: none; background: none; width: 100%; text-align: left; }
.sidebar .nav-item:hover { background: #f3f4f6; color: var(--text); }
.sidebar .nav-item.active { background: #eef2ff; color: var(--primary); font-weight: 600; }
.topbar { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 12px 24px; background: var(--card-bg); border-bottom: 1px solid var(--border); }
.topbar .badge { font-size: 13px; color: var(--text-secondary); }
.topbar .badge .value { color: var(--primary); font-weight: 600; }
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.content-area { padding: 24px; flex: 1; }
.page { display: none; }
.page.active { display: block; }
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { padding: 20px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--border); }
th { background: #f9fafb; color: var(--text-secondary); font-weight: 600; white-space: nowrap; }
tr:hover { background: #f9fafb; }
tr.clickable { cursor: pointer; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); font-size: 13px; font-weight: 500; cursor: pointer; border: 1px solid var(--border); background: var(--card-bg); color: var(--text); transition: all .15s; }
.btn:hover { background: #f3f4f6; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.form-control { width: 100%; padding: 8px 12px; border-radius: var(--radius); border: 1px solid var(--border); font-size: 14px; color: var(--text); outline: none; transition: border-color .15s; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(99,102,241,0.1); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: none; align-items: center; justify-content: center; z-index: 1000; }
.modal-overlay.show { display: flex; }
.modal { background: var(--card-bg); border-radius: 12px; padding: 24px; max-width: 480px; width: 90%; box-shadow: 0 20px 60px rgba(0,0,0,0.15); max-height: 80vh; overflow-y: auto; }
.modal h3 { font-size: 18px; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.status-badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.status-new { background: #eef2ff; color: var(--primary); }
.status-contacted { background: #fef3c7; color: #92400e; }
.status-qualified { background: #d1fae5; color: #065f46; }
.status-converted { background: #dbeafe; color: #1e40af; }
.status-lost { background: #fee2e2; color: #991b1b; }
.kanban { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 16px; }
.kanban-col { min-width: 260px; max-width: 300px; flex: 1; background: #f3f4f6; border-radius: var(--radius); padding: 12px; min-height: 400px; }
.kanban-col-header { font-size: 14px; font-weight: 600; margin-bottom: 12px; display: flex; justify-content: space-between; }
.kanban-card { background: var(--card-bg); border-radius: var(--radius); padding: 12px; margin-bottom: 8px; cursor: grab; border: 1px solid var(--border); box-shadow: var(--shadow); }
.kanban-card:active { cursor: grabbing; }
.kanban-card .deal-title { font-size: 14px; font-weight: 500; }
.kanban-card .deal-info { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: 16px; }
.timeline-item::before { content: ''; position: absolute; left: -16px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); border: 2px solid var(--card-bg); }
.timeline-item .time { font-size: 11px; color: var(--text-muted); }
.timeline-item .content { font-size: 13px; margin-top: 2px; }
.inline-edit { cursor: pointer; padding: 2px 4px; border-radius: 4px; }
.inline-edit:hover { background: #f3f4f6; }
.inline-edit input, .inline-edit select { padding: 4px 8px; border: 1px solid var(--primary); border-radius: 4px; font-size: 14px; outline: none; }
.toast { position: fixed; top: 16px; right: 16px; z-index: 2000; padding: 12px 20px; border-radius: var(--radius); font-size: 14px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); display: none; max-width: 360px; }
.toast.info { background: var(--primary); color: #fff; }
.toast.warn { background: var(--danger); color: #fff; }
.toast.success { background: var(--success); color: #fff; }
.toast.show { display: block; animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mb-4 { margin-bottom: 16px; }
.mt-4 { margin-top: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); font-size: 13px; }
.hidden { display: none; }
.detail-grid { display: grid; grid-template-columns: 1fr 380px; gap: 20px; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-field { margin-bottom: 12px; }
.detail-field .field-label { font-size: 12px; color: var(--text-muted); }
.detail-field .field-value { font-size: 14px; margin-top: 2px; }

/* Entry page */
.entry-container {
  display: flex; gap: 24px; justify-content: center;
  align-items: center; min-height: 60vh; flex-wrap: wrap;
}
.entry-card {
  background: var(--card-bg); border: 2px solid var(--border);
  border-radius: 16px; padding: 40px; width: 280px;
  text-align: center; cursor: pointer; transition: all 0.2s;
}
.entry-card:hover { border-color: var(--primary); transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,0.15); }
.entry-icon { font-size: 48px; margin-bottom: 16px; }
.entry-title { font-size: 20px; font-weight: 600; margin-bottom: 8px; }
.entry-desc { font-size: 14px; color: var(--text-muted); }

/* Team list */
.team-list { max-width: 500px; margin: 20px auto; }
.team-select-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; margin-bottom: 12px;
  cursor: pointer; display: flex; justify-content: space-between;
  align-items: center; transition: all 0.2s;
}
.team-select-card:hover { border-color: var(--primary); }
.team-select-name { font-size: 18px; font-weight: 600; }
.team-select-role { font-size: 13px; color: var(--text-muted); }

/* Invite code display */
.invite-code-box {
  background: var(--bg); border: 1px dashed var(--primary);
  border-radius: 8px; padding: 16px; text-align: center; margin: 12px 0;
}
.invite-code {
  font-size: 24px; font-weight: 700; letter-spacing: 3px;
  color: var(--primary); padding: 8px 16px;
  background: var(--card-bg); border-radius: 6px;
  display: inline-block; margin: 8px 0;
}

/* Email history */
.email-history-item {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px; margin-bottom: 8px;
  cursor: pointer; transition: all 0.15s;
}
.email-history-item:hover { border-color: var(--primary); }
.email-history-item .flex { display: flex; justify-content: space-between; align-items: center; }

/* Attachments */
.attachment-item {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 10px; margin: 4px;
  font-size: 13px;
}
.attachment-item a { color: var(--primary); text-decoration: none; }
.attachment-item a:hover { text-decoration: underline; }

/* Lead checkbox column */
.lead-checkbox { width: 16px; height: 16px; cursor: pointer; }
#selectAllLeads { width: 16px; height: 16px; cursor: pointer; }

/* Text colors */
.text-warn { color: #f59e0b; font-size: 13px; }
.text-success { color: #22c55e; font-size: 13px; }
