/* ============================================================
   XCOMIC EMAIL MARKETER - ELEGANT PREMIUM DESIGN SYSTEM
   Minimalist · Clean Typography · Sophisticated
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Inter:wght@400;500;600&display=swap');

:root {
    /* Brand Colors - Sophisticated and Restrained */
    --primary:       #0f172a; /* Deep Slate */
    --primary-light: #334155;
    --accent:        #4f46e5; /* Indigo for primary actions */
    --accent-hover:  #4338ca;
    --p:             #4f46e5;
    --p-light:       rgba(79, 70, 229, 0.1);
    
    /* Semantic */
    --success:       #059669;
    --success-bg:    #ecfdf5;
    --warning:       #d97706;
    --warning-bg:    #fffbeb;
    --danger:        #dc2626;
    --danger-bg:     #fef2f2;

    /* Surfaces - Clean Light Mode */
    --bg:            #f8fafc;
    --surface-0:     #ffffff;
    --surface-1:     #f1f5f9;
    --surface-hover: #f8fafc;

    /* Borders */
    --border:        #e2e8f0;
    --border-hover:  #cbd5e1;

    /* Text */
    --text:          #0f172a;
    --text-muted:    #64748b;
    --text-dim:      #94a3b8;

    /* Shadows - Soft and Refined */
    --shadow-sm:     0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md:     0 4px 6px -1px rgba(15, 23, 42, 0.05), 0 2px 4px -1px rgba(15, 23, 42, 0.03);
    --shadow-lg:     0 10px 15px -3px rgba(15, 23, 42, 0.05), 0 4px 6px -2px rgba(15, 23, 42, 0.025);
    --shadow-float:  0 20px 25px -5px rgba(15, 23, 42, 0.05), 0 10px 10px -5px rgba(15, 23, 42, 0.02);

    /* Transitions */
    --ease:          cubic-bezier(0.4, 0, 0.2, 1);
    --duration:      0.25s;
    --radius-sm:     8px;
    --radius-md:     12px;
    --radius-lg:     16px;
    --radius-xl:     24px;
}

/* Dark Mode */
[data-theme="dark"] {
    --bg:            #0f172a;
    --surface-0:     #1e293b;
    --surface-1:     #273549;
    --surface-hover: #334155;
    --border:        #334155;
    --border-hover:  #475569;
    --text:          #f1f5f9;
    --text-muted:    #94a3b8;
    --text-dim:      #64748b;
    --shadow-sm:     0 1px 2px rgba(0,0,0,0.3);
    --shadow-md:     0 4px 6px -1px rgba(0,0,0,0.3);
    --shadow-lg:     0 10px 15px -3px rgba(0,0,0,0.3);
    --shadow-float:  0 20px 25px -5px rgba(0,0,0,0.4);
}

/* ============================================================
   BASE RESET
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; font-size: 16px; }

body {
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: block;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    overflow-y: auto;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

::selection { background: rgba(79, 70, 229, 0.15); color: var(--accent); }

/* ============================================================
   APP LAYOUT
   ============================================================ */
#app-page {
    display: none;
    width: 100%;
    min-height: 100vh;
    background: var(--bg);
    position: relative;
}
#app-page.on { display: flex; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: 260px;
    min-height: 100vh;
    padding: 32px 20px;
    display: flex;
    flex-direction: column;
    background: var(--surface-0);
    border-right: 1px solid var(--border);
    position: sticky; top: 0; height: 100vh;
    z-index: 100;
    flex-shrink: 0;
    overflow-y: auto;
}

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 12px;
    margin-bottom: 48px;
}
.logo i {
    width: 32px; height: 32px;
    background: var(--text);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; color: #fff;
}
.logo h2 {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
}

nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-item {
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-radius: var(--radius-md);
    transition: all var(--duration) var(--ease);
    cursor: pointer;
}
.nav-item i { font-size: 16px; opacity: 0.8; transition: transform var(--duration) var(--ease); }
.nav-item:hover {
    color: var(--text);
    background: var(--surface-1);
}
.nav-item:hover i { transform: translateX(2px); opacity: 1; }
.nav-item.active {
    color: var(--accent);
    background: rgba(79, 70, 229, 0.08);
}
.nav-item.active i { opacity: 1; }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    flex: 1;
    padding: 48px 56px;
    overflow-y: auto;
    position: relative; z-index: 1;
    min-height: 100vh;
    scrollbar-width: none; /* Firefox - hide scrollbar */
}
.main-content::-webkit-scrollbar {
    display: none; /* Chrome/Edge - hide scrollbar */
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
    margin-bottom: 40px;
}
.page-title {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text);
    margin-bottom: 8px;
}
.page-subtitle { font-size: 15px; color: var(--text-muted); font-weight: 500; }

/* ============================================================
   VIEWS
   ============================================================ */
.view { display: none; animation: fadeIn 0.4s var(--ease); }
.view.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.stat-card {
    padding: 28px;
    border-radius: var(--radius-lg);
    background: var(--surface-0);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: flex-start;
    gap: 20px;
    transition: all var(--duration) var(--ease);
}
.stat-card:hover { 
    transform: translateY(-4px); 
    box-shadow: var(--shadow-lg); 
    border-color: var(--border-hover);
}

.stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-md);
    background: var(--surface-1);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; color: var(--text);
    flex-shrink: 0;
}
.stat-content {
    display: flex;
    flex-direction: column;
}
.stat-label { 
    font-size: 13px; 
    color: var(--text-muted); 
    font-weight: 600; 
    text-transform: uppercase; 
    letter-spacing: 0.05em; 
    margin-bottom: 8px;
}
.stat-value {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text);
    line-height: 1;
}

/* ============================================================
   TABLES
   ============================================================ */
