* { margin: 0; padding: 0; box-sizing: border-box; }

/* =============================================
   THEME SYSTEM - Professional Design
   ============================================= */

:root {
    /* Brand Colors */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #8b5cf6;
    --accent: #06b6d4;

    /* Status Colors */
    --success: #10b981;
    --success-light: #34d399;
    --warning: #f59e0b;
    --warning-light: #fbbf24;
    --danger: #ef4444;
    --danger-light: #f87171;

    /* Sidebar */
    --sidebar-width: 260px;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

/* Dark Theme (Default) */
:root, [data-theme="dark"] {
    --bg-primary: #0a0e1a;
    --bg-primary-rgb: 10, 14, 26;
    --bg-secondary: #111827;
    --bg-secondary-rgb: 17, 24, 39;
    --bg-card: #1a1f2e;
    --bg-card-rgb: 26, 31, 46;
    --bg-card-hover: #242938;
    --bg-hover: #2d3548;
    --bg-input: #151b2b;
    --border: #2d3548;
    --border-light: #374151;
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --text-inverse: #111827;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --gradient-card: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, transparent 100%);
    --gradient-glow: radial-gradient(ellipse at center, rgba(99, 102, 241, 0.15), transparent 70%);
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-primary-rgb: 248, 250, 252;
    --bg-secondary: #ffffff;
    --bg-secondary-rgb: 255, 255, 255;
    --bg-card: #ffffff;
    --bg-card-rgb: 255, 255, 255;
    --bg-card-hover: #f1f5f9;
    --bg-hover: #e2e8f0;
    --bg-input: #f1f5f9;
    --border: #e2e8f0;
    --border-light: #cbd5e1;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-inverse: #f9fafb;

    /* Adjusted shadows for light mode */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.03);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.03);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.05), 0 4px 6px -4px rgb(0 0 0 / 0.03);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.05), 0 8px 10px -6px rgb(0 0 0 / 0.03);

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --gradient-card: linear-gradient(180deg, rgba(255,255,255,1) 0%, rgba(248,250,252,1) 100%);
    --gradient-glow: radial-gradient(ellipse at center, rgba(99, 102, 241, 0.08), transparent 70%);
}

/* Legacy variable mapping for backward compatibility */
:root {
    --bg-dark: var(--bg-primary);
}

[data-theme="light"] {
    --bg-dark: var(--bg-secondary);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Smooth theme transition for all elements */
*, *::before, *::after {
    transition: background-color var(--transition-normal),
                border-color var(--transition-normal),
                box-shadow var(--transition-normal);
}

/* Logo styling - highlight Ads portion */
.logo-ads {
    color: var(--primary) !important;
}

.screen { display: none; }
.screen.active { display: flex; }

/* Login */
#login-screen {
    min-height: 100vh;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

.login-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
}

.login-brand { text-align: center; margin-bottom: 32px; }
.login-brand .logo { margin-bottom: 12px; }
.login-brand h1 { font-size: 28px; font-weight: 700; color: var(--text-primary); }
.login-brand p { color: var(--text-muted); margin-top: 4px; font-size: 13px; }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; color: var(--text-secondary); font-size: 13px; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    transition: all var(--transition-fast);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    background: var(--bg-card);
}
.form-group input::placeholder { color: var(--text-muted); }
.form-group small { display: block; margin-top: 6px; color: var(--text-muted); font-size: 12px; }

/* Stripe Elements Container */
.stripe-element-container {
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.stripe-element-container:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    background: var(--bg-card);
}
.card-errors {
    color: var(--danger);
    font-size: 13px;
    margin-top: 8px;
    min-height: 20px;
}
.terms-checkbox {
    margin-top: 16px;
}
.terms-checkbox .checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
}
.terms-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: var(--primary);
}
.terms-checkbox a {
    color: var(--primary);
    text-decoration: none;
}
.terms-checkbox a:hover {
    text-decoration: underline;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
    box-shadow: var(--shadow-sm);
}
.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.45);
}
.btn-primary:active {
    transform: translateY(0);
}
.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
}
.btn-danger {
    background: var(--danger);
    color: white;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.35);
}
.btn-danger:hover {
    background: var(--danger-light);
    transform: translateY(-1px);
}
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    box-shadow: none;
}
.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 15px; }

.error-message { color: var(--danger); text-align: center; margin-top: 16px; font-size: 13px; }
.login-footer { text-align: center; margin-top: 24px; color: var(--text-muted); font-size: 11px; }
.login-footer p { margin: 4px 0; }

/* App Layout */
#app-screen { display: none; min-height: 100vh; }
#app-screen.active { display: flex; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    box-shadow: var(--shadow-lg);
}

.sidebar-header {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid var(--border);
    background: var(--gradient-card);
}

.sidebar-header .logo-small {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.sidebar-header .logo-small img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-title {
    font-size: 20px;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-menu {
    list-style: none;
    padding: 16px 12px;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: 4px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    position: relative;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 60%;
    background: white;
    border-radius: 0 4px 4px 0;
    opacity: 0.5;
}

.nav-item.active .nav-icon { stroke: white; }
.nav-icon {
    width: 20px;
    height: 20px;
    stroke: var(--text-muted);
    flex-shrink: 0;
    transition: stroke var(--transition-fast);
}
.nav-item:hover .nav-icon { stroke: var(--text-primary); }

.nav-section-header {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 16px 16px 6px;
    list-style: none;
    user-select: none;
}

.nav-section-header:first-child {
    padding-top: 4px;
}

.superadmin-only { display: none; }
body.is-superadmin .superadmin-only { display: flex; }
.admin-only { display: flex; }
body.is-affiliate .admin-only { display: none !important; }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--gradient-card);
    box-shadow: 0 -1px 0 var(--border), inset 0 1px 0 rgba(99,102,241,0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
    color: white;
    box-shadow: var(--shadow-md);
}

.user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: capitalize;
}

.btn-logout {
    background: transparent;
    border: none;
    padding: 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

.btn-logout svg { stroke: currentColor; }

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 28px 32px;
    min-height: 100vh;
    background: var(--bg-primary);
}

.page { display: none; }
.page.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Page subtitle */
.page-subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin: 4px 0 0;
}

/* Help button */
.help-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: all var(--transition-fast);
}
.help-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Warning Banner */
.warning-banner {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #f59e0b;
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 24px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
}
[data-theme="dark"] .warning-banner {
    background: linear-gradient(135deg, rgba(245,158,11,0.12) 0%, rgba(245,158,11,0.06) 100%);
    border-color: rgba(245,158,11,0.3);
}
.warning-banner-icon {
    background: #f59e0b;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.warning-banner-body { flex: 1; }
.warning-banner-title {
    color: #92400e;
    font-size: 14px;
    display: block;
    margin-bottom: 4px;
}
[data-theme="dark"] .warning-banner-title { color: #fbbf24; }
.warning-banner-text {
    margin: 0;
    color: #a16207;
    font-size: 13px;
    line-height: 1.5;
}
[data-theme="dark"] .warning-banner-text { color: #d97706; }

/* Fraud page grid */
.fraud-breakdown-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
@media (max-width: 768px) { .fraud-breakdown-grid { grid-template-columns: 1fr; } }

.fraud-logs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.fraud-logs-header h3 { margin: 0; }

.loading-placeholder {
    text-align: center;
    color: var(--text-muted);
    padding: 40px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
}

.page-header h1 small {
    font-weight: 400;
    font-size: 14px;
    color: var(--text-muted);
    margin-left: 10px;
}

.count-badge {
    display: inline-block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    margin-left: 6px;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.search-input, .select-filter {
    padding: 10px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    transition: all var(--transition-fast);
}

.search-input:focus, .select-filter:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    background: var(--bg-card);
}

.search-input:hover, .select-filter:hover {
    border-color: var(--border-light);
}

.search-input { width: 200px; }
.search-input[type="date"] { width: 150px; }
.search-input::placeholder { color: var(--text-muted); }
.select-filter { cursor: pointer; }
.select-filter option { background: var(--bg-card); }

/* =============================================
   FILTER BAR SYSTEM — Standard component
   Usage: <div class="filter-bar"> ... </div>
   ============================================= */

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    align-items: center;
}

/* Separator between filter groups */
.filter-bar .filter-separator {
    width: 1px;
    height: 28px;
    background: var(--border);
    flex-shrink: 0;
}

/* Search input with icon */
.filter-bar .filter-search {
    position: relative;
    min-width: 160px;
    flex: 1;
    max-width: 220px;
}
.filter-bar .filter-search svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    opacity: 0.5;
}
.filter-bar .filter-search input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    transition: all var(--transition-fast);
}
.filter-bar .filter-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
    background: var(--bg-card);
}
.filter-bar .filter-search input:hover {
    border-color: var(--border-light);
}
.filter-bar .filter-search input::placeholder {
    color: var(--text-muted);
}
/* Autocomplete suggestions container */
.filter-bar .filter-search .campaign-suggestions {
    left: 0;
    right: 0;
}

/* Styled select */
.filter-bar .filter-select {
    position: relative;
    min-width: 120px;
}
.filter-bar .filter-select select {
    width: 100%;
    padding: 8px 32px 8px 34px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    transition: all var(--transition-fast);
}
.filter-bar .filter-select select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}
.filter-bar .filter-select select:hover {
    border-color: var(--border-light);
}
.filter-bar .filter-select option {
    background: var(--bg-card);
}
/* Left icon */
.filter-bar .filter-select > svg:first-child {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    opacity: 0.5;
}
/* Chevron on the right */
.filter-bar .filter-select::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--text-muted);
    pointer-events: none;
}

/* Date inputs with calendar icon */
.filter-bar .filter-date {
    position: relative;
}
.filter-bar .filter-date svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    opacity: 0.5;
}
.filter-bar .filter-date input {
    padding: 8px 12px 8px 34px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    max-width: 160px;
    transition: all var(--transition-fast);
}
.filter-bar .filter-date input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}
.filter-bar .filter-date input:hover {
    border-color: var(--border-light);
}

/* Date preset pills */
.filter-bar .filter-date-presets {
    display: flex;
    gap: 2px;
    padding: 3px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.filter-bar .filter-date-presets button {
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    background: transparent;
    color: var(--text-muted);
    transition: all var(--transition-fast);
    white-space: nowrap;
}
.filter-bar .filter-date-presets button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.filter-bar .filter-date-presets button.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
}

