:root {
    /* Pro Agency Palette - Unified (Redesign v2) */
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --bg-dark: #0a1929;
    --bg-card: rgba(15, 23, 42, 0.8);
    --bg-card-solid: #0f172a;
    --bg-glass: rgba(15, 23, 42, 0.85);
    --sidebar-bg: #06111d;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --status-success: #10b981;
    --status-warning: #f59e0b;
    --status-error: #ef4444;
    --status-info: #0ea5e9;

    --border: rgba(255, 255, 255, 0.08);
    --card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --card-shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
    --glass-blur: blur(12px);
    
    --sidebar-width: 240px;
    --header-height: 64px;
    --card-radius: 12px;
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Reset & Typography */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

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

/* Layout Structure */
.app-container { display: flex; min-height: 100vh; }

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100vh;
    overflow-y: auto;
}

/* Content Layout - Only hide sidebar, NOT content */
.content-sidebar {
    display: none !important;
}

.content-main {
    display: block !important;
    width: 100% !important;
}

.content-layout {
    display: block !important;
}



/* Unified Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: var(--transition-smooth);
}

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

.brand {
    font-weight: 800;
    font-size: 1.25rem;
    color: white;
    text-decoration: none;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand span {
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.03); color: white; transform: translateX(4px); }
.nav-item.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(59, 130, 246, 0.05) 100%);
    color: var(--accent);
    font-weight: 600;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* Sidebar Filters - CRITICAL FIX */
.filters { padding: 20px; display: flex; flex-direction: column; gap: 24px; border-top: 1px solid var(--border); }
.filter-group { display: flex; flex-direction: column; gap: 12px; }
.filter-group-header { display: flex; justify-content: space-between; align-items: center; }
.filter-group h3 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 700; }

.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 0;
    transition: color 0.2s;
}
.filter-checkbox:hover { color: white; }
.filter-checkbox input[type="checkbox"] {
    appearance: none;
    width: 16px; height: 16px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}
.filter-checkbox input:checked { background: var(--accent); border-color: var(--accent); }
.filter-checkbox input:checked::after {
    content: ''; 
    position: absolute; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
}

.filter-action {
    background: none; border: none; color: var(--accent); font-size: 0.7rem; font-weight: 600; cursor: pointer;
}
.filter-action:hover { text-decoration: underline; }

.stats-panel { padding: 20px; background: rgba(0,0,0,0.2); border-top: 1px solid var(--border); margin-top: auto; }
.stats-panel h3 { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 12px; }
#quick-stats p { font-size: 0.8rem; display: flex; justify-content: space-between; margin-bottom: 6px; color: var(--text-secondary); }
#quick-stats span { font-weight: 700; color: white; }

/* Top Bar & Search */
.top-bar {
    height: var(--header-height);
    background: var(--bg-glass);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky; top: 0; z-index: 40;
}

.search-box { flex: 1; max-width: 500px; }
.search-box input {
    width: 100%;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    padding: 10px 16px;
    border-radius: 12px;
    color: white;
    font-size: 0.9rem;
    transition: all 0.2s;
}
.search-box input:focus { outline: none; border-color: var(--accent); background: rgba(255,255,255,0.08); box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1); }

/* Dashboard Grid (Ads) - CRITICAL FIX */
.ads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    padding: 32px;
}

.ad-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    overflow: hidden;
    transition: var(--transition-smooth);
    cursor: pointer;
    display: flex;
    flex-direction: column;
}
.ad-card:hover { border-color: var(--accent); transform: translateY(-4px); box-shadow: var(--card-shadow-hover); }

.ad-media {
    width: 100%;
    height: 200px;
    background: #000;
    position: relative;
    overflow: hidden;
}
.ad-media img, .ad-media video {
    width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease;
}
.ad-card:hover .ad-media img { transform: scale(1.05); }

.type-badge {
    position: absolute; top: 12px; left: 12px;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
    color: white; padding: 4px 10px; border-radius: 8px; font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
}