table { width: 100%; border-collapse: separate; border-spacing: 0; }
thead tr th {
    padding: 16px 24px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: left;
    border-bottom: 1px solid var(--border);
    background: var(--surface-0);
}
thead tr th:first-child { border-top-left-radius: var(--radius-lg); }
thead tr th:last-child { border-top-right-radius: var(--radius-lg); }
tbody tr td {
    padding: 20px 24px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    background: var(--surface-0);
    transition: background var(--duration) var(--ease);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:last-child td:first-child { border-bottom-left-radius: var(--radius-lg); }
tbody tr:last-child td:last-child { border-bottom-right-radius: var(--radius-lg); }
tbody tr:hover td { background: var(--surface-1); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    padding: 12px 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    background: var(--surface-0);
    color: var(--text);
    transition: all var(--duration) var(--ease);
    box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--surface-1); border-color: var(--border-hover); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2), 0 2px 4px -1px rgba(79, 70, 229, 0.1);
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.3); }
.btn.primary:active { transform: translateY(0); }

.btn.danger {
    background: var(--surface-0);
    border-color: #fca5a5;
    color: var(--danger);
}
.btn.danger:hover { background: var(--danger-bg); border-color: var(--danger); }

/* ============================================================
   FORMS & INPUTS
   ============================================================ */
.form-group { margin-bottom: 24px; }
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--surface-0);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    outline: none;
    transition: all var(--duration) var(--ease);
    box-shadow: var(--shadow-sm);
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-dim); }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}
.form-group select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; background-size: 16px; padding-right: 40px; }
.form-group textarea { resize: vertical; line-height: 1.6; }

/* ============================================================
   CARDS & CONTAINERS
   ============================================================ */
.glass {
    background: var(--surface-0);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    padding: 32px;
}

/* ============================================================
   STATUS BADGES
   ============================================================ */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
}
.status-badge.sent, .status-badge.completed { background: var(--success-bg); color: var(--success); }
.status-badge.pending, .status-badge.draft { background: var(--warning-bg); color: var(--warning); }
.status-badge.failed, .status-badge.error { background: var(--danger-bg); color: var(--danger); }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 24px;
    display: none;
}
.alert.success { background: var(--success-bg); color: var(--success); border: 1px solid #a7f3d0; display: block; }
.alert.error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; display: block; }

/* ============================================================
   TABS
   ============================================================ */
.tabs-bar {
    display: inline-flex;
    background: var(--surface-1);
    border-radius: var(--radius-lg);
    padding: 6px;
    margin-bottom: 32px;
    gap: 4px;
}
.tab-btn {
    padding: 10px 24px;
    border: none;
    background: transparent;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--duration) var(--ease);
    display: flex; align-items: center; gap: 8px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
    background: var(--surface-0);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

/* ============================================================
   EMAIL BUILDER (Refined)
   ============================================================ */
.builder-layout {
    display: flex;
    gap: 32px;
    height: calc(100vh - 280px);
    min-height: 600px;
}

.builder-sidebar {
    width: 320px;
    flex-shrink: 0;
    background: var(--surface-0);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
}

.builder-canvas-wrapper {
    flex: 1;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow-y: auto;
    padding: 48px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

#builder-canvas {
    width: 100%;
    max-width: 600px;
    min-height: 500px;
    background: #fff;
    border-radius: 0;
    box-shadow: var(--shadow-float);
    position: relative;
    overflow: hidden;
    margin: 0 auto;
}

.canvas-placeholder {
    text-align: center;
    padding: 100px 20px;
    color: var(--text-dim);
    font-size: 15px;
    font-weight: 500;
    pointer-events: none;
}

.email-block {
    position: relative;
    border: 2px solid transparent;
    cursor: default;
    transition: border-color 0.2s;
}
.email-block:hover { border: 2px dashed rgba(79, 70, 229, 0.4); }
.email-block.selected { border: 2px solid var(--accent); }

.block-actions {
    position: absolute;
    top: -36px; right: -2px;
    background: var(--accent);
    color: #fff;
    display: none;
    align-items: center;
    z-index: 10;
    border-radius: 8px 8px 0 0;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}
.email-block:hover .block-actions,
.email-block.selected .block-actions { display: flex; }

.action-btn {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.15s;
}
.action-btn:hover { background: var(--accent-hover); }
.action-btn.delete:hover { background: var(--danger); }

.drop-indicator {
    height: 3px;
    background: var(--accent);
    width: 100%;
    z-index: 20;
    pointer-events: none;
    display: none;
    margin: 2px 0;
}

.draggable-block {
    padding: 14px 16px;
    background: var(--surface-0);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    cursor: grab;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
    transition: all var(--duration) var(--ease);
    box-shadow: var(--shadow-sm);
}
.draggable-block:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.draggable-block:active { cursor: grabbing; transform: scale(0.98); }

.property-editor-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

/* ============================================================
   TOAST NOTIFICATIONS (V2)
   ============================================================ */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast-item {
    min-width: 280px;
    max-width: 420px;
    background: #fff;
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1);
    pointer-events: auto;
    font-family: 'Plus Jakarta Sans', sans-serif;
    animation: toastSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    position: relative;
    overflow: hidden;
}

.toast-item.hide {
    animation: toastSlideOut 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateY(40px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastSlideOut {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.95); }
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toast-icon {
    font-size: 18px;
}

.toast-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    flex: 1;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    opacity: 0.7;
    transition: 0.2s;
}

.toast-close:hover {
    opacity: 1;
    color: var(--text);
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--p);
    width: 100%;
    animation: toastProgress linear forwards;
}

@keyframes toastProgress {
    from { width: 100%; }
    to { width: 0%; }
}

/* ============================================================
   ANALYTICS DASHBOARD
   ============================================================ */
