/* ============================================
   CRM DASHBOARD - STYLES
   Premium dark theme inspired by Pipedrive
   ============================================ */

:root {
    /* Core palette */
    --bg-primary: #0f1117;
    --bg-secondary: #161822;
    --bg-tertiary: #1c1f2e;
    --bg-card: #1e2235;
    --bg-hover: #252a3a;
    --bg-input: #1a1d2b;

    --accent-purple-glow: rgba(167, 139, 250, 0.15);
    --accent-teal: #2dd4bf;
    --accent-teal-glow: rgba(45, 212, 191, 0.15);
    --accent-yellow: #fbbf24;

    /* Stage colors */
    --cold-color: #60a5fa;
    --warm-color: #fbbf24;
    --hot-color: #f87171;
    --customer-color: #34d399;

    /* Borders */
    --border-color: rgba(255, 255, 255, 0.06);
    --border-light: rgba(255, 255, 255, 0.1);

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
    --shadow-glow-blue: 0 0 20px rgba(79, 140, 255, 0.2);

    /* Layout */
    --sidebar-width: 250px;
    --sidebar-collapsed: 70px;
    --topbar-height: 64px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============ RESET & BASE ============ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.2);
}

/* ============ SIDEBAR ============ */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    transition: width var(--transition-slow);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 24px;
}

.brand-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
    transition: transform 0.3s ease;
}

.brand-icon:hover {
    transform: rotate(5deg) scale(1.05);
}

.brand-text {
    font-size: 1.4rem;
    font-weight: 800;
    background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -1px;
}

/* ============ DASHBOARD WRAPPER ============ */
#crm-app-wrapper {
    display: flex;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

.sidebar-nav {
    flex: 1;
    padding: 0 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.93rem;
    transition: all var(--transition-fast);
    position: relative;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-blue-glow);
    color: var(--accent-blue);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--accent-blue);
    border-radius: 0 3px 3px 0;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.badge {
    margin-left: auto;
    background: var(--accent-red);
    color: white;
    font-size: 0.7rem;
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 700;
}

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

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============ MAIN CONTENT ============ */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    transition: margin-left var(--transition-slow);
    background: radial-gradient(circle at 50% 50%, #0f172a 0%, #020617 100%);
    position: relative;
    width: calc(100vw - var(--sidebar-width)); /* Force true width */
}

.main-content::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.2), transparent);
    pointer-events: none;
}

/* ============ TOPBAR ============ */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
}

.page-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box i {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.search-box input {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 12px 8px 36px;
    color: var(--text-primary);
    font-size: 0.85rem;
    width: 240px;
    transition: all var(--transition-fast);
    font-family: 'Inter', sans-serif;
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--accent-blue-glow);
    width: 300px;
}

.topbar-notifications {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.topbar-notifications:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.notif-dot {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 8px;
    height: 8px;
    background: var(--accent-red);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.3); }
}

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), #6366f1);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow-blue);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}

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

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--accent-red);
    color: white;
}

.btn-danger:hover {
    background: #ef4444;
    transform: translateY(-1px);
}

.btn-sm {
    padding: 7px 14px;
    font-size: 0.8rem;
}

