:root {
    --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #fbfcfe;
    --border-color: #edf2f7;

    --primary-blue: #2563eb;
    --primary-blue-light: #eff6ff;
    --primary-text: #0f172a;
    --secondary-text: #64748b;
    --muted-text: #94a3b8;

    --badge-green: #10b981;
    --badge-green-bg: #ecfdf5;
    --badge-red: #ef4444;
    --badge-red-bg: #fef2f2;

    --sidebar-w: 250px;
    --topbar-h: 70px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-page);
    color: var(--primary-text);
    -webkit-font-smoothing: antialiased;
}

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

.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    width: var(--sidebar-w);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 1.25rem 1rem;
    z-index: 100;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.5rem;
    margin-bottom: 1.5rem;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: var(--primary-text);
    font-weight: 800;
    font-size: 1.15rem;
}

.brand-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #2563eb, #60a5fa);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
}

.brand-icon svg { width: 18px; height: 18px; }

.sidebar-close-btn {
    display: none;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--secondary-text);
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
}

.nav-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius-sm);
    color: var(--secondary-text);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: 0.2s ease;
}

.nav-link svg { width: 18px; height: 18px; }

.nav-link:hover, .nav-item.active .nav-link {
    background-color: var(--primary-blue-light);
    color: var(--primary-blue);
    font-weight: 600;
}

.dot-badge {
    width: 6px;
    height: 6px;
    background: #ef4444;
    border-radius: 50%;
    margin-left: auto;
}

.sidebar-footer { padding-top: 1rem; }
.sidebar-card {
    background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
    padding: 1.1rem;
    border-radius: var(--radius-md);
}

.sidebar-card h4 {
    font-size: 0.85rem;
    font-weight: 700;
    color: #1e3a8a;
    line-height: 1.25;
}

.sidebar-card p {
    font-size: 0.74rem;
    color: #3b82f6;
    margin: 0.4rem 0 0.85rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
}

.btn-primary { background: var(--primary-blue); color: #fff; }
.btn-primary svg { width: 15px; height: 15px; }
.btn-block { width: 100%; }

/* ==================== TOPBAR ==================== */
.topbar {
    height: var(--topbar-h);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    position: sticky;
    top: 0;
    z-index: 90;
}

.topbar-left, .topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mobile-menu-toggle { display: none; }

.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-page);
    border: 1px solid var(--border-color);
    padding: 0.45rem 0.9rem;
    border-radius: 30px;
    width: 380px;
}

.search-icon { width: 16px; height: 16px; color: var(--muted-text); }

.search-box input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    font-size: 0.84rem;
}

.shortcut-key {
    font-size: 0.68rem;
    background: #fff;
    border: 1px solid var(--border-color);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    color: var(--muted-text);
}

.icon-btn {
    background: none;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--secondary-text);
    cursor: pointer;
    position: relative;
}

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

.notification-indicator {
    width: 6px;
    height: 6px;
    background: #ef4444;
    border-radius: 50%;
    position: absolute;
    top: 7px;
    right: 8px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    cursor: pointer;
    padding: 0.3rem 0.6rem;
    border-radius: 30px;
}

.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.user-meta { display: flex; flex-direction: column; }
.user-name { font-size: 0.84rem; font-weight: 700; color: var(--primary-text); }
.user-role { font-size: 0.72rem; color: var(--muted-text); }
.dropdown-arrow { width: 14px; height: 14px; color: var(--secondary-text); }

/* ==================== MAIN CONTENT AREA ==================== */
.content-area {
    padding: 1.75rem;
    flex: 1;
}

.welcome-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.welcome-banner h2 { font-size: 1.45rem; font-weight: 800; }
.welcome-banner p { color: var(--secondary-text); font-size: 0.88rem; margin-top: 0.2rem; }

.banner-quote {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.35rem;
}

.banner-quote span { font-size: 0.8rem; font-style: italic; color: var(--muted-text); }

.date-picker-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
}

.date-arrows button {
    border: none;
    background: none;
    cursor: pointer;
    color: var(--secondary-text);
}