.clean-tabs-bar {
    display: flex; gap: 32px; border-bottom: 1px solid var(--border); margin-bottom: 24px;
}
.clean-tab {
    padding: 16px 0; font-size: 15px; font-weight: 600; color: var(--text-muted);
    cursor: pointer; position: relative; transition: color var(--duration);
}
.clean-tab:hover { color: var(--text); }
.clean-tab.active { color: var(--accent); }
.clean-tab.active::after {
    content: ''; position: absolute; bottom: -1px; left: 0; width: 100%;
    height: 3px; background: var(--accent); border-radius: 3px 3px 0 0;
}
.metric-card {
    background: var(--surface-0); border: 1px solid var(--border);
    border-radius: var(--radius-md); padding: 32px 24px; display: flex;
    flex-direction: column; align-items: center; justify-content: center;
    box-shadow: var(--shadow-sm); flex: 1; text-align: center;
}
.metric-card-title {
    font-size: 13px; font-weight: 600; color: var(--text-muted);
    display: flex; align-items: center; gap: 6px; margin-bottom: 20px;
}
.metric-card-title i { font-size: 12px; color: var(--text-dim); }
.metric-card-value {
    font-size: 32px; font-weight: 700; color: var(--text); display: flex; align-items: center; justify-content: center; gap: 12px; line-height: 1;
}
.metric-card-sub { font-size: 20px; color: var(--text-muted); font-weight: 500; border-left: 1px solid var(--border); padding-left: 12px; }
.status-pill {
    background: #333; color: #fff; padding: 6px 14px; border-radius: 99px;
    font-size: 12px; font-weight: 700; letter-spacing: 0.05em;
}
.progress-bar-container {
    height: 4px; background: var(--border); border-radius: 4px; width: 100px;
    overflow: hidden; display: inline-block; vertical-align: middle;
}
.progress-bar-fill { height: 100%; background: var(--text-muted); width: 0%; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
/* PC Sidebar is 100% Full Width (240px) on Desktop screens (>768px) */
.sidebar {
    width: 240px;
    min-width: 240px;
    flex-shrink: 0;
}
.sidebar .logo h2,
.nav-item span {
    display: inline-block !important;
}

@media (max-width: 768px) {

    .sidebar {
        position: fixed; left: -100%; top: 0; bottom: 0; z-index: 1000;
        width: 260px !important; transition: left 0.3s ease;
        box-shadow: 4px 0 24px rgba(0,0,0,0.15);
    }
    .sidebar.open { left: 0; }
    .sidebar .logo h2, .nav-item span { display: block !important; }
    .sidebar-overlay {
        display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4);
        z-index: 999; backdrop-filter: blur(2px);
    }
    .sidebar-overlay.show { display: block; }
    .mobile-menu-btn {
        display: flex !important; position: fixed; top: 16px; left: 16px;
        z-index: 998; width: 44px; height: 44px;
        background: var(--surface-0); border: 1px solid var(--border);
        border-radius: 10px; align-items: center; justify-content: center;
        cursor: pointer; box-shadow: var(--shadow-md); font-size: 18px; color: var(--text);
    }
    .main-content { padding: 16px; padding-top: 72px; }
    .builder-layout { flex-direction: column; height: auto; }
    .builder-sidebar { width: 100%; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .page-header { flex-direction: column; gap: 12px; align-items: flex-start !important; }
    table { font-size: 13px; }
    .glass { padding: 16px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .main-content { padding: 12px; padding-top: 68px; }
}

/* ============================================================
   ANIMATIONS & UX ENHANCEMENTS
   ============================================================ */

/* Shimmer loading skeleton */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s ease infinite;
    border-radius: 6px;
    display: inline-block;
}

[data-theme="dark"] .skeleton {
    background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
    background-size: 200% 100%;
}

/* ============================================================
   TOOLTIPS
   ============================================================ */
[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: #0f172a;
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 1000;
}

[data-theme="dark"] [data-tooltip]::after {
    background: #e2e8f0;
    color: #0f172a;
}

[data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    border: 6px solid transparent;
    border-top-color: #0f172a;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1000;
}

[data-theme="dark"] [data-tooltip]::before {
    border-top-color: #e2e8f0;
}

[data-tooltip]:hover::after,
[data-tooltip]:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Pulse animation for notification badge */
@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.85; }
}

/* Page view entrance animation */
.view { animation: fadeSlideIn 0.25s ease; }
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Input focus glow */
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

/* Button loading state */
.btn.loading { pointer-events: none; opacity: 0.7; }
.btn.loading::after {
    content: '';
    display: inline-block;
    width: 12px; height: 12px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }



/* Empty state */
.empty-state {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; padding: 64px 24px; gap: 16px; text-align: center;
}
.empty-state-icon {
    width: 72px; height: 72px;
    background: var(--surface-1); border-radius: 20px;
    display: flex; align-items: center; justify-content: center;
    font-size: 32px;
}
.empty-state h3 { font-size: 16px; font-weight: 700; color: var(--text); margin: 0; }
.empty-state p { font-size: 13px; color: var(--text-muted); margin: 0; max-width: 280px; }

/* Admin badge */
.nav-item { position: relative; }
.admin-badge {
    background: #ef4444; color: #fff; border-radius: 50%;
    width: 18px; height: 18px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 700; margin-left: auto;
    animation: pulse 1.5s infinite;
}

/* Smooth nav transitions */
.nav-item { transition: background 0.15s ease, color 0.15s ease; }
.nav-item:hover { background: var(--surface-1); }

/* Table row hover */
tbody tr { transition: background 0.15s ease; }
tbody tr:hover { background: var(--surface-1) !important; }

/* Approve button pulse on admin panel */
button[onclick*="approveUser"] {
    animation: approvalPulse 2s infinite;
}
@keyframes approvalPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(5, 150, 105, 0); }
}

/* Mobile menu button & app header hidden by default */
.mobile-menu-btn, .mobile-app-header { display: none; }

/* Command Palette */
.cmd-item { display:flex; align-items:center; gap:12px; padding:12px 24px; cursor:pointer; text-decoration:none; color:var(--text); transition:background 0.1s; }
.cmd-item:hover, .cmd-item.active { background:var(--surface-1); }
.cmd-item .cmd-icon { width:32px; height:32px; border-radius:8px; display:flex; align-items:center; justify-content:center; font-size:14px; }
.cmd-item .cmd-title { font-weight:600; font-size:14px; }
.cmd-item .cmd-desc { font-size:12px; color:var(--text-muted); }

/* ============================================================
   RESPONSIVE & MOBILE DESIGN SYSTEM (Strictly <= 768px)
   ============================================================ */
