/* ==========================================================================
   DESIGN SYSTEM & VARIABLES (Support Dark and Light Themes)
   ========================================================================== */
:root {
    /* Dark Theme Variables (Midnight Navy & Purple/Blue Glow - matching MyBrand site) */
    --bg-darkest: #06070B;
    --bg-dark: #0A0D16;
    --bg-card: rgba(19, 21, 34, 0.65);
    --bg-card-hover: rgba(29, 32, 52, 0.85);
    --border-color: rgba(255, 255, 255, 0.06);
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --text-dark: #64748B;
    --shadow-color: rgba(0, 0, 0, 0.6);

    --primary: #8B5CF6;        /* Violet Accent */
    --primary-glow: rgba(139, 92, 246, 0.15);
    --primary-dark: #00A3FF;   /* Sky Blue Accent */
    --border-color-glow: rgba(139, 92, 246, 0.3);
    
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #00A3FF;
    
    --font-heading: 'Red Hat Display', sans-serif;
    --font-body: 'Inter Tight', sans-serif;
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-width: 260px;
}

/* Light Theme Variables */
body.light-mode {
    --bg-darkest: #F1F5F9;
    --bg-dark: #FFFFFF;
    --bg-card: rgba(255, 255, 255, 0.8);
    --bg-card-hover: rgba(241, 245, 249, 0.95);
    --border-color: rgba(15, 23, 42, 0.08);
    --text-main: #0F172A;
    --text-muted: #475569;
    --text-dark: #64748B;
    --shadow-color: rgba(15, 23, 42, 0.1);
}

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

body {
    background-color: var(--bg-darkest);
    color: var(--text-main);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.2);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Utility classes */
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-info { color: var(--info); }
.ml-2 { margin-left: 0.5rem; }
.mr-2 { margin-right: 0.5rem; }
.mr-1 { margin-right: 0.25rem; }

.logo-text-black {
    fill: var(--text-main) !important;
    transition: fill 0.3s;
}

/* Glassmorphism utility */
.glass {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 32px var(--shadow-color);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.9rem;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-primary {
    background-color: var(--primary);
    color: #000;
    box-shadow: 0 4px 14px var(--primary-glow);
}
.btn-primary:hover {
    background-color: var(--primary-dark);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-main);
}
.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--text-muted);
}

.btn-outline-danger {
    background: transparent;
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--danger);
}
.btn-outline-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
}

/* ==========================================================================
   PASSWORD LOGIN CONTAINER
   ========================================================================== */
#login-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-darkest);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

#login-container.active {
    opacity: 1;
    pointer-events: auto;
}

.login-glow {
    position: absolute;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    pointer-events: none;
    filter: blur(40px);
}

.login-card {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 420px;
    padding: 40px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: 0 20px 40px var(--shadow-color);
    text-align: center;
}

.login-card:hover {
    border-color: var(--border-color-glow);
    box-shadow: 0 20px 40px rgba(139, 92, 246, 0.05);
}

.brand-header {
    margin-bottom: 30px;
}

.logo-wrapper {
    width: 70px;
    height: 70px;
    margin: 0 auto 15px;
}

.brand-logo-svg {
    width: 100%;
    height: 100%;
}

.brand-header h2 {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.brand-header .subtitle {
    font-size: 0.75rem;
    letter-spacing: 3px;
    color: var(--primary);
    font-weight: 700;
    margin-top: 4px;
}

/* Input Styles */
.input-group {
    text-align: left;
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-family: var(--font-heading);
    letter-spacing: 0.5px;
}

.field-icon-wrapper, .password-wrapper {
    position: relative;
}

.field-icon-wrapper input, .password-wrapper input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    padding: 12px 40px;
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 1rem;
    border-radius: 8px;
    outline: none;
    transition: var(--transition-smooth);
}

body.light-mode .field-icon-wrapper input,
body.light-mode .password-wrapper input {
    background: rgba(255, 255, 255, 0.8);
}

.field-icon-wrapper input:focus, .password-wrapper input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.15);
}

.input-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dark);
}