/* Pill group (event types, etc.) */
.filter-bar .filter-pills {
    display: flex;
    gap: 2px;
    padding: 3px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.filter-bar .filter-pills button {
    padding: 5px 12px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    background: transparent;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    white-space: nowrap;
}
.filter-bar .filter-pills button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.filter-bar .filter-pills button.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
}
/* Colored pill variants */
.filter-bar .filter-pills button.click.active { background: #6366f1; }
.filter-bar .filter-pills button.lead.active { background: #10b981; }
.filter-bar .filter-pills button.sale.active { background: #f59e0b; }

/* Clear / action buttons */
.filter-bar .filter-btn-clear {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.filter-bar .filter-btn-clear:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.filter-bar .filter-btn-action {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.filter-bar .filter-btn-action:hover {
    background: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* Active filters row */
.filter-bar .filter-active-tags {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}
.filter-bar .filter-active-tags:empty {
    display: none;
}
.filter-bar .filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-light);
    font-size: 12px;
    font-weight: 500;
    border-radius: 20px;
    border: 1px solid rgba(99, 102, 241, 0.2);
}
.filter-bar .filter-tag button {
    background: none;
    border: none;
    color: inherit;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.7;
    transition: opacity var(--transition-fast);
}
.filter-bar .filter-tag button:hover {
    opacity: 1;
}

/* Results count */
.filter-results-count {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* Responsive */
@media (max-width: 768px) {
    .filter-bar {
        padding: 12px;
        gap: 8px;
        max-width: 100%;
        box-sizing: border-box;
    }
    .filter-bar > * { min-width: 0; max-width: 100%; box-sizing: border-box; }
    .filter-bar .filter-search { max-width: 100%; min-width: 100%; }
    .filter-bar .filter-separator { display: none; }
    .filter-bar .filter-select { min-width: 100%; max-width: 100%; }
    .filter-bar .filter-date { flex: 1 1 calc(50% - 4px); min-width: 0; }
    .filter-bar .filter-date input { max-width: 100%; width: 100%; min-width: 0; box-sizing: border-box; }
    .filter-bar .filter-pills { width: 100%; flex-wrap: wrap; }
    .filter-bar .filter-pills button { flex: 1 1 auto; }
    .filter-bar .filter-btn-action { width: 100%; }
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}
#conversions-summary-cards { grid-template-columns: repeat(4, 1fr); }

.stats-grid.secondary-stats .stat-card { padding: 18px; }

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 18px;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.stat-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card.mini { padding: 16px 18px; }
.stat-card.mini .stat-value { font-size: 20px; }

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: var(--shadow-md);
}

.stat-icon svg { stroke: white; }

.stat-card.clicks .stat-icon { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.stat-card.leads .stat-icon { background: linear-gradient(135deg, #10b981, #059669); }
.stat-card.sales .stat-icon { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-card.revenue .stat-icon { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }

.stat-label {
    display: block;
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.sidebar-cards {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

@media (max-width: 1200px) { .dashboard-grid { grid-template-columns: 1fr; } }

.chart-card, .top-campaigns-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}

.chart-card:hover, .top-campaigns-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-light);
}

.chart-card h3 {
    margin-bottom: 20px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-card h3::before {
    content: '';
    width: 4px;
    height: 18px;
    background: var(--gradient-primary);
    border-radius: 2px;
    flex-shrink: 0;
}

.chart-card {
    min-height: 320px;
    position: relative;
}

.chart-card canvas {
    max-height: 300px;
    min-height: 250px;
    width: 100% !important;
}

.top-campaigns-card h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin-bottom: 16px;
    font-size: 15px;
    font-weight: 600;
}

.top-campaigns-card h3::before {
    content: '';
    width: 4px;
    height: 18px;
    background: var(--gradient-primary);
    border-radius: 2px;
    flex-shrink: 0;
}

#top-campaigns-list,
#top-affiliates-list {
    display: block;
    width: 100%;
}

#top-campaigns-list .campaign-item,
#top-affiliates-list .campaign-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
#top-campaigns-list .campaign-item:last-child,
#top-affiliates-list .campaign-item:last-child { border-bottom: none; }

#top-campaigns-list .campaign-item-name,
#top-affiliates-list .campaign-item-name { 
    font-weight: 500; 
    font-size: 13px; 
    flex: 1; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    white-space: nowrap; 
    margin-right: 12px; 
}

#top-campaigns-list .campaign-item-stats,
#top-affiliates-list .campaign-item-stats { 
    display: flex; 
    gap: 12px; 
    font-size: 11px; 
    color: var(--text-muted); 
    flex-shrink: 0; 
}

/* Conversion Funnel */
.funnel-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 24px;
}
.funnel-header {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}
.funnel-stages {
    display: flex;
    align-items: center;
    gap: 12px;
}
.funnel-stage {
    flex: 1;
    min-width: 0;
}
.funnel-bar-container {
    height: 10px;
    background: var(--border);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 8px;
}
.funnel-bar {
    height: 100%;
    border-radius: 6px;
    transition: width 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}
.funnel-clicks { background: linear-gradient(90deg, #6366f1, #818cf8); }
.funnel-leads { background: linear-gradient(90deg, #10b981, #34d399); }
.funnel-sales { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.funnel-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}
.funnel-label-name {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.funnel-label-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}
.funnel-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    color: var(--text-muted);
}
.funnel-rate {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}
@media (max-width: 768px) {
    .funnel-stages { flex-direction: column; gap: 8px; }
    .funnel-arrow { flex-direction: row; gap: 6px; }
    .funnel-arrow svg { transform: rotate(90deg); }
}

/* Device Donut Chart */
.donut-center-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -60%);
    text-align: center;
    pointer-events: none;
}
.donut-total {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}
.donut-total-label {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Trend Indicators */
.stat-trend {
    display: block;
    font-size: 11px;
    font-weight: 600;
    margin-top: 2px;
    min-height: 16px;
}

/* Top Campaign Rows (improved layout) */
.top-campaign-row {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition-fast);
}
.top-campaign-row:last-child { border-bottom: none; }
.top-campaign-row:hover { background: var(--bg-card-hover); margin: 0 -24px; padding: 10px 24px; border-radius: var(--radius-sm); }
.top-campaign-name-row {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 6px;
    color: var(--text-primary);
}
.top-campaign-bar {
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    margin-bottom: 6px;
    overflow: hidden;
}
.top-campaign-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
}
.top-campaign-bar-fill.clicks-bar { background: var(--primary); }
.top-campaign-bar-fill.affiliates-bar { background: var(--success); }
.top-campaign-metrics {
    display: flex;
    gap: 16px;
    font-size: 11px;
    color: var(--text-muted);
}
.top-campaign-metrics span { min-width: 40px; }
.top-campaign-metrics .text-success { color: var(--success); }
.top-campaign-metrics .text-danger { color: var(--danger); }

/* Top List Header */
.top-list-header {
    display: flex;
    gap: 16px;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}
.top-list-header span { min-width: 40px; }

/* Secondary Metrics Card */
.secondary-metrics-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0;
    margin-bottom: 24px;
    overflow: hidden;
}
.secondary-metrics-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
}
.secondary-metric {
    text-align: center;
    padding: 18px 12px;
    border-right: 1px solid var(--border);
    transition: background var(--transition-fast);
    position: relative;
}
.secondary-metric:last-child { border-right: none; }
.secondary-metric.admin-only { display: block; }
.secondary-metric:hover { background: var(--bg-card-hover); }
.secondary-metric:not(:last-child)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 25%;
    height: 50%;
    width: 1px;
    background: linear-gradient(to bottom, transparent, var(--border), transparent);
}
.secondary-metric .stat-label {
    display: block;
    margin-bottom: 6px;
}
.secondary-metric .stat-value {
    display: block;
    font-size: 22px;
    letter-spacing: -0.3px;
}
.secondary-metric.profit-positive { border-bottom: 2px solid var(--success); }
.secondary-metric.profit-negative { border-bottom: 2px solid var(--danger); }