@media (max-width: 768px) {

    #app-page.on {
        flex-direction: column;
    }
    
    #app-page .mobile-menu-btn, #app-page.on .mobile-menu-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 14px;
        left: 14px;
        z-index: 100001;
        width: 42px;
        height: 42px;
        border-radius: 12px;
        background: var(--surface-0);
        border: 1px solid var(--border);
        color: var(--text);
        font-size: 18px;
        cursor: pointer;
        box-shadow: var(--shadow-md);
        transition: all 0.2s ease;
    }

    .mobile-menu-btn:hover {
        background: var(--surface-1);
        color: var(--accent);
    }

    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: -290px !important;
        width: 270px !important;
        height: 100vh !important;
        z-index: 100000 !important;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        box-shadow: 10px 0 30px rgba(0,0,0,0.35) !important;
        border-right: 1px solid var(--border) !important;
    }

    .sidebar.open {
        left: 0 !important;
    }

    .sidebar-overlay {
        position: fixed;
        top: 0; left: 0;
        width: 100vw; height: 100vh;
        background: rgba(15, 23, 42, 0.65);
        backdrop-filter: blur(6px);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
        z-index: 99999;
    }

    .sidebar-overlay.show {
        opacity: 1;
        pointer-events: auto;
    }

    .main-content {
        padding: 68px 16px 32px 16px !important;
        width: 100% !important;
        min-height: calc(100vh - 68px);
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
        margin-bottom: 24px !important;
    }

    .page-header div[style*="display: flex"], 
    .page-header div[style*="display:flex"] {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px !important;
    }

    .card, .table-container, div[style*="overflow-x"] {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    table {
        display: block;
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        white-space: nowrap;
    }

    .stats-grid, div[style*="grid-template-columns"] {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
        gap: 14px !important;
    }
}

/* FAQ Details Layout Rules */
details {
    display: block !important;
    position: relative !important;
    margin-bottom: 16px !important;
    height: auto !important;
}
details:not([open]) > div {
    display: none !important;
    height: 0 !important;
    overflow: hidden !important;
}
details[open] > div {
    display: block !important;
}
details summary {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    cursor: pointer !important;
}

/* 1. Global Viewport Overflow Guard */
html, body, #landing-page, #app-page {
    max-width: 100vw !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
}

/* Hide background glowing orbs on mobile to prevent huge horizontal overflow */
@media (max-width: 992px) {
    .landing-orb, .orb-1, .orb-2, .orb-3 {
        display: none !important;
    }
}

/* Desktop Topbar Layout */
.landing-nav {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 16px 64px !important;
    position: fixed !important;
    top: 0 !important; left: 0 !important; right: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    background: rgba(6, 13, 31, 0.85) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    z-index: 1000 !important;
}

.landing-logo {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
}

.landing-logo img {
    width: 36px !important;
    height: 36px !important;
    border-radius: 8px !important;
}

.landing-logo span {
    font-size: 20px !important;
    font-weight: 800 !important;
    color: #fff !important;
    letter-spacing: -0.02em !important;
}

.landing-nav-links {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 32px !important;
}

.landing-nav-links a {
    color: #cbd5e1 !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    transition: color 0.2s !important;
}

.landing-nav-links a:hover {
    color: #fff !important;
}

.landing-nav-actions {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 12px !important;
}

.landing-nav-toggle {
    display: none !important;
}

/* 2. Responsive Landing Hero, Bento Grid & Typography */
@media (max-width: 900px) {
    .landing-nav {
        padding: 10px 14px !important;
        background: #060d1f !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        border-bottom: 1px solid rgba(255,255,255,0.12) !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .landing-nav-links {
        display: none !important;
    }
    .landing-nav-actions {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 6px !important;
    }
    .landing-nav-actions .landing-login-btn,
    .landing-nav-actions .landing-signup-btn {
        padding: 7px 10px !important;
        font-size: 12px !important;
        font-weight: 700 !important;
        white-space: nowrap !important;
        border-radius: 8px !important;
    }
    .landing-nav-toggle {
        display: flex !important;
        width: 34px !important;
        height: 34px !important;
        font-size: 15px !important;
        border-radius: 8px !important;
        align-items: center !important;
        justify-content: center !important;
        margin: 0 !important;
        flex-shrink: 0 !important;
    }
    .landing-hero {
        padding: 95px 16px 40px !important;
    }
    .landing-hero h1 {
        font-size: 34px !important;
        line-height: 1.25 !important;
    }
    .landing-hero p {
        font-size: 15px !important;
        line-height: 1.6 !important;
        padding: 0 8px !important;
    }
    .hero-ctas, .cta-btns {
        flex-direction: column !important;
        width: 100% !important;
        gap: 12px !important;
    }
    .hero-cta-primary, .cta-primary, .cta-secondary, .landing-login-btn {
        width: 100% !important;
        padding: 14px 20px !important;
        font-size: 15px !important;
        text-align: center !important;
        box-sizing: border-box !important;
    }
    .stats-strip {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        padding: 20px 12px !important;
        gap: 16px !important;
    }
    .stat-item {
        padding: 12px 8px !important;
        border-right: none !important;
        border-bottom: 1px solid rgba(255,255,255,0.06) !important;
        width: 100% !important;
    }
    .stat-num {
        font-size: 28px !important;
    }
    .stat-label {
        font-size: 11px !important;
    }
    .problem-section, #features, .landing-pricing, #affiliate, .landing-cta-final {
        padding: 50px 16px !important;
    }
    .problem-title, .section-title, .pricing-title, .cta-final-title {
        font-size: 26px !important;
        line-height: 1.3 !important;
        margin-bottom: 24px !important;
    }
    .problem-grid, .features-grid, .pricing-grid, .bento-grid, .testimonials-grid {
        grid-template-columns: 1fr !important;
        max-width: 100% !important;
        gap: 16px !important;
    }
    div[style*="width: 600px"], div[style*="width:600px"] {
        width: 100% !important;
        max-width: 100% !important;
    }
    .bento-big, .bento-med, .bento-sm {
        grid-column: span 1 !important;
        grid-row: auto !important;
        padding: 20px 16px !important;
    }
    .feature-highlight {
        grid-template-columns: 1fr !important;
        gap: 32px !important;
        margin-top: 40px !important;
        padding: 0 !important;
    }
    .fh-title {
        font-size: 22px !important;
    }
    .hero-dashboard {
        margin: 24px 0 0 !important;
        border-radius: 12px !important;
        max-width: 100% !important;
        overflow: hidden !important;
    }
    .hd-sidebar {
        display: none !important;
    }
    .hd-main {
        padding: 12px 8px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .hd-stat-row {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 6px !important;
    }
    .hd-stat {
        padding: 8px 10px !important;
        min-width: 0 !important;
    }
    .hd-sval {
        font-size: 16px !important;
    }
    .hd-slabel {
        font-size: 10px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    .hd-inbox-row {
        padding: 8px !important;
        gap: 6px !important;
        flex-wrap: wrap !important;
        box-sizing: border-box !important;
    }
    .hd-email-line {
        font-size: 11px !important;
        min-width: 0 !important;
        flex: 1 1 100% !important;
        margin-bottom: 2px !important;
    }
    .hd-ai-btn {
        font-size: 10px !important;
        padding: 3px 8px !important;
    }
}

@media (max-width: 480px) {
    .landing-hero h1 {
        font-size: 26px !important;
    }
    .landing-logo span {
        font-size: 16px !important;
    }
    .landing-login-btn, .landing-signup-btn {
        padding: 8px 12px !important;
        font-size: 13px !important;
    }
    .pricing-card {
        padding: 24px 16px !important;
    }
    .p-price {
        font-size: 36px !important;
    }
}

/* 3. Dashboard Mobile Responsiveness & Floating AI Button */
@media (max-width: 992px) {
    .main-content {
        padding: 68px 12px 32px 12px !important;
    }
    #ai-chat-panel {
        width: calc(100vw - 20px) !important;
        max-width: 400px !important;
        right: 10px !important;
        bottom: 80px !important;
        height: calc(100vh - 120px) !important;
        max-height: 520px !important;
        border-radius: 16px !important;
        z-index: 100005 !important;
    }
    #ai-chat-btn {
        bottom: 16px !important;
        right: 16px !important;
        width: 52px !important;
        height: 52px !important;
        z-index: 100004 !important;
    }
}