.toggle-pass {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-dark);
    cursor: pointer;
}
.toggle-pass:hover {
    color: var(--text-muted);
}

.error-msg {
    display: none;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger);
    color: #F87171;
    font-size: 0.85rem;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: left;
    align-items: center;
    gap: 8px;
}

.error-msg.active {
    display: flex;
}

.login-footer {
    margin-top: 30px;
    font-size: 0.75rem;
    color: var(--text-dark);
}

/* ==========================================================================
   APP MAIN DASHBOARD
   ========================================================================== */
#app-container {
    display: flex;
    min-height: 100vh;
    opacity: 0;
    transition: opacity 0.5s ease;
}

#app-container.active {
    opacity: 1;
}

/* Sidebar Navigation */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-dark);
    border-right: 1px solid var(--border-color);
    padding: 24px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}

.logo-wrapper-sm {
    width: 32px;
    height: 32px;
}

.sidebar-header .brand-name {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 800;
    display: block;
    line-height: 1.1;
}

.sidebar-header .app-tag {
    font-size: 0.65rem;
    letter-spacing: 1.5px;
    color: var(--primary);
    font-weight: 700;
    text-transform: uppercase;
}

.sidebar-nav {
    flex-grow: 1;
}

.sidebar-nav ul {
    list-style: none;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    margin-bottom: 6px;
}

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

.nav-item:hover, .nav-item.active {
    background-color: rgba(255, 255, 255, 0.03);
    color: var(--primary);
}

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

.user-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.status-indicator.online {
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success);
}

/* Main Content Workspace */
.main-content {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    padding: 40px;
    width: calc(100% - var(--sidebar-width));
}

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

.content-header h1 {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.pulse-badge {
    background-color: rgba(139, 92, 246, 0.05);
    border: 1px solid rgba(139, 92, 246, 0.2);
    padding: 6px 14px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pulse-dot {
    width: 6px;
    height: 6px;
    background-color: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--primary);
    animation: pulse 1.8s infinite;
}

.badge-text {
    font-size: 0.75rem;
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
}

@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.5; }
}

/* ==========================================================================
   TAB MANAGEMENT
   ========================================================================== */
.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* ==========================================================================
   STATS GRID
   ========================================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stats-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px;
    transition: var(--transition-smooth);
}

.stats-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-color-glow);
}

.stats-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.stats-info h3 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.2;
}

.stats-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ==========================================================================
   CONTROL PANEL (Search & Filters)
   ========================================================================== */
.control-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 20px;
    margin-bottom: 20px;
}

.search-box {
    position: relative;
    flex-grow: 1;
    max-width: 480px;
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dark);
}

.search-box input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    padding: 10px 15px 10px 42px;
    border-radius: 8px;
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition-smooth);
}

body.light-mode .search-box input {
    background: #fff;
}

.search-box input:focus {
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.4);
}

body.light-mode .search-box input:focus {
    background: #fff;
}

.filter-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-select {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    padding: 10px 15px;
    border-radius: 8px;
    color: var(--text-muted);
    outline: none;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition-smooth);
}

body.light-mode .filter-select {
    background: #fff;
}

.filter-select:focus, .filter-select:hover {
    border-color: var(--primary);
    color: var(--text-main);
}

.filter-select option {
    background-color: var(--bg-dark);
    color: var(--text-main);
}

body.light-mode .filter-select option {
    background-color: #fff;
}

/* ==========================================================================
   BULK ACTIONS BAR
   ========================================================================== */
.bulk-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    margin-bottom: 20px;
    background: rgba(139, 92, 246, 0.05);
    border: 1px solid var(--primary-glow);
    border-radius: 8px;
    animation: slideDown 0.3s ease;
}

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

.selected-count {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--primary);
}

.bulk-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* ==========================================================================
   LEADS TABLE
   ========================================================================== */
.table-container {
    overflow-x: auto;
    max-width: 100%;
    margin-bottom: 20px;
    position: relative;
}

.leads-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.85rem;
}

.leads-table th, .leads-table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.leads-table th {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--text-muted);
    background-color: rgba(255, 255, 255, 0.01);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