.ad-info { padding: 20px; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.page-name { font-weight: 700; font-size: 1rem; color: white; }
.ad-stats-row { display: flex; gap: 12px; font-size: 0.75rem; color: var(--text-secondary); }
.ad-hook { font-size: 0.85rem; color: var(--text-primary); line-height: 1.4; display: -webkit-box; line-clamp: 2; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-style: italic; }

.ad-meta-tags { margin-top: auto; display: flex; justify-content: space-between; align-items: center; padding-top: 12px; border-top: 1px solid var(--border); }
.tag { font-size: 0.65rem; background: rgba(59, 130, 246, 0.1); color: var(--accent); padding: 4px 8px; border-radius: 6px; font-weight: 600; }

/* Dashboard - Global Stats Header */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 24px;
    padding: 32px 32px 0;
}
.stat-card {
    background: linear-gradient(145deg, var(--bg-card-solid), #1e293b);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--card-shadow-hover); border-color: rgba(59, 130, 246, 0.3); }
.stat-value { font-size: 2rem; font-weight: 800; color: white; }
.stat-label { font-size: 0.75rem; color: var(--text-secondary); text-transform: uppercase; font-weight: 700; }

/* Unified Buttons */
.btn {
    padding: 10px 20px; border-radius: 12px; font-weight: 600; font-size: 0.9rem;
    display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
    transition: all 0.2s; border: 1px solid transparent; text-decoration: none;
}
.btn-primary { background: linear-gradient(135deg, var(--accent) 0%, #2563eb 100%); color: white; }
.btn-primary:hover { box-shadow: 0 0 20px rgba(59, 130, 246, 0.4); transform: translateY(-2px); }
.btn-secondary { background: rgba(255,255,255,0.05); color: white; border-color: var(--border); }
.btn-secondary:hover { background: rgba(255,255,255,0.1); border-color: var(--text-muted); }

/* Modals */
.modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(2, 6, 23, 0.9); backdrop-filter: blur(10px);
    display: none; align-items: center; justify-content: center; z-index: 3000; padding: 20px;
}
.modal.visible, .modal.show { display: flex; }
.modal-content {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 24px;
    width: 100%; max-width: 1200px; height: 90vh; display: flex; overflow: hidden;
    position: relative; box-shadow: 0 30px 60px rgba(0,0,0,0.5);
}

/* Mobile Responsive - see enhanced version at bottom */

/* Skeletons */
.skeleton {
    background: linear-gradient(90deg, var(--bg-card-solid) 25%, #1e293b 50%, var(--bg-card-solid) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 8px;
}
@keyframes loading { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Toast Notification System */
.toast-container {
    position: fixed; bottom: 24px; right: 24px; z-index: 4000;
    display: flex; flex-direction: column-reverse; gap: 10px;
    max-width: 400px; width: calc(100% - 48px);
    pointer-events: none;
}
.toast {
    background: var(--bg-card-solid); border: 1px solid var(--border); border-radius: 12px;
    transform: translateX(120%); transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.35s ease;
    font-size: 0.85rem; font-weight: 500; overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    pointer-events: auto; cursor: pointer; opacity: 0;
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast.success { border-left: 4px solid var(--status-success); }
.toast.error { border-left: 4px solid var(--status-error); }
.toast.warning { border-left: 4px solid var(--status-warning); }
.toast.info { border-left: 4px solid var(--status-info); }

.toast-body {
    display: flex; align-items: center; gap: 10px; padding: 12px 16px;
}
.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-msg { flex: 1; line-height: 1.4; color: var(--text-primary); }
.toast-close {
    background: none; border: none; color: var(--text-muted); font-size: 1.2rem;
    cursor: pointer; padding: 0 2px; line-height: 1; flex-shrink: 0;
}
.toast-close:hover { color: white; }
.toast-progress {
    height: 3px; width: 100%; transform-origin: left;
    animation: toast-drain linear forwards;
}
.toast-progress.success { background: var(--status-success); }
.toast-progress.error { background: var(--status-error); }
.toast-progress.warning { background: var(--status-warning); }
.toast-progress.info { background: var(--status-info); }
@keyframes toast-drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* Confirm Modal */
.confirm-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(2, 6, 23, 0.85); backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    z-index: 5000; opacity: 0; pointer-events: none;
    transition: opacity 0.25s ease;
}
.confirm-overlay.visible { opacity: 1; pointer-events: auto; }
.confirm-box {
    background: var(--bg-card-solid); border: 1px solid var(--border); border-radius: var(--card-radius);
    padding: 32px; max-width: 420px; width: 90%; text-align: center;
    transform: scale(0.9); transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}
.confirm-overlay.visible .confirm-box { transform: scale(1); }
.confirm-icon { font-size: 2.5rem; margin-bottom: 12px; }
.confirm-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; color: var(--text-primary); }
.confirm-message { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 24px; line-height: 1.5; }
.confirm-actions { display: flex; gap: 12px; justify-content: center; }
.confirm-cancel {
    background: rgba(255,255,255,0.05); border: 1px solid var(--border); color: var(--text-primary);
    padding: 10px 24px; border-radius: 10px; font-weight: 600; font-size: 0.9rem; cursor: pointer;
    font-family: inherit; transition: all 0.2s;
}
.confirm-cancel:hover { background: rgba(255,255,255,0.1); border-color: var(--text-muted); }
.confirm-ok {
    padding: 10px 24px; border-radius: 10px; font-weight: 600; font-size: 0.9rem;
    cursor: pointer; border: none; font-family: inherit; transition: all 0.2s;
}
.confirm-danger { background: var(--status-error); color: white; }
.confirm-danger:hover { background: #dc2626; transform: translateY(-1px); }
.confirm-primary { background: var(--accent); color: white; }
.confirm-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }

/* Button loading spinner */
.btn-spinner {
    display: inline-block; width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,0.3); border-top-color: white;
    border-radius: 50%; animation: btn-spin 0.6s linear infinite;
    vertical-align: middle;
}

/* Empty States */
.empty-state-pro {
    text-align: center; padding: 60px 20px; background: rgba(255,255,255,0.02);
    border: 2px dashed var(--border); border-radius: 24px; color: var(--text-secondary);
}
.empty-state-pro span { font-size: 3rem; display: block; margin-bottom: 16px; }

/* Category Scroll for Mobile */
.scroll-x {
    display: flex; overflow-x: auto; white-space: nowrap; gap: 10px;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.scroll-x::-webkit-scrollbar { display: none; }

/* ============================================
   NATIVE HTML ELEMENTS - Dark Theme Styling
   ============================================ */

/* Select dropdowns */
select, .controls-right select {
    appearance: none;
    -webkit-appearance: none;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 32px 8px 12px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}
select:hover { border-color: var(--text-muted); background-color: rgba(255,255,255,0.08); }
select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15); }
select option { background: var(--bg-card); color: var(--text-primary); }

/* View toggle buttons */
.view-toggles {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.view-toggles button {
    background: rgba(255,255,255,0.03);
    border: none;
    color: var(--text-secondary);
    padding: 8px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}
.view-toggles button:hover { background: rgba(255,255,255,0.08); color: white; }
.view-toggles button.active {
    background: var(--accent);
    color: white;
}
.view-toggles button + button { border-left: 1px solid var(--border); }

/* Controls right container */
.controls-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* File inputs */
input[type="file"] {
    color: var(--text-secondary);
    font-size: 0.85rem;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px;
    cursor: pointer;
}
input[type="file"]::file-selector-button {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    margin-right: 12px;
}
input[type="file"]::file-selector-button:hover {
    background: rgba(255,255,255,0.1);
    border-color: var(--text-muted);
}

/* Text inputs & textareas unified */
input[type="text"], input[type="number"], input[type="url"], textarea {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: all 0.2s;
}
input[type="text"]:focus, input[type="number"]:focus, input[type="url"]:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* ============================================
   SIDEBAR TOGGLE - Mobile Hamburger
   ============================================ */
.sidebar-toggle, #sidebar-toggle {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1001;
    display: none;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    font-size: 1.2rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.sidebar-toggle:hover, #sidebar-toggle:hover {
    background: var(--accent);
    border-color: var(--accent);
    transform: scale(1.05);
}

.sidebar-close, #sidebar-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color 0.2s;
}
.sidebar-close:hover { color: white; }

/* Clear filters button */
.clear-filters {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    margin-top: 12px;
    width: 100%;
    transition: all 0.2s;
}
.clear-filters:hover {
    background: rgba(255,255,255,0.1);
    color: white;
    border-color: var(--text-muted);
}

/* Filter chips / Pills */
.chips-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 16px 32px 0;
}
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #60a5fa;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.chip-remove {
    background: none;
    border: none;
    color: #60a5fa;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0;
    opacity: 0.8;
    transition: opacity 0.2s, transform 0.2s;
}
.chip-remove:hover { opacity: 1; transform: scale(1.1); }