/* ============================================================
   LANDING PAGE MOBILE SLIDE-OUT DRAWER MENU
   ============================================================ */
.landing-nav-toggle {
    display: none;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    font-size: 18px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

@media (max-width: 900px) {
    .landing-nav-toggle {
        display: flex !important;
    }
}

.landing-mobile-drawer {
    position: fixed;
    top: 0;
    right: -310px;
    width: 290px;
    max-width: 85vw;
    height: 100vh;
    background: #091026;
    border-left: 1px solid rgba(255,255,255,0.1);
    box-shadow: -10px 0 30px rgba(0,0,0,0.5);
    z-index: 100002;
    display: flex;
    flex-direction: column;
    padding: 24px 20px;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
}

.landing-mobile-drawer.open {
    right: 0 !important;
}

.landing-mobile-backdrop {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 100001;
}

.landing-mobile-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

.lmd-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 24px;
}

.lmd-close-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: #cbd5e1;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.lmd-close-btn:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

.lmd-links {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

.lmd-links a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 12px;
    color: #f1f5f9;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}

.lmd-links a:hover {
    background: rgba(99,102,241,0.15);
    border-color: rgba(99,102,241,0.3);
    color: #fff;
    transform: translateX(4px);
}

.lmd-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

/* FAQ Accordion Chevron Animation */
details[open] summary .faq-icon {
    transform: rotate(180deg) !important;
}
details summary::-webkit-details-marker,
details summary::marker {
    display: none !important;
    content: "" !important;
}

/* ============================================================
   MOBILE DASHBOARD & VISUAL BUILDER UX OPTIMIZATIONS
   (Strictly scoped to max-width: 768px - NO CHANGES on PC)
   ============================================================ */
@media (max-width: 768px) {

    /* 1. Mobile Visual Builder & Campaign Creation */
    #campaigns-builder,
    #cold-mail-builder,
    .builder-container {
        padding: 12px 8px !important;
    }
    
    .builder-layout,
    .visual-builder-layout {
        flex-direction: column !important;
        gap: 16px !important;
    }
    
    .builder-sidebar,
    .builder-sidebar-left,
    .builder-sidebar-right {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 280px !important;
        overflow-y: auto !important;
        border-right: none !important;
        border-bottom: 1px solid rgba(255,255,255,0.1) !important;
        padding: 12px !important;
        box-sizing: border-box !important;
    }
    
    .builder-canvas-wrapper,
    .builder-canvas {
        width: 100% !important;
        min-height: 320px !important;
        padding: 12px 8px !important;
        overflow-x: auto !important;
        box-sizing: border-box !important;
    }

    .vb-tab-bar,
    .builder-tabs {
        display: flex !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        white-space: nowrap !important;
        padding-bottom: 6px !important;
        gap: 8px !important;
    }

    .vb-tab,
    .builder-tab-btn {
        flex-shrink: 0 !important;
        padding: 8px 14px !important;
        font-size: 13px !important;
    }

    /* Prevent mobile browser zoom on input focus */
    .builder-container input,
    .builder-container select,
    .builder-container textarea,
    .view input,
    .view select,
    .view textarea,
    .modal-content input,
    .modal-content select,
    .modal-content textarea {
        font-size: 16px !important;
    }

    /* 2. Mobile Dashboard Overview Cards & Grid */
    .overview-grid,
    .stats-cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
        gap: 10px !important;
    }

    .stat-card {
        padding: 14px 12px !important;
    }

    .stat-card-value {
        font-size: 22px !important;
    }

    /* 3. Mobile Tables (Leads, Campaigns, Accounts) */
    .table-responsive,
    .data-table-wrapper {
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        border-radius: 12px !important;
    }

    .data-table th,
    .data-table td {
        padding: 10px 12px !important;
        font-size: 13px !important;
        white-space: nowrap !important;
    }

    /* Touch Friendly Action Buttons */
    .action-btn,
    .table-action-btn {
        min-width: 36px !important;
        min-height: 36px !important;
        padding: 6px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 8px !important;
    }

    /* 4. Mobile Modals & Slide-overs */
    .modal-content,
    .modal-card {
        width: 94vw !important;
        max-width: 480px !important;
        max-height: 88vh !important;
        overflow-y: auto !important;
        padding: 20px 16px !important;
        margin: 12px auto !important;
        border-radius: 16px !important;
    }

    /* 5. Mobile Sticky Bottom Action Bar for Campaign Steps */
    .builder-footer-actions,
    .step-navigation-bar {
        flex-direction: column !important;
        gap: 10px !important;
        width: 100% !important;
    }

    .builder-footer-actions button,
    .step-navigation-bar button {
        width: 100% !important;
        padding: 12px 16px !important;
        font-size: 14px !important;
        font-weight: 700 !important;
    }

    /* 6. Mobile Dashboard Off-Canvas Sidebar & Header */
    #app-page .main-content {
        padding: 68px 12px 36px 12px !important;
        margin-left: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    #app-page .topbar,
    #app-page .header {
        left: 0 !important;
        width: 100% !important;
        padding: 10px 14px !important;
        box-sizing: border-box !important;
    }

    /* 7. Mobile Inbox View */
    .inbox-layout,
    .inbox-container {
        flex-direction: column !important;
        height: auto !important;
    }

    .inbox-sidebar,
    .inbox-list {
        width: 100% !important;
        max-height: 300px !important;
        overflow-y: auto !important;
        border-right: none !important;
        border-bottom: 1px solid rgba(255,255,255,0.08) !important;
    }

    .inbox-detail,
    .inbox-thread {
        width: 100% !important;
        padding: 12px 8px !important;
    }

    /* 8. Mobile Sending Accounts Grid */
    .accounts-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    /* 9. Mobile Analytics & Charts */
    .analytics-grid,
    .charts-container {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    /* 10. Mobile Admin & Upgrade Modals */
    #admin-user-modal > div,
    #upgrade-modal > div {
        width: 95vw !important;
        max-width: 480px !important;
        max-height: 90vh !important;
        margin: auto !important;
        border-radius: 16px !important;
        overflow-y: auto !important;
    }

    /* 11. Cold Mail Builder Mobile Responsive Fixes */
    .instantly-sequence-container {
        flex-direction: column !important;
        min-height: auto !important;
        gap: 16px !important;
    }

    .instantly-steps-sidebar {
        width: 100% !important;
        max-width: 100% !important;
        padding: 14px !important;
        box-sizing: border-box !important;
    }

    .instantly-step-editor {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .clean-tabs-bar {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        white-space: nowrap !important;
        gap: 16px !important;
        padding-bottom: 6px !important;
    }

    .clean-tab {
        flex-shrink: 0 !important;
        font-size: 14px !important;
    }

    .cold-analytics-grid {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }

    /* 12. Mobile Top App Header */
    .mobile-app-header {
        display: flex !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: 56px !important;
        background: #091026 !important;
        border-bottom: 1px solid rgba(255,255,255,0.08) !important;
        z-index: 99999 !important;
        padding: 0 14px !important;
        align-items: center !important;
        justify-content: space-between !important;
        box-shadow: 0 4px 16px rgba(0,0,0,0.3) !important;
    }

    .mobile-app-header .mobile-menu-btn {
        position: static !important;
        display: flex !important;
    }

    .sidebar-close-btn {
        display: flex !important;
    }

    /* 13. Sidebar Nav Touch Targets */
    .sidebar nav .nav-item {
        padding: 14px 18px !important;
        font-size: 15px !important;
        border-radius: 12px !important;
        margin-bottom: 4px !important;
        min-height: 48px !important;
        display: flex !important;
        align-items: center !important;
    }

    /* 14. Main Content Area - proper padding below fixed header */
    .main-content {
        padding-top: 72px !important;
        padding-left: 10px !important;
        padding-right: 10px !important;
        padding-bottom: 32px !important;
        margin-left: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }

    /* 15. Page Headers mobile sizing */
    .page-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
        padding-bottom: 16px !important;
    }

    .page-title {
        font-size: 22px !important;
        line-height: 1.2 !important;
    }

    .page-subtitle {
        font-size: 13px !important;
    }

    /* 16. ALL Tables: force scrollable wrapper */
    .view table,
    .glass table,
    #app-page table {
        display: block !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        width: 100% !important;
    }

    .view thead,
    .view tbody,
    .view tr {
        min-width: max-content !important;
    }

    .view th,
    .view td {
        padding: 10px 12px !important;
        font-size: 13px !important;
        white-space: nowrap !important;
    }

    /* 17. Visual Builder Tabs (vb-tab) - horizontal scroll */
    .vb-tabs-row,
    div:has(> .vb-tab) {
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        white-space: nowrap !important;
        gap: 0 !important;
        flex-wrap: nowrap !important;
    }

    .vb-tab {
        flex-shrink: 0 !important;
        padding: 10px 14px !important;
        font-size: 13px !important;
        white-space: nowrap !important;
    }

    /* 18. Clean Tabs (cold-mail-builder) - horizontal scroll */
    .clean-tabs-bar {
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        white-space: nowrap !important;
        flex-wrap: nowrap !important;
        gap: 0 !important;
        margin-bottom: 20px !important;
    }

    .clean-tab {
        flex-shrink: 0 !important;
        font-size: 13px !important;
        padding-bottom: 10px !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
        white-space: nowrap !important;
    }

    /* 19. Stat cards grid */
    .stat-cards-row,
    .stat-card-grid,
    .overview-stats {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .stat-card {
        padding: 16px !important;
        border-radius: 14px !important;
    }

    .stat-card .stat-value,
    .stat-card-value {
        font-size: 24px !important;
    }

    /* 20. ALL Buttons - proper touch size */
    .view .btn,
    .view button,
    #app-page .btn {
        min-height: 44px !important;
        font-size: 14px !important;
        border-radius: 10px !important;
    }

    /* 21. All inline flex rows - stack on mobile */
    .view div[style*="display:flex"][style*="gap:24px"],
    .view div[style*="display:flex"][style*="gap:32px"] {
        flex-wrap: wrap !important;
    }

    /* 22. View inner containers - prevent any horizontal overflow */
    .view {
        max-width: 100vw !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }

    /* 23. Input fields - prevent iOS zoom */
    #app-page input,
    #app-page select,
    #app-page textarea {
        font-size: 16px !important;
    }

    /* 24. Sending Accounts cards */
    .view .glass,
    .view .card {
        padding: 16px 14px !important;
        border-radius: 14px !important;
        box-sizing: border-box !important;
    }

    /* 25. Cold Mail Builder action buttons row */
    #cold-tab-sequences > div:first-child {
        flex-direction: column !important;
        gap: 10px !important;
    }

    #cold-tab-sequences > div:first-child .btn,
    #cold-tab-sequences > div:first-child button {
        width: 100% !important;
    }

    /* 26. Campaign list / Cold mail list action buttons */
    .view .btn[style*="padding:6px 12px"],
    .view button[style*="padding:6px 12px"] {
        min-width: 40px !important;
        min-height: 40px !important;
        padding: 8px !important;
    }

    /* 27. Cold Mail Builder - autopilot button fix */
    #autopilot-btn {
        max-width: 100% !important;
        white-space: normal !important;
        word-break: break-word !important;
    }

    /* 28. Dedicated Mobile Sequence Builder Enhancements (PC Unchanged) */
    .instantly-sequence-container {
        flex-direction: column !important;
        min-height: auto !important;
        gap: 16px !important;
    }

    .inst-step-item {
        width: auto !important;
        flex-shrink: 0 !important;
        white-space: nowrap !important;
    }

    .instantly-steps-sidebar {
        width: 100% !important;
        max-width: 100% !important;
        padding: 10px 12px !important;
        background: transparent !important;
        border: none !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 8px !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .instantly-steps-sidebar h4 {
        display: none !important;
    }

    #inst-steps-bar {
        display: flex !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        gap: 8px !important;
        padding-bottom: 4px !important;
        flex-wrap: nowrap !important;
    }

    #inst-add-step-btn {
        width: auto !important;
        margin-top: 0 !important;
        padding: 8px 14px !important;
        font-size: 13px !important;
        flex-shrink: 0 !important;
    }



    .instantly-step-editor {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        border-radius: 12px !important;
    }

    .instantly-step-editor > div:first-child {
        padding: 14px 16px !important;
        flex-wrap: wrap !important;
        gap: 10px !important;
    }

    .instantly-step-editor > div:nth-child(2) {
        padding: 16px 12px !important;
    }

    /* Auto-pilot mobile form layout */
    #cold-tab-sequences div:has(> #autopilot-input) {
        flex-direction: column !important;
        gap: 10px !important;
    }

    #autopilot-input {
        width: 100% !important;
        box-sizing: border-box !important;
    }

    #autopilot-btn {
        width: 100% !important;
        justify-content: center !important;
        text-align: center !important;
    }

    /* Template selector mobile layout */
    #cold-tab-sequences div:has(> #template-selector) {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
    }

    #template-selector {
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Subject input mobile layout */
    #inst-subject {
        width: 100% !important;
        box-sizing: border-box !important;
        font-size: 15px !important;
        padding: 12px 14px !important;
        padding-right: 44px !important;
    }

    /* AI Tools buttons horizontal swipe row */
    #cold-tab-sequences div:has(> button[onclick*="checkSpamScore"]) {
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        white-space: nowrap !important;
        flex-wrap: nowrap !important;
        justify-content: flex-start !important;
        gap: 8px !important;
        padding-bottom: 6px !important;
        margin-bottom: 10px !important;
    }

    #cold-tab-sequences div:has(> button[onclick*="checkSpamScore"]) button {
        flex-shrink: 0 !important;
        font-size: 12px !important;
        padding: 8px 12px !important;
    }

    /* Textarea body mobile sizing */
    #inst-body {
        width: 100% !important;
        box-sizing: border-box !important;
        min-height: 180px !important;
        font-size: 15px !important;
        padding: 12px !important;
    }

    /* Tags & Spintax copy row */
    #cold-tab-sequences div[style*="border:1px dashed"] {
        padding: 10px !important;
        box-sizing: border-box !important;
    }

    #cold-tab-sequences div[style*="border:1px dashed"] div:last-child {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
    }

    /* 29. Visual Builder Design Editor Mobile Responsive (PC Unchanged) */
    #vb-tab-design {
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }

    .builder-top-bar {
        flex-direction: column !important;
        gap: 12px !important;
        padding: 12px 14px !important;
        align-items: stretch !important;
    }

    .builder-top-left {
        width: 100% !important;
        flex: none !important;
    }

    #campaign-subject {
        width: 100% !important;
        max-width: 100% !important;
        border: 1px solid var(--border) !important;
        background: #ffffff !important;
        font-size: 15px !important;
        padding: 10px 12px !important;
        box-sizing: border-box !important;
        border-radius: 8px !important;
    }

    /* Helper pills row */
    .builder-top-left div[style*="display:inline-flex"],
    .builder-top-left div:has(> button[onclick*="showToast"]) {
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        white-space: nowrap !important;
        gap: 6px !important;
        margin-top: 8px !important;
        margin-left: 0 !important;
        padding-bottom: 4px !important;
    }

    .builder-top-left button[onclick*="showToast"] {
        flex-shrink: 0 !important;
        padding: 6px 10px !important;
        font-size: 12px !important;
    }

    /* Top right actions (Undo, Redo, Save Template, Save Draft, Next) horizontal swipe */
    .builder-top-right {
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        gap: 8px !important;
        white-space: nowrap !important;
        width: 100% !important;
        padding-bottom: 4px !important;
        margin-top: 4px !important;
    }

    .builder-top-right .btn,
    .builder-top-right button {
        flex-shrink: 0 !important;
        font-size: 12px !important;
        padding: 8px 12px !important;
        min-height: 40px !important;
    }

    /* Builder Layout canvas & sidebar stacked vertically on mobile */
    .builder-layout {
        flex-direction: column !important;
        height: auto !important;
        min-height: auto !important;
        gap: 16px !important;
    }

    .builder-canvas-wrapper {
        width: 100% !important;
        max-width: 100% !important;
        padding: 12px !important;
        box-sizing: border-box !important;
        min-height: 380px !important;
        border-radius: 12px !important;
    }

    #builder-canvas {
        width: 100% !important;
        max-width: 100% !important;
        padding: 16px 12px !important;
        box-sizing: border-box !important;
        min-height: 320px !important;
    }

    .builder-sidebar {
        width: 100% !important;
        max-width: 100% !important;
        border-left: none !important;
        border-top: 1px solid var(--border) !important;
        box-sizing: border-box !important;
        min-height: auto !important;
        border-radius: 12px !important;
    }

    /* Block palette grid on mobile */
    #block-palette {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    .draggable-block {
        padding: 16px 10px !important;
        border-radius: 10px !important;
    }

    .draggable-block i {
        font-size: 20px !important;
        margin-bottom: 6px !important;
    }

    /* 30. Inbox Preview Modal Mobile Responsive Fixes (PC Unchanged) */
    #inbox-preview-modal > div {
        width: 95vw !important;
        max-width: 500px !important;
        max-height: 90vh !important;
        margin: auto !important;
        border-radius: 16px !important;
        overflow: hidden !important;
    }

    #inbox-preview-modal div[style*="width:200px"] {
        display: none !important;
    }

    #inbox-preview-modal div[style*="flex:1"][style*="padding:24px"] {
        padding: 16px 14px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    #inbox-preview-modal #preview-subject {
        font-size: 17px !important;
        font-weight: 700 !important;
        margin-bottom: 12px !important;
        line-height: 1.3 !important;
        word-break: break-word !important;
    }

    #preview-body-frame {
        width: 100% !important;
        min-height: 320px !important;
        border: none !important;
    }

    /* 32. Mobile Sidebar & Logout Button Fixes (PC 100% Unchanged) */
    aside.sidebar,
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        left: -100% !important;
        width: 280px !important;
        max-width: 85vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        z-index: 10000 !important;
        background: var(--surface-0, #fff) !important;
        border-right: 1px solid var(--border, #e2e8f0) !important;
        box-shadow: 6px 0 24px rgba(0,0,0,0.18) !important;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 20px 16px 100px 16px !important;
        display: flex !important;
        flex-direction: column !important;
    }

    aside.sidebar.open,
    .sidebar.open {
        left: 0 !important;
    }

    .sidebar-overlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        background: rgba(15, 23, 42, 0.6) !important;
        backdrop-filter: blur(4px) !important;
        -webkit-backdrop-filter: blur(4px) !important;
        z-index: 9999 !important;
        display: none;
    }

    .sidebar-overlay.show {
        display: block !important;
    }

    .sidebar-close-btn {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Mobile Logout Button Fix */
    #logout-btn {
        margin-top: 20px !important;
        margin-bottom: 40px !important;
        padding: 12px 16px !important;
        background: rgba(239, 68, 68, 0.08) !important;
        border: 1px solid rgba(239, 68, 68, 0.2) !important;
        border-radius: 12px !important;
        color: #ef4444 !important;
        font-weight: 700 !important;
        display: flex !important;
        align-items: center !important;
        gap: 10px !important;
        cursor: pointer !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    #logout-btn i {
        color: #ef4444 !important;
        font-size: 16px !important;
    }

    #logout-btn span {
        color: #ef4444 !important;
        font-weight: 700 !important;
        display: inline-block !important;
    }
}