/* Sticky First Column for Business Name */
.leads-table th:nth-child(3),
.leads-table td:nth-child(3) {
    position: sticky;
    left: 0;
    z-index: 10;
    background-color: var(--bg-dark);
    border-right: 1px solid var(--border-color);
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
}

body.light-mode .leads-table th:nth-child(3),
body.light-mode .leads-table td:nth-child(3) {
    background-color: #fff;
}

.leads-table tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

body.light-mode .leads-table tr:hover td {
    background-color: rgba(0, 0, 0, 0.01);
}

.leads-table tr:hover td:nth-child(3) {
    background-color: var(--bg-card-hover);
}

/* Cell content constraints */
.leads-table td {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leads-table td.actions-col, .leads-table th.actions-col {
    position: sticky;
    right: 0;
    background-color: var(--bg-dark);
    border-left: 1px solid var(--border-color);
    z-index: 10;
    text-align: center;
    box-shadow: -2px 0 5px rgba(0,0,0,0.1);
}

body.light-mode .leads-table td.actions-col,
body.light-mode .leads-table th.actions-col {
    background-color: #fff;
}

.leads-table tr:hover td.actions-col {
    background-color: var(--bg-card-hover);
}

/* Custom Status Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success { background: rgba(16, 185, 129, 0.1); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.2); }
.badge-warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.2); }
.badge-danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.2); }
.badge-info { background: rgba(6, 182, 212, 0.1); color: var(--info); border: 1px solid rgba(6, 182, 212, 0.2); }
.badge-muted { background: rgba(161, 161, 170, 0.1); color: var(--text-muted); border: 1px solid rgba(161, 161, 170, 0.2); }

.action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: var(--transition-smooth);
}
.action-btn:hover {
    color: var(--primary);
    background: rgba(255, 255, 255, 0.05);
}
.action-btn.btn-delete:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.empty-state {
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-icon {
    font-size: 3rem;
    color: var(--text-dark);
    margin-bottom: 15px;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ==========================================================================
   KANBAN VIEW STYLING
   ========================================================================== */
.kanban-board {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 20px;
    min-height: 70vh;
    align-items: flex-start;
}

.kanban-column {
    flex: 1;
    min-width: 280px;
    max-width: 350px;
    padding: 16px;
    height: auto;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.kanban-column-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.kanban-column-header h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 800;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.dot.pending { background-color: var(--text-muted); }
.dot.in-progress { background-color: var(--info); }
.dot.converted { background-color: var(--success); }
.dot.not-interested { background-color: var(--danger); }

.card-count {
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}

.kanban-cards-container {
    flex-grow: 1;
    overflow-y: auto;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 4px;
}

.kanban-card {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px;
    cursor: grab;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 6px rgba(0,0,0,0.15);
}

body.light-mode .kanban-card {
    background: #fff;
}

.kanban-card:hover {
    border-color: var(--border-color-glow);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px var(--shadow-color);
}

.kanban-card-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 6px;
}

.kanban-card-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.kanban-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
    color: var(--text-dark);
}

/* ==========================================================================
   CALENDAR VIEW STYLING
   ========================================================================== */
.calendar-container {
    padding: 24px;
}

/* FullCalendar Custom Theme Overrides */
.fc {
    font-family: var(--font-body);
}

.fc-theme-standard td, .fc-theme-standard th, .fc-theme-standard .fc-scrollgrid {
    border-color: var(--border-color) !important;
}

.fc-daygrid-day-number, .fc-col-header-cell-cushion {
    color: var(--text-main);
    font-family: var(--font-heading);
    font-weight: 700;
}

.fc-button-primary {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #000 !important;
    font-weight: 700 !important;
}

.fc-button-primary:hover {
    background-color: var(--primary-dark) !important;
}

.fc-event {
    border: 1px solid rgba(139, 92, 246, 0.3) !important;
    background-color: rgba(139, 92, 246, 0.1) !important;
    color: var(--primary) !important;
    padding: 2px 4px;
    border-radius: 4px;
}