/* ============ VIEWS ============ */
.views-container {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.view {
    display: none;
    height: 100%;
    overflow: hidden;
    padding: 24px;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============ PIPELINE VIEW ============ */
.pipeline-header {
    margin-bottom: 20px;
    flex-shrink: 0;
}

.pipeline-filters {
    display: flex;
    gap: 10px;
}

.filter-select {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.filter-search {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
    width: 250px;
    transition: border-color var(--transition-fast);
}

.filter-search:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.pipeline-board {
    display: flex;
    gap: 16px;
    flex: 1;
    overflow-x: auto;
    padding-bottom: 16px;
}

.pipeline-column {
    min-width: 300px;
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.column-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.column-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stage-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.stage-dot.cold { background: var(--cold-color); box-shadow: 0 0 8px rgba(96,165,250,0.4); }
.stage-dot.warm { background: var(--warm-color); box-shadow: 0 0 8px rgba(251,191,36,0.4); }
.stage-dot.hot { background: var(--hot-color); box-shadow: 0 0 8px rgba(248,113,113,0.4); }
.stage-dot.customer { background: var(--customer-color); box-shadow: 0 0 8px rgba(52,211,153,0.4); }

.column-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
}

.lead-count {
    background: var(--bg-hover);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.column-amount {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-green);
}

.column-cards {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 100px;
}

.column-cards.drag-over {
    background: var(--accent-blue-glow);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* Lead Card */
.lead-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px;
    cursor: grab;
    transition: all var(--transition-fast);
    user-select: none;
}

.lead-card:hover {
    border-color: var(--accent-blue);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.lead-card.dragging {
    opacity: 0.5;
    transform: rotate(3deg);
}

.lead-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.lead-card-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.lead-card-amount {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--accent-green);
}

.lead-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.lead-card-meta i {
    margin-right: 4px;
    font-size: 0.7rem;
}

.lead-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.lead-card-source {
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.source-meta { background: rgba(79,140,255,0.15); color: var(--accent-blue); }
.source-referral { background: rgba(167,139,250,0.15); color: var(--accent-purple); }
.source-organic { background: rgba(52,211,153,0.15); color: var(--accent-green); }

.lead-card-payment {
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.payment-pending { background: rgba(251,191,36,0.15); color: var(--accent-yellow); }
.payment-partial { background: rgba(251,146,60,0.15); color: var(--accent-orange); }
.payment-paid { background: rgba(52,211,153,0.15); color: var(--accent-green); }
.payment-overdue { background: rgba(248,113,113,0.15); color: var(--accent-red); }

/* ============ LEADS TABLE VIEW ============ */
.leads-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 10px;
}

.leads-filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.leads-table-wrapper {
    flex: 1;
    overflow: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    width: 100%; /* Stretch to end */
}

.leads-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 100%; /* Ensure it spans the wrapper */
}

.leads-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.leads-table th {
    background: var(--bg-tertiary);
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color);
    transition: color var(--transition-fast);
}

.leads-table th:hover {
    color: var(--accent-blue);
}

.leads-table th i {
    margin-left: 4px;
    font-size: 0.7rem;
}

.leads-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
    white-space: nowrap;
}

.leads-table tbody tr {
    transition: background var(--transition-fast);
    cursor: pointer;
}

.leads-table tbody tr:hover {
    background: var(--bg-hover);
}

.stage-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.stage-cold { background: rgba(96,165,250,0.15); color: var(--cold-color); }
.stage-warm { background: rgba(251,191,36,0.15); color: var(--warm-color); }
.stage-hot { background: rgba(248,113,113,0.15); color: var(--hot-color); }
.stage-customer { background: rgba(52,211,153,0.15); color: var(--customer-color); }

.action-btns {
    display: flex;
    gap: 6px;
}

.action-btn {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: none;
    background: var(--bg-hover);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: all var(--transition-fast);
}

.action-btn:hover {
    background: var(--accent-blue-glow);
    color: var(--accent-blue);
}

.action-btn.delete:hover {
    background: var(--accent-red-glow);
    color: var(--accent-red);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

/* ============ ANALYTICS VIEW ============ */
.analytics-controls {
    margin-bottom: 24px;
    flex-shrink: 0;
}

.time-range-selector {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    width: fit-content;
}

.time-btn {
    padding: 8px 18px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.time-btn.active {
    background: var(--accent-blue);
    color: white;
}

.time-btn:hover:not(.active) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.analytics-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
    overflow-y: auto;
    padding-right: 4px; /* Space for scrollbar */
}

.kpi-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
}

.kpi-card {
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 18px;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

.kpi-card:hover {
    transform: translateY(-5px);
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 10px 25px -10px rgba(0, 0, 0, 0.5), 0 0 20px rgba(59, 130, 246, 0.1);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.kpi-icon.blue { background: var(--accent-blue-glow); color: var(--accent-blue); }
.kpi-icon.green { background: var(--accent-green-glow); color: var(--accent-green); }
.kpi-icon.orange { background: var(--accent-orange-glow); color: var(--accent-orange); }
.kpi-icon.purple { background: var(--accent-purple-glow); color: var(--accent-purple); }
.kpi-icon.teal { background: var(--accent-teal-glow); color: var(--accent-teal); }

.kpi-data {
    display: flex;
    flex-direction: column;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.kpi-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 2px;
}

.chart-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.chart-row:has(.wide:only-child),
.chart-row:has(.chart-card.wide:first-child:last-child) {
    grid-template-columns: 1fr;
}

.chart-card {
    background: rgba(15, 23, 42, 0.3);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: all var(--transition-fast);
}

.chart-card:hover {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(15, 23, 42, 0.4);
}

.chart-card.wide {
    grid-column: 1 / -1;
}

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.chart-header h3 {
    font-size: 1rem;
    font-weight: 700;
}

.chart-type-select {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 5px 10px;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
}

.chart-type-select:focus {
    outline: none;
    border-color: var(--accent-blue);
}

/* ============ REMINDERS VIEW ============ */
.reminders-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-shrink: 0;
}

.reminders-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
}

.reminders-filters {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.reminders-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.reminder-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all var(--transition-fast);
}

.reminder-item:hover {
    border-color: var(--accent-blue);
    box-shadow: var(--shadow-sm);
}

.reminder-item.overdue {
    border-left: 3px solid var(--accent-red);
}

.reminder-item.upcoming {
    border-left: 3px solid var(--accent-yellow);
}

.reminder-item.completed {
    border-left: 3px solid var(--accent-green);
    opacity: 0.6;
}

.reminder-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--accent-blue-glow);
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.reminder-content {
    flex: 1;
}