/* ============================================================
   31. UNBEATABLE PC DESKTOP LAYOUT PROTECTION (min-width: 769px)
   Guarantees 100% full FIXED 260px sidebar on all PC screens
   Sidebar uses position:fixed so it NEVER scrolls away
   ============================================================ */
@media (min-width: 769px) {
    html, body {
        overflow-x: hidden !important;
    }

    #app-page,
    #app-page.on {
        display: block !important;
        width: 100% !important;
        min-height: 100vh !important;
        position: relative !important;
        overflow: visible !important;
    }

    .mobile-app-header,
    .mobile-menu-btn,
    .sidebar-overlay,
    .sidebar-close-btn {
        display: none !important;
    }

    aside.sidebar,
    .sidebar {
        display: flex !important;
        flex-direction: column !important;
        width: 260px !important;
        min-width: 260px !important;
        max-width: 260px !important;
        height: 100vh !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        z-index: 1000 !important;
        flex-shrink: 0 !important;
        background: var(--surface-0) !important;
        border-right: 1px solid var(--border) !important;
        transform: none !important;
        box-shadow: none !important;
        margin: 0 !important;
        padding: 32px 20px !important;
        visibility: visible !important;
        opacity: 1 !important;
        overflow-y: auto !important;
    }

    aside.sidebar .logo h2,
    aside.sidebar .nav-item > span:not(#user-support-badge):not(#admin-unread-badge),
    .sidebar .logo h2,
    .nav-item > span:not(#user-support-badge):not(#admin-unread-badge) {
        display: inline-block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    #user-support-badge,
    #admin-unread-badge {
        display: none !important;
    }

    #user-support-badge.has-unread,
    #admin-unread-badge.has-unread {
        display: inline-flex !important;
    }

    main.main-content,
    .main-content {
        display: block !important;
        width: calc(100% - 260px) !important;
        max-width: calc(100vw - 260px) !important;
        margin-left: 260px !important;
        padding: 36px 48px !important;
        min-height: 100vh !important;
        position: relative !important;
        z-index: 1 !important;
    }
}