.chip-clear-all {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 8px;
    cursor: pointer;
    transition: color 0.2s;
}
.chip-clear-all:hover {
    color: white;
    text-decoration: underline;
}

/* ============================================
   BUTTON MICRO-INTERACTIONS
   ============================================ */
button, .btn, [role="button"] {
    transition: all 0.2s ease;
}
button:active:not(:disabled), .btn:active:not(:disabled) {
    transform: scale(0.96);
}

/* Ghost buttons (used in modals) */
.btn-ghost {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-ghost:hover {
    background: rgba(255,255,255,0.1);
    border-color: var(--text-muted);
    transform: translateY(-1px);
}

/* Facebook link button */
.btn-fb {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #1877f2;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}
.btn-fb:hover { background: #1565c0; transform: translateY(-1px); }

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Loading spinner for buttons */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}
.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
    right: 12px;
    top: 50%;
    margin-top: -8px;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* ============================================
   IMPROVED MODAL RESPONSIVE
   ============================================ */
.modal-body {
    display: flex;
    height: 100%;
    overflow: hidden;
}
.media-column {
    flex: 0 0 45%;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    padding: 24px;
}
.analysis-column {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}
.analysis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.badge {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent);
    padding: 4px 12px;
    border-radius: var(--card-radius);
    font-size: 0.75rem;
    font-weight: 600;
}
.insight-box {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
}
.insight-box h4 {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.full-analysis {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.full-analysis h4 {
    font-size: 0.85rem;
    margin-bottom: 12px;
    color: var(--text-muted);
}
#modal-raw-analysis {
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.close-modal {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 1.8rem;
    color: var(--text-muted);
    cursor: pointer;
    z-index: 10;
    transition: color 0.2s;
    line-height: 1;
}
.close-modal:hover { color: white; }

.nav-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    z-index: 3001;
}
.nav-btn:hover { background: var(--accent); border-color: var(--accent); transform: scale(1.1); }

/* ============================================
   ENHANCED RESPONSIVE - Mobile & Tablet
   ============================================ */

/* Desktop: Always show sidebar - Forced flex layout */
@media (min-width: 769px) {
    .app-container {
        display: flex !important;
        flex-direction: row !important;
    }
    .sidebar {
        position: relative !important;
        left: 0 !important;
        transform: none !important;
        display: flex !important;
        flex-direction: column !important;
        flex: 0 0 var(--sidebar-width) !important;
        width: var(--sidebar-width) !important;
    }
    .main-content {
        flex: 1 1 auto !important;
        display: flex !important;
        min-width: 0 !important;
        flex-direction: column !important;
    }
    .sidebar-overlay {
        display: none !important;
    }
    .sidebar-toggle {
        display: none !important;
    }

    /* Content sidebar on desktop */
    .content-sidebar {
        width: 220px;
        flex-direction: column;
    }

    .content-nav {
        flex-direction: column;
    }

    .content-nav-item {
        padding: 12px 16px;
        font-size: 0.9rem;
    }
}

/* Mobile: Hide sidebar by default */
@media (max-width: 768px) {
    .sidebar {
        position: fixed !important;
        left: calc(-1 * var(--sidebar-width)) !important;
        top: 0 !important;
        height: 100vh !important;
        width: var(--sidebar-width) !important;
        display: none !important;
        z-index: 1000 !important;
    }
    .sidebar.open {
        left: 0 !important;
        display: flex !important;
    }

    /* Content sidebar on mobile - hide or make horizontal */
    .content-sidebar {
        width: 100%;
        flex-direction: row;
        border-right: none;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
        height: auto;
    }

    .content-nav {
        flex-direction: row;
        gap: 4px;
        padding: 8px;
        overflow-x: auto;
    }

    .content-nav-item {
        white-space: nowrap;
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .sidebar-overlay {
        position: fixed;
        display: none;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }
    .sidebar-overlay.visible { display: block; }

    .sidebar-toggle, #sidebar-toggle { display: flex !important; }

    .top-bar {
        padding: 0 16px;
        gap: 8px;
        padding-left: 68px;
    }

    .search-box { max-width: none; }

    .controls-right {
        flex-shrink: 0;
    }
    .controls-right select {
        max-width: 120px;
        font-size: 0.75rem;
        padding: 6px 24px 6px 8px;
    }
    .view-toggles button {
        padding: 6px 10px;
        font-size: 0.7rem;
    }

    .ads-grid {
        grid-template-columns: 1fr;
        padding: 16px;
        gap: 16px;
    }

    .chips-container { padding: 8px 16px 0; }

    .modal { padding: 4px; }
    .modal-content {
        flex-direction: column;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        height: 98vh;
        max-height: 98vh;
        border-radius: 12px;
    }
    .modal-body {
        flex-direction: column;
        overflow: visible;
        height: auto;
    }
    .media-column {
        flex: none;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 12px;
        overflow: hidden;
    }
    .media-column img, .media-column video {
        max-height: 35vh;
        object-fit: contain;
    }
    .analysis-column {
        padding: 12px;
        overflow: visible;
        height: auto;
    }

    .nav-btn { width: 36px; height: 36px; font-size: 1rem; }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        padding: 16px;
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .top-bar { padding-left: 60px; }
    .controls-right select { display: none; }
    .stats-grid { grid-template-columns: 1fr; }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .ads-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        padding: 24px;
        gap: 20px;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        padding: 24px 24px 0;
    }
}

/* ============================================
   FADE ANIMATIONS
   ============================================ */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   CRM - Client Cards & Grid (clients.html)
   ============================================ */
.content-area {
    padding: 0 32px 32px;
}

.client-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}

.client-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    padding: 20px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.client-card:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.client-card .card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.client-card .card-body {
    flex: 1;
}

.client-card .card-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--card-radius);
    font-size: 0.7rem;
    font-weight: 700;
    white-space: nowrap;
}
.badge-success { background: rgba(16,185,129,0.15); color: #34d399; }
.badge-info { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-warning { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-default { background: rgba(255,255,255,0.05); color: var(--text-secondary); }

/* Empty States */
.empty-state-pro {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}
.empty-state-pro span {
    font-size: 3rem;
    display: block;
    margin-bottom: 16px;
}
.empty-state-pro h3 {
    font-size: 1.1rem;
    color: white;
    margin-bottom: 8px;
}
.empty-state-pro p {
    font-size: 0.85rem;
    max-width: 400px;
    margin: 0 auto;
}

/* Form Inputs */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.form-group label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
}

@media (max-width: 768px) {
    .content-area { padding: 0 16px 16px; }
    .client-grid { grid-template-columns: 1fr; }
}

/* ============================================
   PHASE 3: MOBILE MODALS (375px iPhone SE)
   ============================================ */

/* Ad Detail Modal - Full mobile takeover */
@media (max-width: 480px) {
    .modal { padding: 0; }
    .modal-content {
        border-radius: 0;
        height: 100vh;
        max-height: 100vh;
        max-width: 100%;
    }
    .media-column {
        max-height: 30vh;
        padding: 8px;
    }
    .media-column img, .media-column video {
        max-height: 28vh;
    }
    .analysis-column {
        padding: 12px;
    }
    .analysis-header h3 { font-size: 1rem; }
    .insight-box { padding: 12px; margin-bottom: 8px; }
    .insight-box h4 { font-size: 0.75rem; }
    .full-analysis h4 { font-size: 0.8rem; }
    #modal-raw-analysis { font-size: 0.8rem; line-height: 1.5; }
    .close-modal { top: 8px; right: 12px; font-size: 2rem; }
    .nav-btn { width: 32px; height: 32px; font-size: 0.9rem; }
    .nav-btn.prev { position: fixed; left: 4px; }
    .nav-btn.next { position: fixed; right: 4px; }
    .action-row { grid-template-columns: 1fr !important; gap: 8px !important; }
    .meta-row { flex-direction: column; gap: 8px; }
}

/* Confirm modal mobile */
@media (max-width: 480px) {
    .confirm-box {
        width: 95%;
        padding: 24px 20px;
        border-radius: var(--card-radius);
    }
    .confirm-icon { font-size: 2rem; }
    .confirm-title { font-size: 1rem; }
    .confirm-message { font-size: 0.85rem; }
    .confirm-actions { flex-direction: column; gap: 8px; }
    .confirm-cancel, .confirm-ok {
        width: 100%;
        padding: 12px;
        text-align: center;
    }
}

/* Toast mobile */
@media (max-width: 480px) {
    .toast-container {
        bottom: 16px;
        right: 12px;
        left: 12px;
        max-width: none;
        width: auto;
    }
    .toast { font-size: 0.8rem; }
    .toast-body { padding: 10px 12px; }
}

/* ============================================
   PHASE 3: TOUCH TARGETS 44px MINIMUM
   ============================================ */

/* Filter checkboxes - enlarge touch area */
.filter-checkbox {
    min-height: 44px;
    display: flex;
    align-items: center;
}
.filter-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    min-width: 20px;
}

/* Filter action buttons */
.filter-action {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
}

/* Nav items */
.nav-item {
    min-height: 44px;
}

/* Tab buttons */
.tab-btn {
    min-height: 44px;
}

/* Chip remove button */
.chip-remove {
    min-width: 32px;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Sidebar close */
.sidebar-close, #sidebar-close {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Card action buttons (deep analyze, links) */
.card-deep-btn, .ad-meta-tags a {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* btn-icon ensure 44px */
.btn-icon {
    min-width: 44px;
    min-height: 44px;
}

/* Modal nav buttons */
.nav-btn {
    min-width: 44px;
    min-height: 44px;
}

/* All small action buttons in panels */
.panel-card .filter-action,
.business-card .filter-action {
    min-height: 36px;
    padding: 6px 12px;
}

@media (max-width: 768px) {
    .panel-card .filter-action,
    .business-card .filter-action {
        min-height: 44px;
        padding: 8px 14px;
    }
}

/* ============================================
   PHASE 4: STATUS BADGE ANIMATIONS
   ============================================ */

/* Pulsating running status */
@keyframes status-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 currentColor; }
    50% { opacity: 0.85; box-shadow: 0 0 8px 2px currentColor; }
}

@keyframes status-dot-pulse {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.3); opacity: 1; }
}