/* Recent Activity */
.recent-activity-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.recent-activity-item:last-child { border-bottom: none; }
.recent-activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.recent-activity-dot.lead { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.4); }
.recent-activity-dot.sale { background: #f59e0b; box-shadow: 0 0 6px rgba(245,158,11,0.4); }
.recent-activity-info {
    flex: 1;
    min-width: 0;
}
.recent-activity-campaign {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
    font-weight: 500;
}
.recent-activity-amount {
    font-weight: 600;
    flex-shrink: 0;
}
.recent-activity-time {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 45px;
    text-align: right;
}
.recent-activity-new {
    animation: recentActivityPulse 0.5s ease;
}
@keyframes recentActivityPulse {
    0% { background: rgba(99,102,241,0.15); }
    100% { background: transparent; }
}

@media (max-width: 768px) {
    .secondary-metrics-grid { grid-template-columns: repeat(3, 1fr); }
    .secondary-metric { border-bottom: 1px solid var(--border); }
    .secondary-metric:nth-child(3) { border-right: none; }
}

/* Period Selector */
.period-selector {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.period-btn {
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
}

.period-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.period-btn.active {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
}

.data-table th, .data-table td {
    padding: 14px 18px;
    text-align: left;
}

.data-table th {
    background: var(--bg-secondary);
    font-weight: 600;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-bottom: 2px solid var(--border);
}

.data-table td {
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    color: var(--text-primary);
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tr:hover td {
    background: var(--bg-card-hover);
}

.data-table tr:hover td:first-child {
    box-shadow: inset 3px 0 0 var(--primary);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.status-active { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.status-inactive { background: rgba(239, 68, 68, 0.12); color: #ef4444; }
.status-pending { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.status-approved { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.status-rejected { background: rgba(239, 68, 68, 0.12); color: #ef4444; }

.ctr-badge {
    display: inline-block;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    background: rgba(99, 102, 241, 0.12);
    color: var(--primary);
}

/* Event type color badges */
.event-type-click { background: rgba(99,102,241,0.12) !important; color: #6366f1 !important; }
.event-type-lead { background: rgba(16,185,129,0.12) !important; color: #10b981 !important; }
.event-type-sale { background: rgba(245,158,11,0.12) !important; color: #f59e0b !important; }
.event-type-pageview { background: rgba(148,163,184,0.12) !important; color: #94a3b8 !important; }
.event-type-upsell, .event-type-rebill { background: rgba(139,92,246,0.12) !important; color: #8b5cf6 !important; }

/* Event type pill filters */
.event-type-pills {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 4px;
}
.event-pill {
    padding: 6px 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    background: transparent;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    white-space: nowrap;
}
.event-pill:hover { background: var(--bg-hover); color: var(--text-primary); }
.event-pill.active { background: var(--primary); color: white; box-shadow: 0 2px 8px rgba(99,102,241,0.3); }
.event-pill.click.active { background: #6366f1; }
.event-pill.lead.active { background: #10b981; }
.event-pill.sale.active { background: #f59e0b; }

/* Fraud row highlight */
.fraud-row td { background: rgba(239,68,68,0.05) !important; }
.fraud-row td:first-child { box-shadow: inset 3px 0 0 #ef4444 !important; }
.fraud-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: rgba(239,68,68,0.12);
    color: #dc2626;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 999px;
    font-weight: 600;
    margin-left: 4px;
}

/* Events live badge */
.events-live-badge {
    display: inline-block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-left: 6px;
}

/* Alert Rules Card Layout */
.rules-summary {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 16px;
}
.rule-cards-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.rule-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all var(--transition-fast);
}
.rule-card:hover { box-shadow: var(--shadow-md); border-left-color: var(--primary); }
.rule-card.rule-paused { opacity: 0.6; border-left-color: var(--border); }
.rule-card-left { flex-shrink: 0; }
.rule-card-body { flex: 1; min-width: 0; }
.rule-card-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.rule-card-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}
.rule-condition {
    background: rgba(107,114,128,0.1);
    color: var(--text-secondary);
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    font-family: monospace;
}
.rule-arrow { color: var(--text-muted); font-size: 14px; }
.rule-meta-sep { color: var(--border); }
.rule-trigger-badge {
    background: rgba(245,158,11,0.15);
    color: #f59e0b;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 600;
}
.rule-card-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* Rule toggle (checkbox-based) */
.rule-toggle-wrap {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 22px;
    cursor: pointer;
}
.rule-toggle-input { opacity: 0; width: 0; height: 0; position: absolute; }
.rule-toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-hover);
    border-radius: 11px;
    transition: background var(--transition-fast);
    border: 1px solid var(--border);
}
.rule-toggle-slider::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform var(--transition-fast);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.rule-toggle-input:checked + .rule-toggle-slider { background: #10b981; border-color: #10b981; }
.rule-toggle-input:checked + .rule-toggle-slider::after { transform: translateX(16px); }

.toggle-switch {
    width: 40px;
    height: 22px;
    background: var(--bg-hover);
    border-radius: 11px;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}
.toggle-switch.active { background: var(--success); }
.toggle-switch::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 9px;
    top: 2px;
    left: 2px;
    transition: all 0.2s;
}
.toggle-switch.active::after { left: 20px; }

/* Geo-Redirect Toggle Switch */
.geo-toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    cursor: pointer;
    flex-shrink: 0;
}
.geo-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.geo-toggle-track {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-tertiary);
    border-radius: 28px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.geo-toggle-switch.active .geo-toggle-track {
    background: var(--primary);
}
.geo-toggle-thumb {
    position: absolute;
    width: 22px;
    height: 22px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.geo-toggle-switch.active .geo-toggle-thumb {
    transform: translateX(24px);
}

.action-btn {
    background: var(--bg-hover);
    border: none;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
    margin-right: 4px;
}
.action-btn:hover { background: #475569; }
.action-btn.danger:hover { background: rgba(239,68,68,0.2); }

.tracking-url {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 11px;
    background: var(--bg-dark);
    padding: 6px 10px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.copy-btn {
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.6;
    font-size: 12px;
}
.copy-btn:hover { opacity: 1; }

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.modal.active { display: flex; }

/* Modal Overlay (for dynamically created modals) */
.modal-overlay {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.modal-overlay .modal {
    display: block;
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease;
}
.modal-overlay .modal-header h3 {
    font-size: 17px;
    font-weight: 600;
    margin: 0;
}
.modal-overlay .modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 17px; font-weight: 600; }
.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 24px; }
.modal-body .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.modal-body .form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

/* Modal Nueva Organización - más ancho para plan custom */
.modal.new-org-modal .modal-content {
    max-width: 680px;
}

/* Toast */
/* Toast Notification — Stitch-inspired design */
.toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: none;
    border-left: 4px solid var(--primary);
    padding: 0;
    border-radius: 12px;
    display: none;
    z-index: 2000;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 8px 24px -4px rgba(25, 28, 30, 0.06), 0 2px 8px rgba(0,0,0,0.04);
    opacity: 0;
    min-width: 340px;
    max-width: 400px;
    overflow: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast.success { border-left-color: #10b981; }
.toast.error   { border-left-color: #ef4444; }
.toast.info    { border-left-color: #3b82f6; }
.toast.warning { border-left-color: #f59e0b; }
.toast.active {
    display: block;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    animation: toastSlideIn 0.35s cubic-bezier(0.21, 1.02, 0.73, 1) forwards;
}
.toast.hiding {
    opacity: 0;
    transform: translateX(-50%) translateY(-16px);
}
.toast-body {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
}
.toast-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.toast-icon svg { width: 20px; height: 20px; }
.toast.success .toast-icon svg { color: #10b981; }
.toast.error .toast-icon svg   { color: #ef4444; }
.toast.info .toast-icon svg    { color: #3b82f6; }
.toast.warning .toast-icon svg { color: #f59e0b; }
.toast-message {
    flex: 1;
    color: var(--text-primary, #191c1e);
    line-height: 1.4;
    font-weight: 500;
}
.toast-close {
    background: none;
    border: none;
    color: var(--text-muted, #94a3b8);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    flex-shrink: 0;
    opacity: 0.4;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}
.toast-close:hover { opacity: 1; background: rgba(0,0,0,0.04); }
.toast-close svg { width: 16px; height: 16px; }
@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* File Upload Area */
.file-upload-area {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 28px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-dark);
}
.file-upload-area:hover {
    border-color: var(--primary);
    background: rgba(59,130,246,0.05);
}

code {
    font-family: 'SF Mono', Monaco, monospace;
    background: var(--bg-dark);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

/* Mobile Header */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: rgba(var(--bg-card-rgb, 255, 255, 255), 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    align-items: center;
    padding: 0 12px;
    gap: 10px;
}
.mobile-header-logo {
    display: none; /* Hidden - only hamburger and title needed */
}
.mobile-header-logo img, .mobile-header-logo svg {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.mobile-header-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mobile Menu Button - Animated Hamburger */
.mobile-menu-btn {
    display: none;
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg-hover);
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.mobile-menu-btn:hover {
    background: var(--bg-card-hover);
}
.mobile-menu-btn:active {
    transform: scale(0.95);
    background: var(--primary);
}

/* Hamburger Icon Lines */
.hamburger-icon {
    width: 20px;
    height: 14px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.hamburger-icon span {
    display: block;
    width: 100%;
    height: 2.5px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.25s ease;
    transform-origin: center;
}

/* Hamburger → X Animation */
.mobile-menu-btn.active .hamburger-icon span:nth-child(1) {
    transform: translateY(5px) rotate(45deg);
}
.mobile-menu-btn.active .hamburger-icon span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}
.mobile-menu-btn.active .hamburger-icon span:nth-child(3) {
    transform: translateY(-5px) rotate(-45deg);
}

/* Sidebar Overlay with Blur */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Responsive - Tablet & Mobile */
@media (max-width: 768px) {
    /* Mobile Header - highest z-index below modals */
    .mobile-header { display: flex; z-index: 101; }
    .mobile-menu-btn { display: flex; }

    /* Sidebar Overlay - behind sidebar, above content */
    .sidebar-overlay { z-index: 150; }
    .sidebar-overlay.active { display: block; }

    /* Sidebar with Glassmorphism - above overlay */
    .sidebar {
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
        background: rgba(var(--bg-secondary-rgb, 22, 22, 30), 0.95);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
    }
    .sidebar.open {
        transform: translateX(0);
    }

    /* Main Content */
    .main-content {
        margin-left: 0;
        padding: 14px;
        padding-top: 60px; /* Space for mobile header */
        min-width: 0; /* Allow flex shrinking below content width */
        max-width: 100vw;
        overflow-x: hidden;
    }
    .page { min-width: 0; max-width: 100%; }
    .info-banner { max-width: 100%; box-sizing: border-box; }
    .info-banner > div, .info-banner > p, .info-banner > strong { min-width: 0; }

    /* Page Header */
    .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .page-header h1 { font-size: 22px; }
    .page-header .header-actions { width: 100%; flex-wrap: wrap; }

    /* Stats Grid - Compact for mobile */
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-icon { width: 38px; height: 38px; }
    .stat-icon svg { width: 18px; height: 18px; }
    .stat-value { font-size: 20px; }
    .stat-label { font-size: 10px; letter-spacing: 0.3px; }

    /* Secondary stats - 3 columns for tablets */
    .stats-grid.secondary-stats {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Forms & Modals - Mobile */
    .modal-body .form-row { grid-template-columns: 1fr; }
    .search-input { width: 100%; }
    .search-input[type="date"] { width: 100%; }

    /* Form groups in modals/pages — compact mobile (covers .form-control too) */
    .form-group { margin-bottom: 10px !important; }
    .form-group label { font-size: 11px !important; margin-bottom: 3px !important; }
    .form-group input, .form-group select, .form-group textarea, .form-control {
        padding: 7px 10px !important;
        font-size: 12px !important;
        border-radius: 6px !important;
    }
    .form-group textarea, textarea.form-control { min-height: 60px !important; }
    .form-group small, .form-hint { font-size: 10px !important; margin-top: 3px !important; line-height: 1.3 !important; }
    .form-row { gap: 8px !important; }

    /* Modal headings + section dividers */
    .modal h2, .modal-overlay h2, .modal-header h2, .modal-header h3 { font-size: 14px !important; }
    .modal h3, .modal-overlay h3, .modal-content h3 { font-size: 13px !important; }
    .modal h4, .modal-overlay h4, .modal-content h4 { font-size: 12px !important; margin: 12px 0 6px !important; }
    .modal h5, .modal h6 { font-size: 11px !important; margin: 8px 0 4px !important; }

    /* Page headers — comprehensive */
    .page-header h1, h1[style*="font-size:24px"], h1[style*="font-size: 24px"] { font-size: 18px !important; }
    .page-subtitle, p.page-subtitle { font-size: 12px !important; margin-top: 2px !important; }

    /* Empty states inside cards & pages */
    .empty-state { padding: 24px 12px !important; }
    .empty-state svg { width: 40px !important; height: 40px !important; }
    .empty-state h3, .empty-state strong { font-size: 14px !important; margin-bottom: 4px !important; }
    .empty-state p { font-size: 12px !important; line-height: 1.4 !important; }

    /* Checkbox / radio labels */
    label.checkbox-label, label[style*="checkbox"] { font-size: 12px !important; }

    /* Autocomplete & select wrappers */
    .autocomplete-wrapper input, .select-filter, .search-input {
        padding: 7px 10px !important;
        font-size: 12px !important;
    }

    /* Sections inside modals with inline borders/backgrounds */
    .modal div[style*="background"][style*="border-radius"] { padding: 10px !important; margin-bottom: 10px !important; }

    /* Inline H4 with style — kill big margins everywhere */
    h4[style*="margin: 20px"] { margin: 10px 0 6px !important; font-size: 12px !important; }
    h3[style*="margin"], h2[style*="margin"] { margin-top: 10px !important; margin-bottom: 6px !important; }

    /* Chart cards & dashboard cards */
    .chart-card, .top-campaigns-card { padding: 14px !important; border-radius: 12px !important; }
    .chart-card h3, .top-campaigns-card h3 { font-size: 13px !important; margin-bottom: 10px !important; }

    /* Settings cards */
    .settings-card, .settings-section { padding: 14px !important; border-radius: 12px !important; }
    .settings-card h3, .settings-section h3 { font-size: 13px !important; }
    .settings-card-header { padding: 12px 14px !important; }

    /* Filter pills general (period selectors etc.) */
    .filter-pills button, .period-selector button { font-size: 11px !important; padding: 4px 9px !important; }

    /* Modal responsive - 768px — compact mobile */
    .modal, .modal-overlay { padding: 10px; }
    .modal-content, .modal-overlay .modal {
        max-width: calc(100vw - 20px);
        border-radius: 12px;
    }
    .modal.new-org-modal .modal-content { max-width: calc(100vw - 20px); }
    .modal-header { padding: 10px 12px; }
    .modal-header h2, .modal-header h3, .modal-overlay .modal-header h3 { font-size: 14px; }
    .modal-close { font-size: 16px; padding: 2px; width: 28px; height: 28px; }
    .modal-body { padding: 12px; }
    .modal-body label { font-size: 11px; margin-bottom: 2px; }
    .modal-body input, .modal-body select, .modal-body textarea { font-size: 12px; padding: 6px 10px; border-radius: 6px; }
    .modal-body textarea { min-height: 60px; }
    .modal-body .form-group { margin-bottom: 8px; }
    .modal-body .form-actions { margin-top: 12px; padding-top: 10px; gap: 6px; }
    .modal-footer, .modal-overlay .modal-footer { padding: 8px 12px; gap: 6px; }
    .modal-footer .btn, .modal-body .form-actions .btn { font-size: 12px; padding: 6px 12px !important; }
    .modal-body hr, .modal-body > div[style*="border-top"] { margin: 10px 0 !important; }
    .modal-body h4, .modal-body h3:not(.modal-header h3) { font-size: 13px; margin: 8px 0 6px; }

    /* Fraud filter bar — compact mobile */
    .fraud-filter-bar {
        padding: 10px !important;
        gap: 6px !important;
        flex-wrap: wrap;
    }
    .fraud-filter-bar #fraud-campaign {
        min-width: 100% !important;
        width: 100%;
        font-size: 12px !important;
        padding: 6px 10px !important;
    }
    .fraud-filter-bar #fraud-date-from,
    .fraud-filter-bar #fraud-date-to {
        flex: 1 1 calc(50% - 3px) !important;
        max-width: calc(50% - 3px) !important;
        min-width: 0 !important;
        font-size: 12px !important;
        padding: 6px 8px !important;
    }
    .fraud-filter-bar .fraud-period-btn {
        font-size: 10px !important;
        padding: 3px 7px !important;
    }

    /* Dashboard Controls */
    .dashboard-controls { flex-direction: column; gap: 12px; width: 100%; }
    .live-controls { flex-wrap: wrap; gap: 8px; }
    .live-freq-selector { display: none; }
    .period-selector { width: 100%; justify-content: space-between; }

    /* Table Responsive */
    .data-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -16px;
        padding: 0 16px;
    }
    .data-table {
        min-width: 600px;
    }
    .data-table th, .data-table td {
        padding: 12px 14px;
        font-size: 13px;
    }
    .data-table th {
        font-size: 10px;
    }

    /* Force conversion summary cards to 2x2 (compact rules apply via generic .stats-grid below) */
    #conversions-summary-cards { grid-template-columns: 1fr 1fr !important; gap: 6px !important; }

    /* My-org usage stats — tighter to avoid long-number wrapping */
    .my-org-stat-item { padding: 12px !important; }
    .my-org-stat-item .stat-icon { width: 32px !important; height: 32px !important; margin-bottom: 8px !important; }
    .my-org-stat-item .stat-icon svg { width: 16px; height: 16px; }
    .my-org-stat-item .stat-value { font-size: 18px !important; line-height: 1.1; }
    .my-org-stat-item .stat-max { font-size: 12px !important; }
    .my-org-stat-item .stat-label { font-size: 11px !important; margin-top: 2px !important; }
    .my-org-stat-item .stat-details { margin-bottom: 8px !important; }

    /* Buttons globally smaller on mobile */
    .btn { padding: 6px 12px !important; font-size: 12px !important; gap: 5px !important; border-radius: 8px !important; line-height: 1.3 !important; min-height: 0; }
    .btn-primary { padding: 6px 14px !important; font-size: 12px !important; }
    .btn-secondary { padding: 5px 12px !important; font-size: 12px !important; }
    .btn svg { width: 12px !important; height: 12px !important; }
}

/* Extra small screens */
@media (max-width: 480px) {
    .mobile-header { height: 44px; padding: 0 10px; gap: 8px; }
    .mobile-header-logo { display: none; }
    .mobile-header-title { font-size: 14px; }
    .mobile-menu-btn { width: 38px; height: 38px; }
    .hamburger-icon { width: 18px; height: 12px; }

    .main-content { padding: 10px; padding-top: 54px; }

    /* Stats Grid - Main stats in 2x2 with vertical layout — ULTRA compact */
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
    .stats-grid:not(.secondary-stats) .stat-card {
        flex-direction: column;
        text-align: center;
        gap: 4px;
        padding: 10px 8px;
        align-items: center;
    }
    .stats-grid:not(.secondary-stats) .stat-card > div:last-child {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
    }
    .stats-grid:not(.secondary-stats) .stat-info {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    .stats-grid:not(.secondary-stats) .stat-icon { width: 30px !important; height: 30px !important; border-radius: 8px !important; }
    .stats-grid:not(.secondary-stats) .stat-icon svg { width: 15px !important; height: 15px !important; }
    .stats-grid:not(.secondary-stats) .stat-value { font-size: 20px !important; line-height: 1 !important; margin: 0 !important; order: 2; }
    .stats-grid:not(.secondary-stats) .stat-label {
        font-size: 9px !important;
        letter-spacing: 0.4px;
        margin: 0 !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
        order: 1;
    }

    /* Secondary stats - 3 columns for CTR, Conversion, EPC */
    .stats-grid.secondary-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    .stats-grid.secondary-stats .stat-card {
        padding: 10px 6px;
        justify-content: center;
    }
    .stats-grid.secondary-stats .stat-card .stat-info {
        align-items: center;
        text-align: center;
    }
    .stats-grid.secondary-stats .stat-value {
        font-size: 16px;
    }
    .stats-grid.secondary-stats .stat-label {
        font-size: 8px;
    }

    .page-header { margin-bottom: 12px; }
    .page-header h1 { font-size: 18px; }
    .period-selector { gap: 4px; }
    .period-selector button { padding: 5px 8px; font-size: 11px; }
    .btn-primary { padding: 8px 14px; font-size: 13px; }
    .table-wrapper { font-size: 12px; }
    /* Modal - Extra compact for 480px */
    .modal, .modal-overlay { padding: 6px; }
    .modal-content, .modal-overlay .modal {
        max-width: calc(100vw - 12px);
        max-height: calc(100vh - 12px);
        border-radius: 10px;
    }
    .modal.new-org-modal .modal-content { max-width: calc(100vw - 12px); }
    .modal-header { padding: 10px 12px; }
    .modal-header h2, .modal-header h3, .modal-overlay .modal-header h3 { font-size: 13px; }
    .modal-close { font-size: 16px; padding: 2px; }
    .modal-body { padding: 10px 12px; }
    .modal-body label { font-size: 10px; margin-bottom: 2px; }
    .modal-body input, .modal-body select, .modal-body textarea {
        font-size: 12px;
        padding: 7px 9px;
        border-radius: 6px;
    }
    .modal-body .form-group { margin-bottom: 8px; }
    .modal-body .form-actions { margin-top: 12px; padding-top: 10px; gap: 6px; }
    .modal-footer, .modal-overlay .modal-footer { padding: 8px 12px; gap: 6px; }
    .modal-footer .btn, .modal-body .form-actions .btn {
        font-size: 11px;
        padding: 6px 10px;
        border-radius: 6px;
    }
}

/* =============================================
   MOBILE IMPROVEMENTS - All Pages
   ============================================= */

/* Tablet (768px) - Header Actions Grid */
@media (max-width: 768px) {
    /* Header actions - wrap into grid */
    .header-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        width: 100%;
    }

    /* Landing-style headers: keep header-actions on the right (override global grid rule above) */
    .landing-header-inner > .header-actions,
    .landing-header > .header-actions {
        display: flex !important;
        width: auto !important;
        grid-template-columns: none !important;
        margin-left: auto !important;
        gap: 8px !important;
    }

    /* Full width for inputs and selects */
    .header-actions .search-input,
    .header-actions .select-filter,
    .header-actions .campaign-search-wrapper {
        width: 100%;
        min-width: 0;
    }

    /* Buttons span full width or half */
    .header-actions .btn {
        justify-content: center;
    }

    .header-actions .btn-primary {
        grid-column: span 2;
    }

    /* Table container with scroll indicator */
    .table-container {
        position: relative;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -10px;
        padding: 0 10px;
    }

    .table-container::after {
        content: '→';
        position: absolute;
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
        background: var(--bg-card);
        padding: 8px;
        border-radius: 50%;
        color: var(--text-muted);
        font-size: 14px;
        opacity: 0.7;
        pointer-events: none;
        animation: scrollHint 1.5s ease-in-out infinite;
    }

    .table-container::-webkit-scrollbar {
        height: 4px;
    }

    @keyframes scrollHint {
        0%, 100% { opacity: 0.4; transform: translateY(-50%) translateX(0); }
        50% { opacity: 0.8; transform: translateY(-50%) translateX(5px); }
    }

    /* Hide scroll hint when scrolled */
    .table-container.scrolled::after {
        display: none;
    }

    /* Data table adjustments */
    .data-table {
        min-width: 600px;
    }

    .data-table th,
    .data-table td {
        padding: 10px 12px;
        font-size: 12px;
        white-space: nowrap;
    }

    .data-table th {
        font-size: 10px;
    }

    /* Status badges smaller */
    .status-badge {
        padding: 3px 8px;
        font-size: 10px;
    }

    /* Action buttons in tables */
    .data-table .btn-icon {
        width: 28px;
        height: 28px;
        padding: 4px;
    }

    .data-table .btn-icon svg {
        width: 14px;
        height: 14px;
    }
}

/* Mobile Small (480px) - Compact Everything */
@media (max-width: 480px) {
    /* Header actions - single column for very small screens */
    .header-actions {
        grid-template-columns: 1fr;
    }

    .header-actions .btn-primary {
        grid-column: span 1;
    }

    /* Search inputs - full width and larger touch target */
    .search-input,
    .select-filter {
        font-size: 14px !important;
        padding: 10px 12px !important;
        min-height: 42px;
    }

    /* Date inputs */
    input[type="date"].search-input {
        font-size: 13px !important;
    }

    /* Buttons - larger touch targets (WCAG 2.5.5: 44x44px) */
    .btn {
        min-height: 44px;
        padding: 12px 14px;
    }

    /* Hide button text on very small screens, show icon only */
    .header-actions .btn span:not(:only-child) {
        display: none;
    }

    .header-actions .btn svg {
        margin: 0;
    }

    /* But keep text for primary action buttons */
    .header-actions .btn-primary span {
        display: inline;
    }

    /* Table improvements */
    .data-table th,
    .data-table td {
        padding: 8px 10px;
        font-size: 11px;
    }

    .data-table th {
        font-size: 9px;
    }

    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        gap: 4px;
        justify-content: center;
    }

    .pagination button {
        min-width: 32px;
        height: 32px;
        font-size: 12px;
    }

    /* Info banners */
    .info-banner {
        flex-direction: column;
        text-align: center;
        gap: 10px !important;
        padding: 14px !important;
        max-width: 100%;
        box-sizing: border-box;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    .info-banner > div:first-child {
        padding: 8px !important;
    }
    .info-banner > div:first-child svg {
        width: 18px !important;
        height: 18px !important;
    }
    .info-banner strong { font-size: 13px !important; line-height: 1.3; }
    .info-banner p { font-size: 12px !important; line-height: 1.4; }
    .info-banner .btn {
        width: 100%;
    }

    /* Campaign search wrapper */
    .campaign-search-wrapper {
        width: 100%;
    }

    /* Select filters */
    .select-filter {
        width: 100%;
        appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 10px center;
        padding-right: 30px !important;
    }
}

/* Extra improvements for specific pages */
@media (max-width: 480px) {
    /* Events page - many filters */
    #page-events .header-actions {
        gap: 6px;
    }

    #page-events .header-actions .search-input[type="date"] {
        grid-column: span 1;
    }

    /* Conversions page */
    #page-conversions .header-actions .select-filter {
        font-size: 12px !important;
    }

    /* Affiliates page - simpler header */
    #page-affiliates .page-header {
        gap: 10px;
    }

    #page-affiliates .btn-primary {
        width: 100%;
    }

    /* Campaign detail - stats cards */
    .campaign-stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    /* My Organization - usage stats */
    .my-org-stats-grid {
        grid-template-columns: 1fr 1fr !important;
    }

    /* Affiliate financial summary cards */
    .financial-summary-grid {
        grid-template-columns: 1fr !important;
    }

    /* Empty states */
    .empty-state {
        padding: 30px 16px;
    }

    .empty-state svg {
        width: 48px;
        height: 48px;
    }

    .empty-state h3 {
        font-size: 16px;
    }

    .empty-state p {
        font-size: 13px;
    }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Auth Toggle & Divider */
.auth-divider {
    display: flex;
    align-items: center;
    margin: 24px 0;
    color: var(--text-muted);
    font-size: 12px;
}
.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
.auth-divider span {
    padding: 0 16px;
}

.btn-google {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    background: white;
    color: #333;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-google:hover {
    background: #f5f5f5;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.auth-toggle {
    text-align: center;
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-muted);
}
.auth-toggle a {
    color: var(--primary);
    text-decoration: none;
    margin-left: 4px;
}
.auth-toggle a:hover {
    text-decoration: underline;
}

/* Sidebar Actions */
.sidebar-actions {
    display: flex;
    gap: 8px;
}

.btn-settings {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-settings:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Settings Modal */
#settings-modal .modal-content {
    max-height: 90vh;
    overflow-y: auto;
}

.settings-section {
    padding: 20px 0;
    border-bottom: 1px solid var(--border);
}
.settings-section:last-child {
    border-bottom: none;
}
.settings-section h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* Domains List */
.domains-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.domain-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.domain-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.domain-url {
    font-family: monospace;
    font-size: 13px;
    color: var(--text-primary);
}
.domain-badges {
    display: flex;
    gap: 6px;
}
.domain-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}
.domain-badge.default {
    background: var(--primary);
    color: white;
}
.domain-badge.system {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

/* Text muted utility */
.text-muted {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 12px;
}

.org-header {
    transition: background-color 0.2s;
}

.org-header:hover {
    background: var(--bg-hover) !important;
}

.org-header.expanded {
    border-bottom: 1px solid var(--border);
}

.org-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.org-content {
    animation: slideDown 0.15s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.users-tree-controls {
    display: flex;
    gap: 8px;
}

.users-tree-controls .btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* =============================================
   PARCHE: Estilos para sección de dominios (cliente enterprise)
   Añadir a styles.css
   ============================================= */

/* Domain request section */
.domain-request-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.domain-request-section .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.domain-request-section p {
    color: var(--text-muted);
    font-size: 11px;
    margin-top: 8px;
    text-align: center;
}

.domain-item:last-child {
    border-bottom: none;
}


.domain-badge.default {
    background: var(--primary);
    color: white;
}

.domain-badge.system {
    background: var(--bg-dark);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* Info text for admin */
.domains-info-admin {
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 12px;
    padding: 12px;
    background: var(--bg-dark);
    border-radius: 8px;
    border-left: 3px solid var(--primary);
}

/* Hide add domain button for non-superadmin */
body:not(.is-superadmin) .btn-add-domain,
body:not(.is-superadmin) #btn-add-domain,
body:not(.is-superadmin) [onclick="showAddDomainModal()"] {
    display: none !important;
}

/* =============================================
   CONVERSIONES AGRUPADAS - ESTILOS
   Añadir al final de styles.css
   ============================================= */

/* Vista agrupada para afiliados */
.conversions-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
}

.summary-card .value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.summary-card .label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Grupo de campaña */
.campaign-group {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
}

.campaign-group-header {
    padding: 16px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.15s;
}

.campaign-group-header:hover {
    background: var(--bg-hover);
}

.campaign-group-chevron {
    transition: transform 0.2s;
}

.campaign-group-chevron.expanded {
    transform: rotate(90deg);
}

.campaign-group-details {
    border-top: 1px solid var(--border);
    background: var(--bg-dark);
    padding: 16px;
}

/* Badge de estado pequeño */
.status-badge.status-pending {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.status-badge.status-approved {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.status-badge.status-rejected {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* Botones de filtro pequeños */
.btn-sm {
    padding: 4px 12px;
    font-size: 12px;
}

/* Loading spinner */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Visibilidad condicional */
.affiliate-only {
    display: none;
}

/* Cuando el usuario es afiliado */
body.is-affiliate .affiliate-only {
    display: block;
}

body.is-affiliate .admin-only {
    display: none !important;
}

body.is-affiliate .nav-section-header[data-section="account"] {
    display: none;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state svg {
    opacity: 0.35;
    margin-bottom: 16px;
}
.empty-state h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px;
}
.empty-state p {
    font-size: 13px;
    margin: 0 0 20px;
    max-width: 340px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
}

/* Skeleton loading */
.skeleton {
    background: var(--bg-hover);
    border-radius: 6px;
    position: relative;
    overflow: hidden;
}
.skeleton::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent);
    animation: skeleton-shimmer 1.5s infinite;
}
@keyframes skeleton-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}
[data-theme="light"] .skeleton::after {
    background: linear-gradient(90deg, transparent, rgba(0,0,0,0.04), transparent);
}

/* Form validation */
.form-group.has-error input,
.form-group.has-error select,
.form-group.has-error textarea {
    border-color: var(--danger) !important;
}
.form-group .field-error {
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
    display: block;
}
.form-group.has-success input {
    border-color: var(--success) !important;
}

/* Usage Card Large - Versión con estilo de card */
.usage-card-large {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
}

.usage-card-large h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 24px 0;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

/* Usage Item Large */
.usage-item-large {
    margin-bottom: 20px;
}

.usage-item-large:last-child {
    margin-bottom: 0;
}

/* Usage Bar Large */
.usage-bar-large {
    height: 10px;
    background: var(--bg-dark);
    border-radius: 5px;
    overflow: hidden;
}

/* Plan Price Large */
.plan-price-large {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.plan-price-large .price-amount {
    font-size: 42px;
    font-weight: 700;
    color: var(--primary);
}

.plan-price-large .price-period {
    font-size: 16px;
    color: var(--text-muted);
}

/* Features Section */
.features-section {
    margin-top: 24px;
}

.features-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 16px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.features-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.features-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    font-size: 14px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.features-list li:last-child {
    border-bottom: none;
}

/* =============================================
   ESTILOS CORREGIDOS PARA CAMPAIGN DETAIL PAGE
   Añadir a components.css o styles.css
   ============================================= */

/* Campaign Detail Cards */
.campaign-detail-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.campaign-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    min-height: 48px;
}

.campaign-card-header h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
}
.campaign-card-header h3 svg {
    flex-shrink: 0;
    opacity: 0.6;
}

/* Standardize all action buttons inside card headers */
.campaign-card-header .btn,
.campaign-card-header .btn-sm,
.campaign-card-header .btn-primary,
.campaign-card-header .btn-secondary {
    font-size: 11px !important;
    padding: 4px 10px !important;
    border-radius: 6px !important;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Help buttons (?) in card headers */
.campaign-card-header button[onclick*="Help"] {
    width: 22px !important;
    height: 22px !important;
    flex-shrink: 0;
}

/* Switch/toggle inside headers */
.campaign-card-header .switch {
    flex-shrink: 0;
    transform: scale(0.85);
}

/* PRO badges in headers */
.campaign-card-header .pro-badge,
.campaign-card-header .upgrade-badge {
    font-size: 9px !important;
    padding: 1px 5px !important;
    flex-shrink: 0;
}

.campaign-card-body {
    padding: 16px;
    transition: max-height 0.25s ease, opacity 0.2s ease, padding 0.25s ease;
    overflow: hidden;
    flex: 1;
}

/* Campaign detail tab grids */
.cd-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 20px;
    align-items: start;
}
.cd-grid > .campaign-detail-card {
    margin-top: 0 !important;
}
#cd-tab-general {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 20px;
    align-items: start;
}
@media (max-width: 900px) {
    .cd-grid, #cd-tab-general {
        grid-template-columns: 1fr;
    }
}

/* Collapsible sections */
.campaign-card-header.collapsible {
    cursor: pointer;
    user-select: none;
}
.campaign-card-header.collapsible:hover {
    background: var(--bg-hover);
}
.collapse-chevron {
    margin-left: 4px;
    transition: transform 0.25s ease;
    flex-shrink: 0;
    opacity: 0.3;
}
.campaign-card-header.collapsible:hover .collapse-chevron {
    opacity: 0.6;
}
.campaign-detail-card.collapsed .campaign-card-body {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}
.campaign-detail-card.collapsed .campaign-card-header {
    border-bottom-color: transparent;
}
.campaign-detail-card.collapsed .collapse-chevron {
    transform: rotate(-90deg);
}

/* HTML card body - para que el iframe ocupe todo */
.campaign-content-grid > .campaign-detail-card:first-child .campaign-card-body {
    position: relative;
    padding: 0;
    overflow: hidden;
}

/* Campaign Content Grid - 60% HTML, 40% Tracking */
.campaign-content-grid {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 24px;
    margin-top: 24px;
}

@media (max-width: 1100px) {
    .campaign-content-grid {
        grid-template-columns: 1fr;
    }
}

/* Campaign detail tabs */
.cd-tab.active {
    color: var(--primary) !important;
    border-bottom-color: var(--primary) !important;
}
.cd-tab:hover {
    color: var(--text-primary) !important;
}
@media (max-width: 900px) {
    .cd-tab-content > div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
    #cd-tab-general {
        grid-template-columns: 1fr !important;
    }
}

/* HTML Preview Container */
.html-preview-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    overflow: hidden;
}

.html-preview-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Empty HTML State */
.empty-html-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-muted);
}

.empty-html-state svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-html-state p {
    margin: 0 0 20px 0;
}

/* Detail Tabs - Mejor estilo */
.detail-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-dark);
    border-radius: 10px;
    margin-bottom: 20px;
}

.detail-tab {
    flex: 1;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.detail-tab:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.05);
}

.detail-tab.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* Tracking Info Section */
.tracking-info-section {
    margin-bottom: 20px;
}

.tracking-info-section:last-child {
    margin-bottom: 0;
}

.tracking-info-section h4 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin: 0 0 12px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Code Block - Mejor estilo */
.code-block {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    position: relative;
    margin-bottom: 12px;
}

.code-block:last-child {
    margin-bottom: 0;
}

.code-block code {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 12px;
    color: var(--text-primary);
    word-break: break-all;
    line-height: 1.6;
    display: block;
    padding-right: 70px;
}

.code-block .code-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    display: block;
}

.code-block .copy-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
}

.code-block .copy-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Info Note - Mejor estilo */
.info-note {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-top: 16px;
}

.info-note svg {
    flex-shrink: 0;
    color: var(--primary);
    margin-top: 2px;
}

/* Variables Table */
.variables-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: var(--bg-dark);
    border-radius: 8px;
    overflow: hidden;
}

.variables-table th,
.variables-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.variables-table th {
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-hover);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.variables-table td code {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 12px;
    background: rgba(99, 102, 241, 0.15);
    padding: 3px 8px;
    border-radius: 4px;
    color: var(--primary);
}

.variables-table tr:last-child td {
    border-bottom: none;
}

.variables-table tr:hover {
    background: rgba(255,255,255,0.02);
}

/* =============================================
   CSS ADICIONAL PARA CAMPOS DE FORMULARIO
   Añadir a frontend/styles.css o frontend/components.css
   ============================================= */

/* Hint text bajo los campos de formulario */
.form-hint {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.4;
}

/* Estilo para el campo de VAT/Tax ID */
#reg-tax-id {
    font-family: monospace;
}

/* Validación visual del campo tax_id */
#reg-tax-id:valid:not(:placeholder-shown) {
    border-color: var(--success);
}

#reg-tax-id.invalid {
    border-color: var(--danger);
}

/* Icono de estado de validación */
.tax-id-status {
    display: inline-block;
    margin-left: 8px;
    font-size: 14px;
}

.tax-id-status.valid::after {
    content: '✓';
    color: var(--success);
}

.tax-id-status.invalid::after {
    content: '✗';
    color: var(--danger);
}

/* Mejoras para la sección de billing en plan details */
.billing-section {
    margin-top: 32px;
}

.billing-info-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
}

.billing-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

@media (max-width: 768px) {
    .billing-info-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

.billing-info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.billing-info-item label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.billing-info-item span,
.billing-info-item .payment-method-display {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

.no-payment-method {
    color: var(--text-muted);
    font-style: italic;
}


/* =============================================
   PLAN STYLES - Estilos para nuevos planes
   Agregar al final de styles.css o components.css
   ============================================= */

/* Plan Overview Card */
.plan-overview-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
}

.plan-header-section {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.plan-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
}

.plan-icon-free { background: linear-gradient(135deg, #6b7280 0%, #374151 100%); }
.plan-icon-starter { background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%); }
.plan-icon-professional { background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%); }
.plan-icon-enterprise { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }
.plan-icon-custom { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }

.plan-header-info {
    flex: 1;
    min-width: 200px;
}

.plan-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.plan-name {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.plan-status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.plan-status-badge.active {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.plan-price-row {
    margin-top: 8px;
}

.plan-price {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
}

.plan-period {
    font-size: 16px;
    color: var(--text-muted);
}

.plan-billing-date {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Usage Section */
.usage-section {
    margin-bottom: 24px;
}

.usage-section h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.usage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.usage-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}

.usage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.usage-label {
    font-size: 14px;
    color: var(--text-muted);
}

.usage-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.usage-bar {
    height: 6px;
    background: var(--bg-dark);
    border-radius: 3px;
    overflow: hidden;
}

.usage-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.usage-bar-fill.warning {
    background: #f59e0b;
}

.usage-bar-fill.critical {
    background: #ef4444;
}

/* Plan Features List */
.plan-features-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
}

.plan-features-section h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.plan-features-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.plan-features-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-secondary);
}

/* Pending Downgrade Banner */
.pending-downgrade-banner {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.pending-icon {
    font-size: 24px;
}

.pending-content {
    flex: 1;
    min-width: 200px;
}

.pending-content strong {
    color: #f59e0b;
    display: block;
    margin-bottom: 4px;
}

.pending-content p {
    color: var(--text-secondary);
    margin: 0;
    font-size: 14px;
}

/* Change Plan Page */
.change-plan-header {
    margin-bottom: 24px;
}

.change-plan-header h2 {
    margin: 16px 0 0;
    font-size: 24px;
    font-weight: 600;
}

.plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.plan-option-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    position: relative;
    transition: all 0.2s;
}

.plan-option-card:hover {
    border-color: var(--primary);
}

.plan-option-card.current {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.05);
}

.plan-option-card.popular {
    border-color: var(--primary);
}

.popular-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    padding: 4px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.plan-option-header {
    text-align: center;
    margin-bottom: 20px;
}

.plan-option-header h3 {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 8px;
}

.plan-option-price {
    margin-top: 12px;
}

.plan-option-price .price {
    font-size: 36px;
    font-weight: 700;
    color: var(--text-primary);
}

.plan-option-price .period {
    font-size: 14px;
    color: var(--text-muted);
}

.plan-option-features {
    list-style: none;
    padding: 0;
    margin: 0 0 20px;
}

.plan-option-features li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.plan-option-features li:last-child {
    border-bottom: none;
}

.btn-full {
    width: 100%;
}

/* Downgrade Selection */
.downgrade-selection-page {
    max-width: 800px;
}

.downgrade-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 24px;
}