.reminder-lead-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.reminder-note-text {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.reminder-datetime {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.reminder-datetime i {
    font-size: 0.7rem;
}

.reminder-actions {
    display: flex;
    gap: 8px;
}

/* ============ META ADS INTEGRATION ============ */
.meta-ads-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    overflow: hidden;
    flex-shrink: 0;
}

.meta-ads-header {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    gap: 16px;
    flex-wrap: nowrap;
}

.meta-ads-title {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 16px;
    flex: 1;
    min-width: 0;
}

.meta-ads-title h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 2px 0;
    white-space: nowrap;
}

.meta-ads-card .ie-icon.meta {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px;
    max-width: 44px;
    background: linear-gradient(135deg, #0081FB, #00C2FF);
    color: white;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.meta-ads-actions {
    flex-shrink: 0;
}

.meta-status {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot.connected { 
    background: var(--accent-green); 
    box-shadow: 0 0 10px var(--accent-green);
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.meta-ads-body {
    padding: 20px 24px;
}

.meta-controls {
    display: grid !important;
    grid-template-columns: 1fr 1fr auto !important;
    gap: 16px;
    align-items: flex-end;
}

.meta-controls .btn-primary {
    padding: 10px 24px;
    height: 42px;
    white-space: nowrap;
}

.meta-controls > div {
    flex-shrink: 0;
}

.meta-controls > div:first-child {
    flex: 1;
    flex-shrink: 1;
    min-width: 150px;
}

.meta-controls label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    display: block;
    margin-bottom: 6px;
}

.meta-controls .filter-select,
.meta-controls .filter-search {
    width: 100%;
    box-sizing: border-box;
}

.meta-sync-info {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 14px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.meta-sync-count {
    color: var(--accent-green);
    font-weight: 600;
}

.meta-sync-log {
    margin-top: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    max-height: 200px;
    overflow-y: auto;
}

.sync-log-entries {
    padding: 12px 16px;
    font-family: 'Inter', monospace;
    font-size: 0.78rem;
    line-height: 1.8;
    color: var(--text-secondary);
}

.sync-log-entries .log-success { color: var(--accent-green); }
.sync-log-entries .log-error { color: var(--accent-red); }
.sync-log-entries .log-info { color: var(--accent-blue); }
.sync-log-entries .log-warn { color: var(--accent-yellow); }

@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinning {
    animation: spin 1s linear infinite;
}

/* ============ IMPORT/EXPORT VIEW ============ */
.ie-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    max-width: 900px;
}

.ie-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 16px;
}

.ie-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-md);
    background: var(--accent-blue-glow);
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.ie-icon.export {
    background: var(--accent-green-glow);
    color: var(--accent-green);
}

.ie-card h3 {
    font-size: 1.15rem;
    font-weight: 700;
}

.ie-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.upload-zone {
    width: 100%;
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-md);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-muted);
}

.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--accent-blue);
    background: var(--accent-blue-glow);
    color: var(--accent-blue);
}

.upload-zone i {
    font-size: 2rem;
    margin-bottom: 8px;
    display: block;
}

.upload-zone p {
    font-size: 0.85rem;
}

.export-options {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    accent-color: var(--accent-blue);
    width: 16px;
    height: 16px;
}

/* ============ MODALS ============ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

.modal-large {
    width: 900px;
    max-width: 95vw;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Form Styles */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.required {
    color: var(--accent-red);
}

.form-group input,
.form-group select,
.form-group textarea {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
    transition: border-color var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--accent-blue-glow);
}

.form-group textarea {
    resize: vertical;
}

/* Detail Modal */
.detail-body {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 0;
    padding: 0;
}

.detail-sidebar {
    padding: 24px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.detail-info {
    text-align: center;
}

.detail-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-size: 1.3rem;
    margin: 0 auto 12px;
}

.detail-info h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.detail-stage-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    margin-top: 8px;
}

.detail-fields {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.detail-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.detail-field label {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.detail-field label i {
    width: 14px;
    text-align: center;
    font-size: 0.7rem;
}

.detail-field span {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 500;
    padding-left: 20px;
}

.detail-actions {
    display: flex;
    gap: 8px;
}

.detail-main {
    padding: 24px;
    overflow-y: auto;
    max-height: 70vh;
}

.notes-section h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.notes-section h3 i {
    color: var(--accent-yellow);
}

.add-note-form {
    margin-bottom: 24px;
}

.add-note-form textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    resize: vertical;
    transition: border-color var(--transition-fast);
}

.add-note-form textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--accent-blue-glow);
}

