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

:root {
    --bg: #0a0a0f;
    --surface: #12121a;
    --surface-raised: #1a1a26;
    --accent: #22c55e;
    --accent-dim: #16a34a;
    --accent-glow: rgba(34, 197, 94, 0.15);
    --text: #f0f0f5;
    --text-muted: #8888a0;
    --border: #2a2a3a;
    --danger: #ef4444;
    --warning: #eab308;
    --info: #3b82f6;
    --purple: #a855f7;
    --sidebar-width: 240px;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
}

h1, h2, h3, h4 { font-family: 'Space Grotesk', sans-serif; }

/* Noise overlay */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s;
}

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

.logo {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
    text-decoration: none;
}
.logo span { color: var(--accent); }

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}
.nav-item:hover {
    color: var(--text);
    background: var(--surface-raised);
}
.nav-item.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: var(--accent-glow);
}

.sidebar-footer {
    padding: 12px 0;
    border-top: 1px solid var(--border);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    position: relative;
    z-index: 1;
    min-height: 100vh;
}

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 32px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 50;
}

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

.page-title {
    flex: 1;
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: -0.3px;
}

/* Buttons */
.btn {
    padding: 8px 20px;
    border-radius: 8px;
    border: none;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-primary {
    background: var(--accent);
    color: #000;
}
.btn-primary:hover {
    background: var(--accent-dim);
}
.btn-secondary {
    background: var(--surface-raised);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    border-color: var(--text-muted);
}
.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}
.btn-sm {
    padding: 5px 12px;
    font-size: 0.8rem;
}

/* Views */
.view {
    display: none;
    padding: 24px 32px;
}
.view.active { display: block; }

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

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    transition: border-color 0.2s;
}
.stat-card:hover { border-color: rgba(136, 136, 160, 0.3); }
.stat-card.accent { border-color: rgba(34, 197, 94, 0.3); }
.stat-card.accent .stat-value { color: var(--accent); }

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}
.stat-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 4px;
}
.stat-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.card-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
}
.card-body {
    padding: 16px 20px;
    max-height: 400px;
    overflow-y: auto;
}

/* Follow-up items */
.followup-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.followup-item:last-child { border-bottom: none; }

.followup-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
    margin-top: 6px;
}
.followup-dot.overdue { background: var(--danger); }
.followup-dot.upcoming { background: var(--warning); }

.followup-info { flex: 1; }
.followup-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 2px;
}
.followup-subject {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.followup-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Activity items */
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }

.activity-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
    background: var(--accent-glow);
    color: var(--accent);
}
.activity-icon.stage { background: rgba(59, 130, 246, 0.15); color: var(--info); }
.activity-icon.email { background: rgba(168, 85, 247, 0.15); color: var(--purple); }
.activity-icon.created { background: var(--accent-glow); color: var(--accent); }

.activity-text {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.activity-text strong { color: var(--text); }
.activity-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 14px;
    min-width: 250px;
}
.search-box input {
    background: none;
    border: none;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    outline: none;
    width: 100%;
}
.search-box input::placeholder { color: var(--text-muted); }
.search-box svg { color: var(--text-muted); flex-shrink: 0; }

.filter-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.filter-tab {
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.filter-tab:hover { border-color: var(--text-muted); color: var(--text); }
.filter-tab.active {
    background: var(--accent-glow);
    border-color: rgba(34, 197, 94, 0.3);
    color: var(--accent);
}

/* Leads Table */
.leads-table-wrapper {
    overflow-x: auto;
}
.leads-table {
    width: 100%;
    border-collapse: collapse;
}
.leads-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.leads-table td {
    padding: 14px 16px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
}
.leads-table tr {
    cursor: pointer;
    transition: background 0.2s;
}
.leads-table tbody tr:hover {
    background: var(--surface-raised);
}

/* Stage Badges */
.stage-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}
.stage-new { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.stage-contacted { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.stage-qualified { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.stage-proposal { background: rgba(234, 179, 8, 0.15); color: #eab308; }
.stage-negotiation { background: rgba(249, 115, 22, 0.15); color: #f97316; }
.stage-won { background: rgba(34, 197, 94, 0.25); color: #22c55e; border: 1px solid rgba(34, 197, 94, 0.3); }
.stage-lost { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

.deal-value {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    color: var(--accent);
}

.lead-email {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Pipeline Board */
.pipeline-board {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 20px;
    min-height: calc(100vh - 160px);
}

.pipeline-column {
    min-width: 260px;
    max-width: 300px;
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
}

.pipeline-col-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.pipeline-col-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: capitalize;
}
.pipeline-col-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--surface-raised);
    padding: 2px 8px;
    border-radius: 100px;
}
.pipeline-col-value {
    font-size: 0.75rem;
    color: var(--accent);
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
}

.pipeline-col-body {
    padding: 12px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pipeline-card {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.2s;
}
.pipeline-card:hover {
    border-color: rgba(34, 197, 94, 0.3);
    transform: translateY(-1px);
}
.pipeline-card-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
}
.pipeline-card-company {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.pipeline-card-value {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    color: var(--accent);
    font-size: 0.85rem;
}

/* Sequences */
.sequence-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
}
.sequence-header {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}
.sequence-header:hover { background: var(--surface-raised); }
.sequence-name {
    font-size: 1.05rem;
    font-weight: 600;
}
.sequence-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}
.sequence-badge {
    font-size: 0.75rem;
    padding: 4px 12px;
    border-radius: 100px;
    background: var(--accent-glow);
    color: var(--accent);
    font-weight: 600;
}
.sequence-badge.inactive {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.sequence-steps {
    padding: 0 24px 20px;
    display: none;
}
.sequence-steps.open { display: block; }

.step-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.step-item:last-child { border-bottom: none; }

.step-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-glow);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
    font-family: 'Space Grotesk', sans-serif;
}

.step-content { flex: 1; }
.step-subject {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
}
.step-delay {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.step-preview {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 6px;
    white-space: pre-line;
    line-height: 1.5;
    max-height: 60px;
    overflow: hidden;
}

/* Lead Detail */
.lead-detail {
    max-width: 800px;
}

.lead-detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}
.lead-detail-back {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
}
.lead-detail-back:hover { color: var(--text); }

.lead-detail-info {
    flex: 1;
}
.lead-detail-name {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}
.lead-detail-company {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.lead-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.detail-field {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
}
.detail-field-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}
.detail-field-value {
    font-size: 0.95rem;
    font-weight: 500;
}

.lead-detail-section {
    margin-top: 24px;
}
.lead-detail-section h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    margin: 20px;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}
.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.modal-close:hover { color: var(--text); }

/* Forms */
.form-group {
    padding: 0 24px;
    margin-top: 16px;
}
.form-group:first-of-type { margin-top: 20px; }
.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-raised);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent);
}
.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}
.form-group select {
    cursor: pointer;
}
.form-group textarea {
    resize: vertical;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 24px;
    border-top: 1px solid var(--border);
    margin-top: 20px;
    justify-content: flex-end;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--accent);
    color: #000;
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.85rem;
    z-index: 300;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
}
.toast.show {
    transform: translateY(0);
    opacity: 1;
}
.toast.error {
    background: var(--danger);
    color: #fff;
}

/* Empty state */
.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .view { padding: 16px; }
    .topbar { padding: 12px 16px; }
    .lead-detail-grid { grid-template-columns: 1fr; }
    .filter-tabs { overflow-x: auto; flex-wrap: nowrap; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}

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