.warning-icon {
    font-size: 24px;
}

.warning-content strong {
    color: #f59e0b;
    display: block;
    margin-bottom: 4px;
}

.warning-content p {
    color: var(--text-secondary);
    margin: 0;
    font-size: 14px;
}

.selection-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
}

.selection-section h4 {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 8px;
}

.selection-hint {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.resource-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.resource-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-dark);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.resource-item:hover {
    background: rgba(99, 102, 241, 0.1);
}

.resource-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.resource-item input[type="checkbox"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.resource-name {
    font-size: 14px;
    color: var(--text-primary);
}

.resource-code {
    color: var(--text-muted);
    font-size: 12px;
}

.selection-counter {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-muted);
    text-align: right;
}

.downgrade-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* Pricing Grid - Landing Page */
.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 40px;
}

/* Event Limit Alert */
.event-limit-alert {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.event-limit-alert .alert-icon {
    font-size: 24px;
    color: #ef4444;
}

.event-limit-alert .alert-content {
    flex: 1;
}

.event-limit-alert .alert-content strong {
    color: #ef4444;
    display: block;
    margin-bottom: 4px;
}

.event-limit-alert .alert-content p {
    color: var(--text-secondary);
    margin: 0;
    font-size: 14px;
}

/* Custom Domain Not Available Notice */
.custom-domain-notice {
    background: rgba(107, 114, 128, 0.1);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.custom-domain-notice .notice-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.custom-domain-notice h4 {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 8px;
}

.custom-domain-notice p {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0 0 16px;
}

/* ==================== PLAN SELECTION BANNER ==================== */
/* Modern banner shown when user selects FREE plan for registration */
.plan-selection-banner {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(139, 92, 246, 0.05));
    backdrop-filter: blur(10px);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 16px;
    padding: 20px 24px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2), 0 0 30px rgba(59, 130, 246, 0.1);
    transition: all 0.3s ease;
}