.note-options {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.reminder-fields {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.reminder-fields input {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 10px;
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: 'Inter', sans-serif;
}

.reminder-fields input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.note-button-group {
    margin-left: auto;
    display: flex;
    gap: 10px;
}



/* Notes Timeline */
.notes-timeline {
    position: relative;
}

.notes-timeline::before {
    content: '';
    position: absolute;
    left: 16px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.note-item {
    position: relative;
    padding-left: 44px;
    margin-bottom: 20px;
}

.note-dot {
    position: absolute;
    left: 10px;
    top: 4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-blue);
    border: 3px solid var(--bg-secondary);
    z-index: 1;
}

.note-dot.reminder {
    background: var(--accent-yellow);
}

.note-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
}

.note-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.note-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.note-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.note-reminder-info {
    margin-top: 8px;
    padding: 8px 10px;
    background: rgba(251,191,36,0.08);
    border-radius: 6px;
    font-size: 0.78rem;
    color: var(--accent-yellow);
    display: flex;
    align-items: center;
    gap: 8px;
}

.note-delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all var(--transition-fast);
}

.note-delete-btn:hover {
    background: var(--accent-red-glow);
    color: var(--accent-red);
}

/* ============ TOAST ============ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 2000;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    min-width: 300px;
}

.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error { border-left: 3px solid var(--accent-red); }
.toast.info { border-left: 3px solid var(--accent-blue); }
.toast.warning { border-left: 3px solid var(--accent-yellow); }

.toast i {
    font-size: 1.1rem;
}

.toast.success i { color: var(--accent-green); }
.toast.error i { color: var(--accent-red); }
.toast.info i { color: var(--accent-blue); }
.toast.warning i { color: var(--accent-yellow); }

.toast-text {
    flex: 1;
    font-size: 0.85rem;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 2px;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(30px); }
}

/* ============ REMINDER POPUP ============ */
.reminder-popup {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
    animation: slideDown 0.4s ease;
}

.reminder-popup-content {
    background: var(--bg-card);
    border: 1px solid var(--accent-yellow);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: 0 0 30px rgba(251,191,36,0.2);
    text-align: center;
    max-width: 320px;
}

.reminder-popup-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(251,191,36,0.15);
    color: var(--accent-yellow);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 1.2rem;
    animation: pulse 1.5s infinite;
}

.reminder-popup-content h4 {
    margin-bottom: 8px;
    font-size: 1rem;
}

.reminder-popup-content p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.5;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1200px) {
    .kpi-row {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .menu-toggle {
        display: flex;
    }

    .detail-body {
        grid-template-columns: 1fr;
    }

    .detail-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .ie-grid {
        grid-template-columns: 1fr;
    }

    .chart-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .kpi-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .pipeline-board {
        flex-direction: column;
    }

    .pipeline-column {
        min-width: 100%;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .search-box {
        display: none;
    }

    .topbar-right {
        gap: 8px;
    }
}

/* ============ LOGIN PAGE ============ */
.login-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, #1e293b 0%, #020617 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
}

.login-card {
    background: rgba(15, 23, 42, 0.82);
    backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 32px;
    width: 100%;
    max-width: 440px;
    padding: 60px 50px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6), var(--shadow-glow);
    animation: fadeInScale 0.7s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.login-header {
    text-align: center;
}

.login-header h1 {
    font-size: 2.4rem;
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: -1px;
    margin: 20px 0 10px;
    background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-header p {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

.login-logo {
    display: flex;
    justify-content: center;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}

.login-form label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding-left: 4px;
}

.login-logo img {
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.1);
    transition: transform 0.3s ease;
}

.login-logo img:hover {
    transform: translateY(-5px) rotate(5deg);
}

.login-form input {
    background: rgba(2, 6, 23, 0.6) !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    padding: 14px 18px !important;
    font-size: 1rem !important;
    border-radius: 12px !important;
    transition: all 0.3s ease !important;
}

.login-form input:focus {
    border-color: var(--accent-blue) !important;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15) !important;
    background: var(--bg-input) !important;
}

.btn-primary.btn-block {
    height: 52px;
    font-size: 1.05rem;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    border: none;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
    transition: all 0.3s ease;
}

.btn-primary.btn-block:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.5);
    filter: brightness(1.1);
}

@keyframes fadeInScale {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-form input {
    margin-bottom: 0 !important;
}