/* ==========================================================================
   ANALYTICS & ROI STYLING
   ========================================================================== */
.analytics-layout {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 20px;
}

.analytics-card {
    padding: 24px;
}

.analytics-card h3 {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.analytics-card h2 {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 2.5rem;
    color: var(--primary);
}

/* ==========================================================================
   ADMIN PANEL STYLING
   ========================================================================== */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

.admin-card {
    padding: 24px;
}

.admin-card h3 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 800;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    color: var(--primary);
}

/* ==========================================================================
   DRAWER / SLIDE-OUT PANEL
   ========================================================================== */
.drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1000;
    visibility: hidden;
    transition: visibility 0.4s;
}

.drawer.active {
    visibility: visible;
}

.drawer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.drawer.active .drawer-overlay {
    opacity: 1;
}

.drawer-content {
    position: absolute;
    top: 0;
    right: -560px;
    width: 100%;
    max-width: 560px;
    height: 100%;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 0;
    border-left: 1px solid var(--border-color);
}

.drawer.active .drawer-content {
    right: 0;
}

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

.drawer-header h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    transition: var(--transition-smooth);
}
.btn-close:hover {
    color: var(--danger);
}

.drawer-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 24px;
}

.form-section {
    margin-bottom: 24px;
    background: rgba(0,0,0,0.15);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.02);
}

body.light-mode .form-section {
    background: rgba(0, 0, 0, 0.02);
}

.form-section h3 {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--primary);
    margin-bottom: 14px;
    border-bottom: 1px solid rgba(139, 92, 246, 0.1);
    padding-bottom: 4px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 12px;
}

.col-12 { grid-column: span 12; }
.col-6 { grid-column: span 6; }

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

.form-group label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
}

.form-group input, .form-group textarea, .form-group select {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    padding: 10px;
    color: var(--text-main);
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    outline: none;
    transition: var(--transition-smooth);
}

body.light-mode .form-group input,
body.light-mode .form-group textarea,
body.light-mode .form-group select {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.15);
}

.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    border-color: var(--primary);
}

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

/* ==========================================================================
   TIMELINE / ACTIVITY LOGS
   ========================================================================== */
.timeline {
    position: relative;
    padding-left: 20px;
    margin-top: 10px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 5px;
    width: 2px;
    height: 100%;
    background: var(--border-color);
}

.timeline-item {
    position: relative;
    margin-bottom: 15px;
    font-size: 0.8rem;
}

.timeline-dot {
    position: absolute;
    left: -20px;
    top: 5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--bg-dark);
}

.timeline-time {
    color: var(--text-dark);
    font-size: 0.7rem;
    margin-bottom: 2px;
}

.timeline-user {
    font-weight: 700;
    color: var(--primary);
}

/* ==========================================================================
   MODAL / POPUP
   ========================================================================== */
.modal-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1010;
    display: none;
    align-items: center;
    justify-content: center;
}

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

.modal-overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-card {
    position: relative;
    width: 100%;
    max-width: 500px;
    padding: 30px;
    z-index: 1011;
    background: var(--bg-dark);
    border-radius: 12px;
}

body.light-mode .modal-card {
    background: #fff;
}

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

.modal-header h2 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary);
}

/* ==========================================================================
   CAMPAIGN MONTH TABS & OUTREACH
   ========================================================================== */
.campaign-tabs-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
}

.campaign-tabs {
    display: flex;
    padding: 4px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
}

.campaign-tab {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.85rem;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.campaign-tab:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.03);
}

.campaign-tab.active {
    background-color: var(--primary);
    color: #000;
    box-shadow: 0 2px 10px var(--primary-glow);
}

.quick-outreach {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.outreach-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    text-decoration: none;
    transition: var(--transition-smooth);
}

.outreach-btn:hover {
    color: #000;
    transform: scale(1.1);
}

.outreach-btn.whatsapp:hover {
    background-color: #25D366;
    border-color: #25D366;
    color: #fff;
}

.outreach-btn.instagram:hover {
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    border-color: transparent;
    color: #fff;
}