.plan-selection-banner:hover {
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 15px 20px -3px rgba(0, 0, 0, 0.3), 0 0 40px rgba(59, 130, 246, 0.15);
    transform: translateY(-2px);
}

.plan-selection-banner .plan-info {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
}

.plan-selection-banner .plan-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.4);
}

.plan-selection-banner .plan-icon svg {
    color: white;
}

.plan-selection-banner .plan-details {
    flex: 1;
}

.plan-selection-banner .plan-details h4 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 4px 0;
    background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.plan-selection-banner .plan-details p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
    font-weight: 600;
}

.plan-selection-banner .btn-change {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.2);
    color: var(--text-primary);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.plan-selection-banner .btn-change:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--primary);
    color: var(--primary);
    transform: scale(1.05);
}

/* Plan-specific styling */
/* Free plan */
.plan-selection-banner.plan-free .plan-icon {
    background: linear-gradient(135deg, #6b7280 0%, #374151 100%);
    box-shadow: 0 4px 6px -1px rgba(107, 114, 128, 0.4);
}

.plan-selection-banner.plan-free {
    background: linear-gradient(135deg, rgba(107, 114, 128, 0.1), rgba(55, 65, 81, 0.05));
    border-color: rgba(107, 114, 128, 0.3);
}

.plan-selection-banner.plan-free:hover {
    border-color: rgba(107, 114, 128, 0.5);
    box-shadow: 0 15px 20px -3px rgba(0, 0, 0, 0.3), 0 0 40px rgba(107, 114, 128, 0.15);
}

/* Starter plan */
.plan-selection-banner.plan-starter .plan-icon {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.4);
}