.status-running, .badge-running {
    animation: status-pulse 2s ease-in-out infinite;
}

/* Processing badge variant */
.badge-processing {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    animation: status-pulse 2s ease-in-out infinite;
}

/* Breathing dot for live indicators */
.status-dot-live {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--status-success);
    animation: status-dot-pulse 2s ease-in-out infinite;
    box-shadow: 0 0 6px var(--status-success);
}

/* Job item running state highlight */
.job-item-running {
    border-left: 3px solid var(--accent);
    background: rgba(59, 130, 246, 0.03);
}

/* Completed badge flash */
@keyframes badge-flash {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

.badge-just-completed {
    animation: badge-flash 0.5s ease-out;
}

/* ============================================
   PHASE 4: EMPTY STATES WITH ILLUSTRATIONS
   ============================================ */

.empty-state-illustrated {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.empty-state-illustrated svg {
    width: 120px;
    height: 120px;
    opacity: 0.6;
    margin-bottom: 8px;
}

.empty-state-illustrated h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin: 0;
}

.empty-state-illustrated p {
    font-size: 0.85rem;
    max-width: 400px;
    margin: 0;
    line-height: 1.5;
}

.empty-state-illustrated .btn {
    margin-top: 8px;
}

@media (max-width: 480px) {
    .empty-state-illustrated {
        padding: 32px 16px;
    }
    .empty-state-illustrated svg {
        width: 80px;
        height: 80px;
    }
    .empty-state-illustrated h3 { font-size: 1rem; }
}

/* ============================================
   SECTION NAVIGATION CARDS
   ============================================ */

/* ============================================
   COMPACT HORIZONTAL NAVIGATION TABS
   ============================================ */

.section-nav-cards {
    display: flex;
    gap: 8px;
    padding: 16px 32px;
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    position: sticky;
    top: var(--header-height);
    z-index: 50;
}

.section-nav-cards::-webkit-scrollbar {
    display: none;
}

.nav-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 10px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    flex-shrink: 0;
}