/* ==================== 5 KPI METRICS ==================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1.15rem;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.6rem;
}

.kpi-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kpi-icon svg { width: 17px; height: 17px; }

.icon-blue { background: #eff6ff; color: #2563eb; }
.icon-cyan { background: #ecfeff; color: #0891b2; }
.icon-indigo { background: #eef2ff; color: #4f46e5; }
.icon-emerald { background: #ecfdf5; color: #059669; }
.icon-rose { background: #fff1f2; color: #e11d48; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
}
.badge svg { width: 12px; height: 12px; }
.badge-success { background: var(--badge-green-bg); color: var(--badge-green); }
.badge-danger { background: var(--badge-red-bg); color: var(--badge-red); }

.kpi-title { font-size: 0.78rem; color: var(--secondary-text); font-weight: 500; }

.kpi-value-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-top: 0.35rem;
}

.kpi-value { font-size: 1.55rem; font-weight: 800; color: var(--primary-text); }
.sparkline { width: 75px !important; height: 32px !important; }

/* ==================== GRID SYSTEM ==================== */
.grid-layout {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1.15rem;
}

.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.15rem;
    display: flex;
    flex-direction: column;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.9rem;
}

.card-header h3 { font-size: 0.95rem; font-weight: 700; color: var(--primary-text); }

.form-select-sm {
    border: 1px solid var(--border-color);
    background: var(--bg-page);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.74rem;
    color: var(--secondary-text);
    outline: none;
}

.view-all-link {
    font-size: 0.76rem;
    color: var(--primary-blue);
    text-decoration: none;
    font-weight: 600;
}

.chart-wrapper { height: 240px; position: relative; }

/* Leads by Source */
.source-wrapper {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    height: 100%;
}

.donut-container {
    position: relative;
    width: 140px;
    height: 140px;
    flex-shrink: 0;
}

.donut-center-text {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}
.donut-center-text strong { font-size: 1.1rem; }

.source-legend {
    list-style: none;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.source-legend li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
}