.plan-selection-banner.plan-starter {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(37, 99, 235, 0.05));
    border-color: rgba(59, 130, 246, 0.3);
}

.plan-selection-banner.plan-starter:hover {
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 15px 20px -3px rgba(0, 0, 0, 0.3), 0 0 40px rgba(59, 130, 246, 0.15);
}

/* Professional plan */
.plan-selection-banner.plan-professional .plan-icon {
    background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
    box-shadow: 0 4px 6px -1px rgba(139, 92, 246, 0.4);
}

.plan-selection-banner.plan-professional {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(109, 40, 217, 0.05));
    border-color: rgba(139, 92, 246, 0.3);
}

.plan-selection-banner.plan-professional:hover {
    border-color: rgba(139, 92, 246, 0.5);
    box-shadow: 0 15px 20px -3px rgba(0, 0, 0, 0.3), 0 0 40px rgba(139, 92, 246, 0.15);
}

/* Enterprise plan */
.plan-selection-banner.plan-enterprise .plan-icon {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    box-shadow: 0 4px 6px -1px rgba(245, 158, 11, 0.4);
}

.plan-selection-banner.plan-enterprise {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(217, 119, 6, 0.05));
    border-color: rgba(245, 158, 11, 0.3);
}

.plan-selection-banner.plan-enterprise:hover {
    border-color: rgba(245, 158, 11, 0.5);
    box-shadow: 0 15px 20px -3px rgba(0, 0, 0, 0.3), 0 0 40px rgba(245, 158, 11, 0.15);
}