.nav-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--text-muted);
}

.nav-card.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.nav-card-icon {
    font-size: 1rem;
    line-height: 1;
}

.nav-card-title {
    font-size: 0.85rem;
    font-weight: 600;
}

.nav-card-desc {
    display: none;
}

/* Mobile Section Selector Dropdown */
.section-selector-mobile {
    display: none;
    padding: 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.section-selector-mobile select {
    width: 100%;
    padding: 12px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

/* Content Sections */
.content-sections {
    padding: 0 32px 32px;
}

.content-section {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.content-section.active {
    display: block;
}

/* Responsive */
@media (max-width: 768px) {
    .section-nav-cards {
        display: none;
    }
    
    .section-selector-mobile {
        display: block;
    }
    
    .content-sections {
        padding: 0 16px 16px;
    }
}

@media (max-width: 1024px) {
    .section-nav-cards {
        padding: 12px 16px;
        gap: 6px;
    }
    
    .nav-card {
        padding: 8px 14px;
    }
    
    .nav-card-title {
        font-size: 0.8rem;
    }
}

/* ============================================
   FASE 10: AI TOOLS SIDEBAR (client.html)
   ============================================ */
.ai-cat-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 12px 16px;
    text-align: left;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}
.ai-cat-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}
.ai-cat-btn.active {
    background: var(--bg-card-solid);
    color: var(--accent);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-left: 3px solid var(--accent);
}

@media (max-width: 768px) {
    .ai-layout-container {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    .ai-sidebar {
        position: static !important;
        margin-bottom: 8px;
    }
    .ai-category-list {
        flex-direction: row !important;
        overflow-x: auto;
        padding-bottom: 8px;
    }
    .ai-cat-btn {
        white-space: nowrap;
        padding: 8px 16px;
        border-radius: 20px;
        background: rgba(255, 255, 255, 0.05);
    }
    .ai-cat-btn.active {
        border-left: none;
        background: rgba(59, 130, 246, 0.15);
    }
}    

/* ============================================
   FASE 8: POLISH & MICRO-INTERACTIONS
   ============================================ */

/* Pulsating badge for running status */
.badge-running {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    animation: badge-pulse 2s ease-in-out infinite;
}
@keyframes badge-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4); }
    50% { box-shadow: 0 0 8px 4px rgba(59, 130, 246, 0.15); }
}