.outreach-btn.call:hover {
    background-color: #3B82F6;
    border-color: #3B82F6;
    color: #fff;
}

.outreach-btn.website:hover {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #000;
}

/* ==========================================================================
   TODAY'S FOLLOW-UP URGENCY HIGHLIGHTING
   ========================================================================== */
.leads-table tr.followup-today td {
    background-color: rgba(245, 158, 11, 0.06);
    border-bottom: 1px solid rgba(245, 158, 11, 0.3);
}

.leads-table tr.followup-today td:nth-child(3) {
    background-color: #17120a !important;
    border-right: 1px solid rgba(245, 158, 11, 0.3) !important;
}

body.light-mode .leads-table tr.followup-today td:nth-child(3) {
    background-color: #FFFBEB !important;
}

.leads-table tr.followup-today:hover td {
    background-color: rgba(245, 158, 11, 0.1);
}

.leads-table tr.followup-today:hover td:nth-child(3) {
    background-color: #20170a !important;
}

body.light-mode .leads-table tr.followup-today:hover td:nth-child(3) {
    background-color: #FEF3C7 !important;
}

/* ==========================================================================
   TOAST NOTIFICATION
   ========================================================================== */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: rgba(16, 185, 129, 0.9);
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    transform: translateY(100px);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
}

.toast.active {
    transform: translateY(0);
    opacity: 1;
}

.toast-icon {
    font-size: 1.2rem;
}

/* ==========================================================================
   RESPONSIVE LAYOUTS
   ========================================================================== */

/* Mobile-only elements are hidden on larger screens */
.mobile-topbar,
.sidebar-backdrop {
    display: none;
}

/* ---------- Tablet: icon-only sidebar ---------- */
@media (max-width: 1024px) and (min-width: 769px) {
    :root {
        --sidebar-width: 80px;
    }

    .sidebar-header,
    .sidebar-nav span,
    #active-user-name {
        display: none;
    }

    .sidebar {
        padding: 15px 10px;
        align-items: center;
    }

    .nav-item {
        padding: 12px;
        justify-content: center;
    }

    .sidebar-footer .btn {
        font-size: 0;           /* keep icons, hide labels */
        padding: 10px;
    }
    .sidebar-footer .btn i {
        font-size: 1rem;
        margin: 0;
    }

    .main-content {
        padding: 24px;
    }
}