/* Custom plan */
.plan-selection-banner.plan-custom .plan-icon {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.4);
}

.plan-selection-banner.plan-custom {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(5, 150, 105, 0.05));
    border-color: rgba(16, 185, 129, 0.3);
}

.plan-selection-banner.plan-custom:hover {
    border-color: rgba(16, 185, 129, 0.5);
    box-shadow: 0 15px 20px -3px rgba(0, 0, 0, 0.3), 0 0 40px rgba(16, 185, 129, 0.15);
}

/* Responsive for mobile */
@media (max-width: 600px) {
    .plan-selection-banner {
        flex-direction: column;
        text-align: center;
        padding: 20px;
    }

    .plan-selection-banner .plan-info {
        flex-direction: column;
        text-align: center;
    }

    .plan-selection-banner .btn-change {
        width: 100%;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .plan-header-section {
        flex-direction: column;
        text-align: center;
    }

    .plan-header-section .btn {
        width: 100%;
    }

    .plans-grid {
        grid-template-columns: 1fr;
    }

    .pending-downgrade-banner {
        flex-direction: column;
        text-align: center;
    }

    .downgrade-actions {
        flex-direction: column;
    }

    .downgrade-actions .btn {
        width: 100%;
    }
}

/* =============================================
   SETTINGS PAGE - Modern Design
   ============================================= */

.settings-page-content {
    max-width: 900px;
    margin: 0 auto;
}

.settings-page-content .btn-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 28px;
}

.settings-page-content .btn-back:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--primary);
}

/* Settings Grid Layout */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

@media (max-width: 800px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

/* Settings Card - Modern Style */
.settings-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.settings-card:hover {
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.settings-card.full-width {
    grid-column: 1 / -1;
}

.settings-card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(255,255,255,0.02) 0%, transparent 100%);
}

.settings-card-header-with-icon {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.settings-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(139, 92, 246, 0.1));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.settings-card-icon svg {
    stroke: var(--primary);
}

.settings-card-icon.danger {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.1));
}

.settings-card-icon.danger svg {
    stroke: var(--danger);
}

.settings-card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 4px 0;
}

.settings-card-header .text-muted {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}

.settings-card-body {
    padding: 24px;
}

.settings-card-body .form-group {
    margin-bottom: 20px;
}

.settings-card-body .form-group:last-of-type {
    margin-bottom: 24px;
}

.settings-card-body .form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.settings-card-body .form-control {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.2s;
}

.settings-card-body .form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.settings-card-body .form-control:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: rgba(15, 23, 42, 0.5);
}

.settings-card-body .btn {
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 10px;
}

/* Danger Zone Card */
.settings-card.danger-zone {
    border-color: rgba(239, 68, 68, 0.3);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.02), transparent);
}

.settings-card.danger-zone:hover {
    border-color: rgba(239, 68, 68, 0.5);
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.1);
}

/* Section Divider */
.settings-section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 32px 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.settings-section-title:first-of-type {
    margin-top: 0;
}

/* Domain Item in Settings */
.settings-card .domain-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 10px;
}

.settings-card .domain-item:last-child {
    margin-bottom: 0;
}

.settings-card .domain-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.settings-card .domain-name {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 13px;
    color: var(--text-primary);
}

/* Responsive for Settings Page */
@media (max-width: 600px) {
    .settings-page-content {
        padding: 0;
    }

    .settings-card-header {
        padding: 16px 20px;
    }

    .settings-card-body {
        padding: 20px;
    }

    .settings-card-icon {
        width: 40px;
        height: 40px;
    }
}

/* =============================================
   AUTOCOMPLETE COMPONENT
   ============================================= */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.autocomplete-list.show {
    display: block;
}

.autocomplete-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary);
    transition: background 0.15s;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background: var(--primary-light, #f0ebff);
    color: var(--primary);
}

.autocomplete-item.new-item {
    color: var(--success);
    font-weight: 500;
    border-top: 1px solid var(--border);
}