/* Smooth page fade-in */
body {
    animation: page-fade-in 0.4s ease-out;
}
@keyframes page-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Card entrance animation for content sections */
.content-section.active {
    animation: section-reveal 0.35s ease-out;
}
@keyframes section-reveal {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Enhanced focus states for accessibility */
.btn:focus-visible, .btn-primary:focus-visible, .btn-secondary:focus-visible,
.nav-item:focus-visible, .filter-action:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Smooth transition on content-sidebar nav items */
.content-nav-item {
    transition: all 0.2s ease;
}
.content-nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    transform: translateX(4px);
}

/* --- Fase 12: AI Reader Drawer & Prose --- */
.drawer-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(2, 6, 23, 0.7); backdrop-filter: blur(4px);
    z-index: 1000; opacity: 0; visibility: hidden; transition: all 0.3s ease;
}
.drawer-overlay.visible { opacity: 1; visibility: visible; }

.drawer {
    position: fixed; top: 0; right: 0; height: 100vh; width: 100%; max-width: 800px;
    background: var(--bg-card-solid); border-left: 1px solid var(--border);
    box-shadow: -10px 0 40px rgba(0,0,0,0.5); z-index: 1001;
    display: flex; flex-direction: column;
    transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.drawer.open { transform: translateX(0); }

.drawer-header {
    padding: 24px 32px; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
    background: rgba(255,255,255,0.02);
}
.drawer-close-btn {
    background: transparent; border: none; color: var(--text-muted);
    font-size: 1.5rem; cursor: pointer; padding: 8px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.drawer-close-btn:hover { background: rgba(255,255,255,0.1); color: white; }

.drawer-content {
    flex: 1; overflow-y: auto; padding: 32px;
}
.drawer-footer {
    padding: 20px 32px; border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 12px;
    background: rgba(255,255,255,0.02);
}

/* Premium Prose Reader */
.prose {
    font-size: 1.05rem; line-height: 1.7; color: #cbd5e1;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.prose h1, .prose h2, .prose h3 { color: var(--text-primary); margin-top: 2em; margin-bottom: 0.75em; font-weight: 700; line-height: 1.3; }
.prose h1 { font-size: 1.8rem; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 0.3em; margin-top: 0; }
.prose h2 { font-size: 1.4rem; color: var(--accent); }
.prose h3 { font-size: 1.2rem; }
.prose p { margin-bottom: 1.5em; }
.prose strong { color: white; font-weight: 600; }
.prose ul, .prose ol { margin-bottom: 1.5em; padding-left: 1.5em; }
.prose li { margin-bottom: 0.5em; }
.prose li::marker { color: var(--accent); }
.prose blockquote { border-left: 4px solid var(--accent); margin: 0 0 1.5em 0; padding: 0.5em 0 0.5em 1.5em; background: rgba(59, 130, 246, 0.05); color: #94a3b8; font-style: italic; border-radius: 0 8px 8px 0; }
.prose table { width: 100%; border-collapse: collapse; margin-bottom: 2em; font-size: 0.95rem; }
.prose th, .prose td { padding: 12px 16px; text-align: left; border-bottom: 1px solid rgba(255,255,255,0.08); }
.prose th { font-weight: 600; color: var(--text-primary); text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.05em; background: rgba(255,255,255,0.03); }
.prose tr:hover td { background: rgba(255,255,255,0.02); }

/* Inline Loading Spinner */
.spinner {
    display: inline-block;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