/* ---------- Phones ---------- */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
    }

    html, body {
        overflow-x: hidden;
    }

    /* Inputs below 16px make iOS zoom in on focus */
    input, select, textarea {
        font-size: 16px !important;
    }

    /* Top bar with menu + add buttons */
    .mobile-topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        position: sticky;
        top: 0;
        z-index: 90;
        margin: -16px -16px 16px;
        padding: 10px 16px;
        background: var(--bg-dark);
        border-bottom: 1px solid var(--border-color);
    }

    .mobile-brand {
        font-family: var(--font-heading);
        font-weight: 900;
        font-size: 1.3rem;
        letter-spacing: -0.5px;
    }

    .mobile-icon-btn {
        width: 44px;
        height: 44px;
        border-radius: 10px;
        border: 1px solid var(--border-color);
        background: rgba(255, 255, 255, 0.04);
        color: var(--text-main);
        font-size: 1.1rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }

    .mobile-icon-btn-primary {
        background: var(--primary);
        border-color: var(--primary);
        color: #fff;
    }

    /* Sidebar becomes a slide-out menu */
    .sidebar {
        width: 280px;
        max-width: 85vw;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.4);
        z-index: 200;
        overflow-y: auto;
    }

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

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 150;
        background: rgba(0, 0, 0, 0.55);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    body.menu-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    body.menu-open {
        overflow: hidden;
    }

    .nav-item {
        padding: 14px 16px;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        min-width: 0;
        padding: 16px;
    }

    /* Header */
    .content-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 18px;
    }

    .content-header h1 {
        font-size: 1.4rem;
    }

    .header-title-section > div {
        flex-wrap: wrap;
        gap: 10px !important;
    }

    .client-selector-container,
    .client-selector-container select {
        width: 100%;
    }

    .header-title-section > .text-muted,
    .header-actions {
        display: none;  /* the top bar has its own Add Lead button */
    }

    .campaign-tabs-wrapper {
        justify-content: stretch;
    }

    .campaign-tabs {
        width: 100%;
        overflow-x: auto;
    }

    .campaign-tab {
        flex: 1;
        white-space: nowrap;
        min-height: 40px;
    }

    /* Stats: 2 x 2 */
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        margin-bottom: 16px;
    }

    .stats-card {
        padding: 14px;
        gap: 10px;
    }

    .stats-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
        flex-shrink: 0;
    }

    .stats-info h3 {
        font-size: 1.3rem;
    }

    .stats-info p {
        font-size: 0.72rem;
    }

    /* Quick views: one swipeable row */
    .quick-views-container {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        margin: 0 -16px 12px !important;
        padding: 0 16px 4px;
        scrollbar-width: none;
    }
    .quick-views-container::-webkit-scrollbar {
        display: none;
    }
    .quick-view-btn {
        white-space: nowrap;
        flex-shrink: 0;
        min-height: 40px;
    }

    /* Search & filters */
    .control-panel {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        width: 100%;
    }

    .filter-group {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .filter-group .filter-select,
    .filter-group .btn {
        width: 100%;
        min-height: 44px;
    }

    /* Bulk actions */
    .bulk-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .bulk-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .bulk-actions > * {
        width: 100%;
        min-height: 44px;
    }

    /* Other tables (leaderboard, users, audit) scroll sideways */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* ---------- Main leads table becomes cards ---------- */
    .table-container:has(#leads-table) {
        overflow: visible;
        background: transparent;
        border: none;
        box-shadow: none;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        padding: 0;
    }

    #leads-table,
    #leads-table tbody {
        display: block;
    }

    #leads-table thead {
        display: none;
    }

    #leads-table tr {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        column-gap: 10px;
        padding: 14px;
        margin-bottom: 12px;
        border: 1px solid var(--border-color);
        border-radius: 12px;
        background: var(--bg-card);
    }

    #leads-table tr.followup-today {
        border-color: rgba(245, 158, 11, 0.5);
    }

    #leads-table td,
    #leads-table td:nth-child(3) {
        display: block;
        grid-column: 1 / -1;
        order: 10;
        position: static;
        max-width: none;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
        padding: 6px 0;
        font-size: 0.88rem;
    }

    #leads-table td[data-label]:not(:nth-child(1)):not(:nth-child(3)):not(.actions-col)::before {
        content: attr(data-label);
        display: block;
        font-size: 0.68rem;
        font-weight: 700;
        letter-spacing: 0.5px;
        text-transform: uppercase;
        color: var(--text-dark);
        margin-bottom: 2px;
    }

    /* Card header row: checkbox | business name | actions */
    #leads-table td:nth-child(1) {
        grid-column: 1;
        grid-row: 1;
        order: 0;
        padding-top: 2px;
    }

    #leads-table td:nth-child(3) {
        grid-column: 2;
        grid-row: 1;
        order: 0;
        font-size: 1rem;
        padding-top: 0;
        padding-bottom: 8px;
    }

    #leads-table td.actions-col {
        grid-column: 3;
        grid-row: 1;
        order: 0;
        display: flex;
        gap: 6px;
        align-items: flex-start;
        padding: 0;
        position: static;
    }

    /* Most useful fields first */
    #leads-table td:nth-child(6)  { order: 1; }   /* Contact   */
    #leads-table td:nth-child(16) { order: 2; }   /* Status    */
    #leads-table td:nth-child(14) { order: 3; }   /* Follow up */
    #leads-table td:nth-child(4)  { order: 4; }   /* About     */

    #leads-table td:nth-child(2),     /* No. */
    #leads-table td.cell-empty {
        display: none;
    }

    #leads-table td .text-muted {
        max-width: none !important;
    }

    .action-btn {
        min-width: 40px;
        min-height: 40px;
    }

    .outreach-btn {
        min-width: 38px;
        min-height: 38px;
    }

    .lead-row-checkbox {
        width: 20px;
        height: 20px;
    }

    /* Kanban */
    .kanban-board {
        flex-direction: column;
        align-items: stretch;
    }

    .kanban-column {
        max-width: 100%;
        min-width: 0;
    }

    /* Calendar */
    .fc .fc-toolbar {
        flex-direction: column;
        gap: 8px;
    }

    .fc .fc-toolbar-title {
        font-size: 1.1rem;
    }

    /* Analytics: one column (cards use inline grid-column spans) */
    .analytics-layout > * {
        grid-column: 1 / -1 !important;
    }

    .analytics-card {
        padding: 16px;
    }

    .analytics-card h2 {
        font-size: 1.8rem;
    }

    /* Ad-spend form is an inline flex row on desktop: stack it */
    #ad-spend-form {
        flex-direction: column;
        align-items: stretch !important;
    }

    #ad-spend-form .form-group,
    #ad-spend-form input,
    #ad-spend-form .btn {
        width: 100%;
        min-height: 44px;
    }

    /* Admin */
    .admin-grid {
        grid-template-columns: 1fr;
    }

    /* Edit drawer: full screen, single column form */
    .drawer-content {
        max-width: 100%;
        right: -100%;
        border-left: none;
    }

    .drawer-header,
    .drawer-body {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    .form-grid .col-6 {
        grid-column: span 12;
    }

    .drawer-footer {
        padding: 12px 16px;
    }

    .drawer-footer .btn {
        flex: 1;
        min-height: 44px;
    }

    /* Modals */
    .modal-card {
        width: calc(100% - 32px);
        padding: 20px;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Toast spans the bottom edge */
    .toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
        justify-content: center;
    }
}