.autocomplete-item.new-item:hover {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

/* ==========================================
   SYSTEM ALERTS
   ========================================== */

.system-alerts-container {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.system-alert {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    font-size: 13px;
    font-weight: 500;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.system-alert-info {
    background: #fef3c7;
    border-bottom: 1px solid #f59e0b;
    color: #92400e;
}

.system-alert-warning {
    background: #fed7aa;
    border-bottom: 1px solid #ea580c;
    color: #9a3412;
}

.system-alert-critical {
    background: #fecaca;
    border-bottom: 1px solid #ef4444;
    color: #991b1b;
}

.system-alert .alert-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.system-alert .alert-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.system-alert .alert-message {
    line-height: 1.4;
}

.system-alert .alert-dismiss {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.7;
    transition: opacity 0.2s;
    color: inherit;
    line-height: 1;
}

.system-alert .alert-dismiss:hover {
    opacity: 1;
}

/* Adjust main content when alerts are present */
.has-system-alerts .main-content {
    padding-top: calc(20px + var(--alerts-height, 0px));
}

/* Alert type badges in management page */
.alert-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.alert-type-badge.type-info {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.alert-type-badge.type-warning {
    background: rgba(234, 88, 12, 0.15);
    color: #ea580c;
}

.alert-type-badge.type-critical {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* Status toggle in alerts table */
.alert-status-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.alert-status-toggle .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.alert-status-toggle .status-dot.active {
    background: var(--success);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.alert-status-toggle .status-dot.inactive {
    background: var(--text-muted);
}

/* Alert form in modal */
.alert-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Translations accordion */
.translations-accordion {
    margin-top: 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-dark);
}

.translations-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    list-style: none;
    user-select: none;
}

.translations-toggle::-webkit-details-marker {
    display: none;
}

.translations-toggle .chevron-icon {
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.translations-accordion[open] .chevron-icon {
    transform: rotate(180deg);
}

.translations-toggle:hover {
    color: var(--text-primary);
}

.translations-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 0 16px 16px;
}

.translations-grid .translation-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.translations-grid .translation-field label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
}

.translations-grid .translation-field .flag-icon {
    font-size: 14px;
}

.translations-grid .translation-field input {
    padding: 8px 10px;
    font-size: 13px;
}

@media (max-width: 600px) {
    .translations-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Responsive: hide sidebar offset on mobile */
@media (max-width: 768px) {
    .system-alerts-container {
        left: 0;
    }
}

/* =====================================================
   LIVE DASHBOARD UPDATES
   ===================================================== */

.dashboard-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.live-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    background: var(--bg-dark);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    transition: all 0.3s ease;
}

.live-indicator.live-active {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: all 0.3s ease;
}

.live-indicator.live-active .live-dot {
    background: #22c55e;
    box-shadow: 0 0 8px #22c55e;
    animation: live-pulse 1.5s ease-in-out infinite;
}

@keyframes live-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.7;
    }
}

.live-text {
    display: inline-block;
}

.live-time {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 400;
    margin-left: 4px;
}

.live-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.live-toggle-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.live-toggle-btn.active {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.live-toggle-btn.active svg {
    fill: currentColor;
}

.live-freq-selector {
    display: flex;
    gap: 2px;
    padding: 2px;
    background: var(--bg-card);
    border-radius: 6px;
}

.live-freq-btn {
    padding: 4px 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.live-freq-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.live-freq-btn.active {
    background: var(--primary);
    color: white;
}

/* Stat Card Animations */
.stat-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card.stat-updating {
    animation: stat-highlight 0.8s ease;
}

.stat-card.stat-increased {
    animation: stat-increase-pulse 0.8s ease;
}

@keyframes stat-highlight {
    0% {
        transform: scale(1);
    }
    30% {
        transform: scale(1.02);
        box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes stat-increase-pulse {
    0% {
        transform: scale(1);
    }
    30% {
        transform: scale(1.03);
        box-shadow: 0 0 25px rgba(34, 197, 94, 0.4);
    }
    100% {
        transform: scale(1);
    }
}

.stat-value {
    transition: color 0.3s ease;
}

.stat-card.stat-increased .stat-value {
    color: #22c55e !important;
}

/* Responsive adjustments for live controls */
@media (max-width: 768px) {
    .dashboard-controls {
        flex-direction: column;
        align-items: flex-end;
        gap: 8px;
    }

    .live-controls {
        order: 2;
    }

    .live-freq-selector {
        display: none;
    }
}

@media (max-width: 480px) {
    .live-text {
        display: none;
    }

    .live-time {
        display: none;
    }
}

/* =============================================
   THEME TOGGLE COMPONENT
   ============================================= */

.theme-toggle-container {
    display: flex;
    gap: 12px;
}

.theme-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 16px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.theme-option:hover {
    border-color: var(--primary);
    background: var(--bg-card-hover);
}

.theme-option.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.theme-option.active .theme-icon {
    background: var(--gradient-primary);
    color: white;
}

.theme-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.theme-icon svg {
    stroke: currentColor;
}

.theme-option span {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Light theme specific adjustments */
[data-theme="light"] .sidebar {
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .stat-card {
    box-shadow: var(--shadow-sm);
}

[data-theme="light"] .data-table {
    box-shadow: var(--shadow-sm);
}

[data-theme="light"] .chart-card,
[data-theme="light"] .top-campaigns-card {
    box-shadow: var(--shadow-sm);
}

[data-theme="light"] .btn-primary {
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

[data-theme="light"] .modal-content {
    box-shadow: var(--shadow-xl);
}

[data-theme="light"] .nav-item.active {
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Light mode: Plan selection banner in signup */
[data-theme="light"] .plan-selection-banner {
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
}

[data-theme="light"] .plan-selection-banner:hover {
    box-shadow: var(--shadow-lg);
}

[data-theme="light"] .plan-selection-banner .plan-details h4 {
    background: none;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: var(--text-primary);
    color: var(--text-primary);
}

[data-theme="light"] .plan-selection-banner .btn-change {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
}

[data-theme="light"] .plan-selection-banner .btn-change:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary);
    color: var(--primary);
}

/* Light mode plan-specific backgrounds */
[data-theme="light"] .plan-selection-banner.plan-free {
    background: linear-gradient(135deg, rgba(107, 114, 128, 0.08), rgba(55, 65, 81, 0.04));
    border-color: rgba(107, 114, 128, 0.25);
}

[data-theme="light"] .plan-selection-banner.plan-starter {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(37, 99, 235, 0.04));
    border-color: rgba(59, 130, 246, 0.25);
}

[data-theme="light"] .plan-selection-banner.plan-professional {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08), rgba(109, 40, 217, 0.04));
    border-color: rgba(139, 92, 246, 0.25);
}

[data-theme="light"] .plan-selection-banner.plan-enterprise {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(217, 119, 6, 0.04));
    border-color: rgba(245, 158, 11, 0.25);
}

/* Logo image in sidebar */
.sidebar-header .logo-small svg {
    display: block;
}

.sidebar-header .logo-small img {
    display: none;
}

.sidebar-header.has-logo .logo-small svg {
    display: none;
}

.sidebar-header.has-logo .logo-small img {
    display: block;
}

/* =============================================
   PAYMENT REQUIRED BANNER
   ============================================= */
.payment-required-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    border-radius: var(--radius-md);
    margin: 16px 24px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.payment-required-banner.warning {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15) 0%, rgba(245, 158, 11, 0.1) 100%);
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.payment-required-banner.warning .banner-icon {
    color: var(--warning);
}

.payment-required-banner.urgent {
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.15) 0%, rgba(234, 88, 12, 0.1) 100%);
    border: 1px solid rgba(249, 115, 22, 0.3);
}

.payment-required-banner.urgent .banner-icon {
    color: #f97316;
}

.payment-required-banner.expired {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15) 0%, rgba(220, 38, 38, 0.1) 100%);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.payment-required-banner.expired .banner-icon {
    color: var(--danger);
}

.payment-required-banner .banner-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.payment-required-banner .banner-content {
    flex: 1;
}

.payment-required-banner .banner-title {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.payment-required-banner .banner-message {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.4;
}

.payment-required-banner .banner-action {
    flex-shrink: 0;
    white-space: nowrap;
}

/* Responsive */
@media (max-width: 768px) {
    .payment-required-banner {
        flex-direction: column;
        text-align: center;
        margin: 12px 16px;
        padding: 16px;
    }

    .payment-required-banner .banner-icon {
        margin-bottom: 8px;
    }

    .payment-required-banner .banner-action {
        margin-top: 12px;
        width: 100%;
    }
}

/* =============================================
   GUIDES MODAL (from settings-page.css)
   ============================================= */
.guides-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.guides-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.guides-modal {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 1000px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.95);
    transition: transform 0.3s;
}

.guides-modal-overlay.active .guides-modal {
    transform: scale(1);
}

.guides-modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.guides-modal-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.guides-modal-close {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.guides-modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.guides-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.guides-filter-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.guides-filter-tab {
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.guides-filter-tab:hover,
.guides-filter-tab.active {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

.guides-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.guide-list-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 20px;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
}

.guide-list-item:hover {
    border-color: var(--primary);
}

.guide-list-item h3 {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 6px 0;
}

.guide-list-item p {
    color: var(--text-secondary);
    font-size: 13px;
    margin: 0 0 12px 0;
    line-height: 1.5;
}

.guide-list-meta {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--text-muted);
}

.guide-list-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.guide-tag {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    background: #3b82f6;
    color: white;
}

.guide-tag.intermediate {
    background: #f59e0b;
}

.guide-tag.advanced {
    background: #ef4444;
}

/* Expanded Guide in Modal */
.guide-expanded {
    animation: guideExpandIn 0.3s ease-out;
}

@keyframes guideExpandIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.guide-expanded-header {
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    padding: 40px;
    border-radius: 12px;
    margin-bottom: 24px;
    position: relative;
}

.guide-expanded-header.intermediate {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.guide-expanded-header.advanced {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.guide-expanded-back {
    position: absolute;
    top: 16px;
    left: 16px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.guide-expanded-back:hover {
    background: rgba(255, 255, 255, 0.3);
}

.guide-expanded-level {
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.guide-expanded-title {
    color: white;
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 12px 0;
}

.guide-expanded-meta {
    display: flex;
    gap: 20px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
}

.guide-expanded-content {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.8;
}

.guide-expanded-content h3 {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
    margin: 28px 0 12px 0;
}

.guide-expanded-content h3:first-child {
    margin-top: 0;
}

.guide-expanded-content ul,
.guide-expanded-content ol {
    margin-left: 24px;
    margin-bottom: 20px;
}

.guide-expanded-content li {
    margin-bottom: 8px;
}

.guide-expanded-content code {
    background: var(--bg-secondary);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 13px;
    color: var(--primary);
}

.guide-expanded-content pre {
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 20px;
}

.guide-expanded-content pre code {
    padding: 0;
    background: none;
}

.guide-tip-box {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 20px;
}

.guide-tip-box.warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
}

.guide-tip-box-title {
    color: var(--primary);
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.guide-tip-box.warning .guide-tip-box-title {
    color: #f59e0b;
}

.guide-tip-box p {
    margin: 0;
    font-size: 13px;
}

/* =============================================
   HELP TOOLTIPS
   ============================================= */
.help-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.help-tooltip .tooltip-text {
    visibility: hidden;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: normal;
    max-width: 260px;
    min-width: 160px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    line-height: 1.5;
    text-align: left;
    font-weight: 400;
}
.help-tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}
.help-tooltip .tooltip-text::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--border);
}

/* =============================================
   CAMPAIGN SECTION NAVIGATION
   ============================================= */
.campaign-section-nav {
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.section-nav-item {
    padding: 6px 12px;
    font-size: 11px;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
    border-left: 2px solid transparent;
    transition: all 0.15s ease;
    display: block;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.section-nav-item:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}
.section-nav-item.active {
    color: var(--primary);
    border-left-color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
    font-weight: 600;
}
.section-nav-item.is-collapsed {
    opacity: 0.5;
    font-style: italic;
}
@media (max-width: 1400px) {
    .campaign-section-nav {
        display: none;
    }
}

/* ============================================
   A11y: focus indicator + touch targets
   ============================================ */
button:focus-visible,
[role="switch"]:focus-visible,
.action-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* WCAG 2.5.5 — touch target mínimo 44x44 en .action-btn (iconos en tablas) */
.action-btn {
    min-height: 36px;
    min-width: 36px;
}
@media (max-width: 768px) {
    .action-btn {
        min-height: 44px;
        min-width: 44px;
    }
}

/* ============================================
   Skip-link a11y (WCAG 2.4.1 Bypass Blocks)
   ============================================ */
.skip-link {
    position: absolute;
    top: -48px;
    left: 0;
    background: var(--primary);
    color: white;
    padding: 10px 20px;
    z-index: 10000;
    border-radius: 0 0 8px 0;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: top 0.2s ease;
}
.skip-link:focus {
    top: 0;
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}