.source-legend span {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--secondary-text);
}

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.web { background: #3b82f6; }
.dot.gads { background: #06b6d4; }
.dot.li { background: #6366f1; }
.dot.ref { background: #f59e0b; }
.dot.ig { background: #ec4899; }
.dot.oth { background: #94a3b8; }

/* Pipeline Value Card */
.card-gradient-blue {
    background: linear-gradient(135deg, #eef5ff 0%, #dbeafe 100%);
    border-color: #bfdbfe;
    position: relative;
    overflow: hidden;
}

.pipeline-tag {
    font-size: 0.8rem;
    font-weight: 700;
    color: #1e40af;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.pipeline-tag svg { width: 16px; height: 16px; }

.icon-btn-plain {
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--secondary-text);
}

.icon-btn-plain svg { width: 16px; height: 16px; }

.pipeline-body { margin-top: 1.25rem; }

.pipeline-num-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.pipeline-num-row h2 {
    font-size: 1.6rem;
    font-weight: 800;
    color: #1e3a8a;
}

.badge-pill-green {
    background: #10b981;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}
.badge-pill-green svg { width: 12px; height: 12px; }

.pipeline-desc {
    font-size: 0.74rem;
    color: #3b82f6;
    margin-top: 0.5rem;
}

/* Tasks UI */
.task-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.task-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--border-color);
}

.task-item:last-child { border-bottom: none; padding-bottom: 0; }

.styled-checkbox {
    width: 15px;
    height: 15px;
    accent-color: var(--primary-blue);
    cursor: pointer;
}

.task-content { flex: 1; display: flex; flex-direction: column; }

.task-title {
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.task-title svg { width: 14px; height: 14px; }
.task-icon-orange { color: #f59e0b; }
.task-icon-blue { color: #2563eb; }

.task-sub { font-size: 0.7rem; color: var(--muted-text); }
.task-time { font-size: 0.7rem; color: var(--muted-text); margin: 0 0.5rem; }

.pill {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.2rem 0.45rem;
    border-radius: 4px;
}
.pill-high { background: #fee2e2; color: #dc2626; }
.pill-med { background: #fef3c7; color: #d97706; }
.pill-low { background: #dcfce7; color: #16a34a; }

/* Tables */
.table-responsive { overflow-x: auto; }

.leads-table, .team-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.leads-table td {
    padding: 0.65rem 0.3rem;
    border-bottom: 1px solid var(--border-color);
}

.leads-table tr:last-child td { border-bottom: none; }

.avatar-badge {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.bg-blue-soft { background: #dbeafe; color: #1d4ed8; }
.bg-purple-soft { background: #ede9fe; color: #6d28d9; }
.bg-emerald-soft { background: #d1fae5; color: #047857; }
.bg-amber-soft { background: #fef3c7; color: #b45309; }
.bg-cyan-soft { background: #cffafe; color: #0e7490; }

.leads-table strong { display: block; font-size: 0.8rem; color: var(--primary-text); }
.leads-table small { color: var(--muted-text); font-size: 0.7rem; }

.stage-pill {
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
    font-size: 0.68rem;
    font-weight: 600;
}

.stage-new { background: #dcfce7; color: #15803d; }
.stage-contacted { background: #dbeafe; color: #1e40af; }
.stage-qualified { background: #e0e7ff; color: #3730a3; }
.stage-proposal { background: #fef3c7; color: #b45309; }

/* Schedule Timeline */
.schedule-timeline {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.schedule-timeline li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.cal-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.cal-date b { font-size: 0.95rem; line-height: 1; }
.cal-date small { font-size: 0.62rem; color: var(--muted-text); font-weight: 700; }

.cal-details { display: flex; flex-direction: column; }
.cal-title {
    font-size: 0.78rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.cal-title svg { width: 14px; height: 14px; }
.text-cyan { color: #0891b2; }
.text-blue { color: #2563eb; }

.cal-time { font-size: 0.68rem; color: var(--muted-text); }

/* Team Table */
.team-table th {
    text-align: left;
    font-size: 0.72rem;
    color: var(--muted-text);
    font-weight: 600;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--border-color);
}

.team-table td {
    padding: 0.6rem 0.2rem;
    border-bottom: 1px solid var(--border-color);
}

.team-table tr:last-child td { border-bottom: none; }

.emp-cell { display: flex; align-items: center; gap: 0.5rem; }
.avatar-sm { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }

.progress-box { display: flex; align-items: center; gap: 0.5rem; }
.progress-box span { font-size: 0.74rem; width: 35px; }

.bar-wrap {
    flex: 1;
    height: 5px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill { height: 100%; background: var(--primary-blue); }

/* Sales Funnel */
.funnel-flex {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0.5rem 0;
}

.funnel-pyramid {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.layer { height: 22px; border-radius: 4px; }
.layer.fn-1 { width: 100%; background: #3b82f6; }
.layer.fn-2 { width: 80%; background: #60a5fa; }
.layer.fn-3 { width: 60%; background: #93c5fd; }
.layer.fn-4 { width: 42%; background: #fcd34d; }
.layer.fn-5 { width: 26%; background: #f87171; }

.funnel-legend {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.75rem;
}

.funnel-legend div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.dot.fn-1 { background: #3b82f6; }
.dot.fn-2 { background: #60a5fa; }
.dot.fn-3 { background: #93c5fd; }
.dot.fn-4 { background: #fcd34d; }
.dot.fn-5 { background: #f87171; }

/* Quick Actions */
.qa-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.qa-item {
    border: 1px solid var(--border-color);
    background: #fff;
    padding: 0.55rem 0.3rem;
    border-radius: 6px;
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--primary-text);
    transition: 0.2s ease;
}

.qa-item svg { width: 14px; height: 14px; }
.qa-item:hover { background: var(--primary-blue-light); color: var(--primary-blue); border-color: var(--primary-blue); }

.quote-strip {
    margin-top: 1rem;
    border-left: 2px solid var(--primary-blue);
    padding-left: 0.5rem;
    font-size: 0.72rem;
    font-style: italic;
    color: var(--secondary-text);
}

.mt-4 { margin-top: 1.15rem; }
.mb-4 { margin-bottom: 1.15rem; }

/* ==================== RESPONSIVE BREAKPOINTS ==================== */
@media (max-width: 1200px) {
    .kpi-grid { grid-template-columns: repeat(3, 1fr); }
    .col-5, .col-4, .col-3 { grid-column: span 6; }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }
    .sidebar.show { transform: translateX(0); }
    .sidebar-close-btn { display: block; }
    .mobile-menu-toggle { display: flex; }
    .search-box { display: none; }
    .user-meta, .dropdown-arrow { display: none; }

    .kpi-grid { grid-template-columns: 1fr; }
    .col-5, .col-4, .col-3 { grid-column: span 12; }
    .source-wrapper { flex-direction: column; }
    .banner-quote { align-items: flex-start; }
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 95;
}
.sidebar-backdrop.show { display: block; }