.inline-cell-input {
    width: 100%;
    background: rgba(139, 92, 246, 0.1) !important;
    border: 1px solid var(--primary) !important;
    color: var(--text-main) !important;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    outline: none;
    box-sizing: border-box;
}

.logo-wrapper svg {
    overflow: visible;
}
.logo-wrapper .chevron-inner, .logo-wrapper .chevron-outer {
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), filter 0.3s ease;
    transform-box: fill-box;
    transform-origin: center;
}
.logo-wrapper:hover .chevron-inner {
    transform: translate(4px, -4px);
    filter: drop-shadow(0 0 6px rgba(0, 82, 255, 0.6));
}
.logo-wrapper:hover .chevron-outer {
    transform: translate(8px, -8px);
    filter: drop-shadow(0 0 8px rgba(0, 163, 255, 0.8));
}

/* Quick Views Tabs */
.quick-view-btn {
    background: rgba(19, 21, 34, 0.5) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-muted) !important;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-family: var(--font-heading);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.quick-view-btn:hover {
    background: rgba(139, 92, 246, 0.08) !important;
    border-color: rgba(139, 92, 246, 0.3) !important;
    color: var(--text-main) !important;
}
.quick-view-btn.active {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.35);
}

/* Pipedrive Idle Warning Rows */
tr.lead-row-idle {
    background: rgba(245, 158, 11, 0.02) !important;
}
tr.lead-row-idle:hover {
    background: rgba(245, 158, 11, 0.05) !important;
}

/* Monday.com Subtasks */
.subtask-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 8px;
    transition: var(--transition-smooth);
}
.subtask-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(139, 92, 246, 0.15);
}
.subtask-text {
    flex-grow: 1;
    margin-left: 10px;
    font-size: 0.85rem;
    color: var(--text-main);
    transition: var(--transition-smooth);
}
.subtask-item.done .subtask-text {
    text-decoration: line-through;
    color: var(--text-dark);
}
.subtask-delete-btn {
    background: transparent;
    border: none;
    color: var(--text-dark);
    cursor: pointer;
    transition: var(--transition-smooth);
    font-size: 0.9rem;
    padding: 2px 6px;
}
.subtask-delete-btn:hover {
    color: var(--danger);
}
