/* ============================================
   TARGETO.PRO - Clean Professional Design
   ============================================ */

/* Local Inter font */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('/fonts/inter-cyrillic-ext.woff2') format('woff2');
    unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('/fonts/inter-cyrillic.woff2') format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('/fonts/inter-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('/fonts/inter-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Local Roboto font */
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('/fonts/roboto-cyrillic-ext.woff2') format('woff2');
    unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('/fonts/roboto-cyrillic.woff2') format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('/fonts/roboto-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('/fonts/roboto-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    /* Background - clean blue-gray */
    --bg-base: #f1f5f9;
    --bg-gradient: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);

    /* Glass effects */
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.9);
    --glass-blur: blur(12px);

    /* Brand — синий + оранжевый акцент (как на лендинге) */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: rgba(37, 99, 235, 0.1);
    --accent: #f97316;
    --accent-hover: #ea580c;
    --accent-light: rgba(249, 115, 22, 0.12);

    /* Status colors */
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.1);

    /* Text */
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    /* Borders */
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 40px rgba(0,0,0,0.12);

    /* Radius */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-full: 9999px;
}

/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 50%, #e2e8f0 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "kern" 1, "liga" 1;
    text-rendering: optimizeLegibility;
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.2); }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Focus-visible for accessibility */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Selection color */
::selection {
    background: rgba(37, 99, 235, 0.15);
    color: inherit;
}

/* Smooth page fade-in */
@keyframes pageIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.main-content, .dashboard-main {
    animation: pageIn 0.4s ease forwards;
}

/* ============================================
   Header
   ============================================ */
.header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    padding: 0 16px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 200;
}

.header-left {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
}

.header-center {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 0 16px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
}

.logo-icon {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--primary) 0%, #60a5fa 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.logo-icon svg { width: 15px; height: 15px; }

.logo-text {
    font-size: 15px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, #60a5fa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    position: relative;
    display: inline-flex;
    align-items: flex-start;
}

.logo-pro {
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.3px;
    background: linear-gradient(135deg, var(--accent-hover) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-left: 2px;
    margin-top: 1px;
}

/* Account Switcher */
.account-switcher-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-md);
    min-width: 200px;
    cursor: pointer;
    transition: all 0.2s;
}

.account-switcher-wrapper:hover {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(37, 99, 235, 0.3);
}

.account-switcher-icon {
    width: 22px;
    height: 22px;
    background: rgba(37, 99, 235, 0.1);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    flex-shrink: 0;
}

.account-switcher-icon svg { width: 14px; height: 14px; }

.account-select {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    outline: none;
    padding-right: 20px;
}

.account-switcher-arrow {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    position: absolute;
    right: 12px;
    pointer-events: none;
}

/* Account Switcher Dropdown */
.account-switcher {
    position: relative;
    margin-left: 12px;
}

.account-switcher-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    min-width: 140px;
    max-width: 260px;
}

.account-switcher-btn:hover {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(37, 99, 235, 0.3);
}

.account-switcher.open .account-switcher-btn {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.account-switcher-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-switcher-btn .account-switcher-arrow {
    position: static;
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform 0.2s;
}

.account-switcher.open .account-switcher-arrow {
    transform: rotate(180deg);
}

.account-switcher-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 280px;
    max-width: 420px;
    width: max-content;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    overflow: hidden;
}

.account-switcher.open .account-switcher-dropdown {
    display: block;
}

.account-switcher-list {
    max-height: 480px;
    overflow-y: auto;
}

.account-switcher-search {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}

.account-switcher-search input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
    outline: none;
    background: var(--bg-base);
    color: var(--text-primary);
    transition: border-color 0.2s;
}

.account-switcher-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.account-switcher-search input::placeholder {
    color: var(--text-muted);
}

.account-switcher-empty {
    padding: 16px 12px;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}

.account-switcher-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.15s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.account-switcher-item:hover {
    background: var(--primary-light);
}

.account-switcher-item.active {
    background: var(--primary-light);
}

.account-switcher-item-icon {
    width: 28px;
    height: 28px;
    background: rgba(37, 99, 235, 0.1);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

.account-switcher-item.active .account-switcher-item-icon {
    background: var(--primary);
    color: white;
}

.account-switcher-item-info {
    flex: 1;
    min-width: 0;
}

.account-switcher-item-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-switcher-item-id {
    font-size: 11px;
    color: var(--text-muted);
}

.account-switcher-item-check {
    width: 16px;
    height: 16px;
    color: var(--primary);
    opacity: 0;
    flex-shrink: 0;
}

.account-switcher-item.active .account-switcher-item-check {
    opacity: 1;
}

.account-switcher-manage {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-top: 1px solid var(--border-color);
    transition: all 0.15s;
}

.account-switcher-manage:hover {
    background: var(--bg-base);
    color: var(--primary);
}

.account-switcher-manage svg {
    width: 14px;
    height: 14px;
}

/* Header Buttons */
.header-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: var(--radius-md);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    border: none;
    background: transparent;
}

.header-btn svg { width: 14px; height: 14px; }

.header-btn-ghost {
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.03);
}

.header-btn-ghost:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-primary);
}

.header-btn-danger {
    color: var(--text-muted);
    padding: 5px;
    border-radius: var(--radius-full);
}

.header-btn-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.upgrade-btn {
    background: linear-gradient(135deg, var(--primary) 0%, #60a5fa 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.upgrade-btn:hover {
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
    transform: translateY(-1px);
}

.upgrade-btn.is-pro {
    background: linear-gradient(135deg, var(--success) 0%, #34d399 100%);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.header-divider {
    width: 1px;
    height: 24px;
    background: rgba(0, 0, 0, 0.1);
    margin: 0 4px;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px 4px 4px;
    border-radius: var(--radius-lg);
    transition: background 0.2s;
}

.user-menu:hover {
    background: rgba(0, 0, 0, 0.03);
}

.user-avatar {
    width: 26px;
    height: 26px;
    background: linear-gradient(135deg, #e0e7ff 0%, #bfdbfe 100%);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 13px;
    font-weight: 600;
}

.user-avatar svg { width: 16px; height: 16px; }

.user-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 900px) {
    .header-btn-text { display: none; }
    .header-center { display: none; }
    .user-name { display: none; }
}

/* Legacy header styles */
.btn-outline-danger {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}
.btn-outline-danger:hover {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: var(--danger);
}

.header-left-legacy, .header-right-legacy {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-avatar {
    width: 28px;
    height: 28px;
    background: var(--primary);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 11px;
    font-weight: 600;
}

.user-avatar svg { width: 14px; height: 14px; }

.user-name {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ============================================
   Main Layout
   ============================================ */
.main-content {
    position: relative;
    padding: 12px;
    padding-top: 16px;
    min-height: calc(100vh - 44px);
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding-top: 16px;
}

/* ============================================
   Glass Card
   ============================================ */
.glass-card {
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03), 0 4px 16px rgba(0, 0, 0, 0.05), 0 12px 32px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

/* ============================================
   Stats Cards
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.stat-card {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--radius-lg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.03);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), #60a5fa);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card:hover {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06), 0 12px 32px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.stat-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.stat-card:hover .stat-icon {
    transform: scale(1.08);
}

.stat-icon svg { width: 15px; height: 15px; }

.stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-icon.success { background: var(--success-bg); color: var(--success); }
.stat-icon.warning { background: var(--warning-bg); color: var(--warning); }
.stat-icon.info { background: var(--info-bg); color: var(--info); }

.stat-content { flex: 1; min-width: 0; }

.stat-value {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: -0.3px;
    font-variant-numeric: tabular-nums lining-nums;
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   Toolbar
   ============================================ */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-box {
    position: relative;
    width: 200px;
}

.search-box input {
    width: 100%;
    padding: 5px 10px 5px 28px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-primary);
    transition: all 0.15s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.search-box input::placeholder { color: var(--text-muted); }

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    pointer-events: none;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
    white-space: nowrap;
    letter-spacing: -0.01em;
}

.btn svg { width: 13px; height: 13px; }

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #60a5fa 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, #2563eb 100%);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
    transform: translateY(-1px);
}

.btn-ai-automode {
    background: linear-gradient(135deg, #f97316, #ef4444, #3b82f6);
    color: white;
    border: none;
    transition: all 0.2s;
}
.btn-ai-automode:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
    filter: brightness(1.05);
}

.btn-secondary {
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.btn-secondary:hover {
    background: #f8fafc;
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}

.btn-success { background: var(--success); color: white; box-shadow: 0 2px 6px rgba(16, 185, 129, 0.2); }
.btn-success:hover { background: #059669; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3); }

.btn-warning { background: var(--warning); color: white; box-shadow: 0 2px 6px rgba(245, 158, 11, 0.2); }
.btn-warning:hover { background: #d97706; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3); }

.btn-danger { background: var(--danger); color: white; box-shadow: 0 2px 6px rgba(239, 68, 68, 0.2); }
.btn-danger:hover { background: #dc2626; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--primary-light); color: var(--primary); }

.btn-sm { padding: 3px 8px; font-size: 11px; }
.btn-lg { padding: 7px 14px; font-size: 13px; }

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-icon {
    width: 26px;
    height: 26px;
    padding: 0;
}

.btn-icon.btn-sm {
    width: 22px;
    height: 22px;
}

/* ============================================
   Table
   ============================================ */
.table-container {
    overflow: visible;
    border-radius: var(--radius-lg);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.data-table th,
.data-table td {
    padding: 5px 8px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table th {
    background: rgba(241, 245, 249, 0.8);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table tbody tr {
    background: white;
    transition: background 0.1s;
}

.data-table tbody tr:hover {
    background: var(--primary-light);
}

.data-table tbody tr.selected {
    background: rgba(37, 99, 235, 0.15);
}

/* Checkbox column */
.data-table th:first-child,
.data-table td:first-child {
    width: 36px;
    text-align: center;
    padding: 8px;
}

/* Checkbox */
.checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* Campaign name cell */
.campaign-name {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.campaign-title {
    font-weight: 500;
    color: var(--text-primary);
    position: relative;
}

.campaign-title-text {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.campaign-title-link {
    color: inherit;
    text-decoration: none;
}
.campaign-title-link:hover {
    color: var(--primary, #2563eb);
}
.campaign-title-link:hover .campaign-title-text {
    text-decoration: underline;
}

.promote-url {
    display: block;
    max-width: 100%;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.promote-url-wrap {
    display: block;
    margin-top: 2px;
    position: relative;
}

.promote-url-popup {
    white-space: nowrap;
    min-width: auto;
}

.campaign-id {
    font-size: 10px;
    color: var(--text-muted);
}

/* Status badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    transition: all 0.15s ease;
}

.status-badge svg { width: 10px; height: 10px; }

.status-active {
    background: var(--success-bg);
    color: var(--success);
    box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.15);
}
.status-paused {
    background: var(--warning-bg);
    color: var(--warning);
    box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.15);
}
.status-stopped { background: rgba(148, 163, 184, 0.12); color: #64748b; }
.status-declined {
    background: var(--danger-bg);
    color: var(--danger);
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.15);
}
.status-pending, .status-draft { background: rgba(148, 163, 184, 0.12); color: var(--text-muted); }

/* Cell values */
.cell-value {
    font-weight: 500;
}

.cell-value.positive { color: var(--success); }
.cell-value.negative { color: var(--danger); }

/* Action buttons */
.action-buttons {
    display: flex;
    gap: 4px;
}

.action-btn {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.action-btn svg { width: 14px; height: 14px; }

.action-btn:hover { background: var(--primary-light); color: var(--primary); }
.action-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }
.action-btn.success:hover { background: var(--success-bg); color: var(--success); }

/* ============================================
   Batch Actions Bar
   ============================================ */
.batch-actions {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: var(--radius-xl);
    border: 1px solid rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.batch-actions.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.batch-count {
    font-size: 12px;
    font-weight: 600;
    padding-right: 12px;
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    color: var(--text-secondary);
}

.batch-buttons {
    display: flex;
    gap: 8px;
}

.batch-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: rgba(37, 99, 235, 0.1);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: var(--radius-md);
    color: var(--primary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.batch-btn svg { width: 14px; height: 14px; }
.batch-btn:hover {
    background: rgba(37, 99, 235, 0.15);
    border-color: rgba(37, 99, 235, 0.3);
}
.batch-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.batch-btn.success {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.2);
    color: var(--success);
}
.batch-btn.success:hover {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.3);
}

.batch-btn.danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}
.batch-btn.danger:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
}

.batch-close {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    border-radius: var(--radius-full);
    color: var(--text-muted);
    cursor: pointer;
    margin-left: 4px;
    transition: all 0.15s;
}

.batch-close svg { width: 14px; height: 14px; }
.batch-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

/* Batch Dropdown */
.batch-divider {
    width: 1px;
    height: 20px;
    background: var(--border-color);
    margin: 0 4px;
}

.batch-dropdown {
    position: relative;
}

.batch-dropdown .batch-btn {
    display: flex;
    align-items: center;
    gap: 4px;
}

.batch-dropdown-menu {
    display: none;
    position: absolute;
    bottom: calc(100% + 4px);
    left: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    z-index: 100;
    padding: 4px;
}

.batch-dropdown.open .batch-dropdown-menu {
    display: block;
}

.batch-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: none;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
    white-space: nowrap;
}

.batch-dropdown-item:hover {
    background: var(--bg-base);
}

.batch-dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

/* Campaign Search */
.campaign-search {
    position: relative;
    margin-bottom: 12px;
}

.campaign-search input {
    width: 100%;
    max-width: 320px;
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 13px;
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.campaign-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.campaign-search .search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* Column Visibility Toggle */
.col-secondary {
    /* Hidden by default on smaller screens or when toggled off */
}

.columns-hidden .col-secondary {
    display: none !important;
}

.column-toggle-btn {
    padding: 4px 10px;
    font-size: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
}

.column-toggle-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.column-toggle-btn.active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

/* ============================================
   Task Progress Container
   ============================================ */
.task-progress-container {
    position: fixed;
    bottom: 88px;
    right: 24px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 380px;
}

.task-progress-item {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
    animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.task-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.task-progress-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
}

.task-progress-title .task-icon {
    font-size: 16px;
}

.task-progress-close {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-full);
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.15s;
}

.task-progress-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

.task-progress-bar {
    height: 6px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 10px;
}

.task-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, #60a5fa 100%);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.task-progress-fill.completed {
    background: linear-gradient(90deg, var(--success) 0%, #34d399 100%);
}

.task-progress-fill.failed {
    background: linear-gradient(90deg, var(--danger) 0%, #f87171 100%);
}

.task-progress-fill.cancelled {
    background: linear-gradient(90deg, #9ca3af 0%, #d1d5db 100%);
}

.task-progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    margin-bottom: 12px;
}

.task-progress-status {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-weight: 500;
}

.task-progress-status.running,
.task-progress-status.pending {
    color: var(--primary);
}

.task-progress-status.completed {
    color: var(--success);
}

.task-progress-status.failed {
    color: var(--danger);
}

.task-progress-status.cancelled {
    color: var(--text-muted);
}

.task-progress-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.task-progress-count {
    color: var(--text-muted);
    font-size: 11px;
    display: flex;
    gap: 8px;
    align-items: baseline;
    flex-wrap: wrap;
}
.task-progress-total { color: var(--text-muted); }
.task-progress-ok    { color: #10b981; font-weight: 600; }
.task-progress-fail  { color: #ef4444; font-weight: 600; }

.task-progress-actions {
    display: flex;
    gap: 8px;
}

.task-btn-cancel,
.task-btn-dismiss,
.task-btn-pause,
.task-btn-resume,
.task-btn-retry {
    flex: 1;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border: none;
}

.task-btn-cancel {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.task-btn-cancel:hover {
    background: rgba(239, 68, 68, 0.15);
}

.task-btn-pause {
    background: rgba(249, 115, 22, 0.1);
    color: #f97316;
    border: 1px solid rgba(249, 115, 22, 0.2);
}

.task-btn-pause:hover {
    background: rgba(249, 115, 22, 0.15);
}

.task-btn-resume {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.task-btn-resume:hover {
    background: rgba(34, 197, 94, 0.15);
}

.task-pause-reason {
    font-size: 12px;
    color: #f97316;
    padding: 4px 8px;
    background: rgba(249, 115, 22, 0.08);
    border-radius: 4px;
    margin-bottom: 6px;
    text-align: center;
    width: 100%;
}

.task-btn-retry {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.task-btn-retry:hover {
    background: rgba(59, 130, 246, 0.15);
}

.task-btn-dismiss {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.task-btn-dismiss:hover {
    background: rgba(0, 0, 0, 0.08);
}

.task-dismiss-all {
    width: 100%;
    padding: 10px 16px;
    border-radius: var(--radius-lg);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: var(--text-secondary);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.task-dismiss-all:hover {
    background: rgba(0, 0, 0, 0.08);
    color: var(--text-primary);
}

/* Task Error Details (in progress widget) */
.task-error-details {
    margin-top: 6px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    padding-top: 6px;
}

.task-error-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    padding: 2px 0;
    font-size: 11px;
    color: #ef4444;
    cursor: pointer;
    font-weight: 500;
}

.task-error-toggle:hover {
    color: #dc2626;
}

.task-error-toggle-icon {
    font-size: 9px;
}

.task-error-list {
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.task-error-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 11px;
    padding: 4px 6px;
    background: rgba(239, 68, 68, 0.06);
    border-radius: 4px;
}

.task-error-count {
    color: #ef4444;
    font-weight: 600;
    flex-shrink: 0;
    margin-right: 4px;
}

.task-error-msg {
    color: #64748b;
    word-break: break-word;
}

.task-error-targets {
    color: #94a3b8;
    font-size: 10px;
    padding-left: 6px;
    line-height: 1.35;
    word-break: break-word;
}

/* Visibility Check Results (in progress widget) */
.task-vis-results {
    margin-top: 6px;
    margin-bottom: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    padding-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.task-vis-empty {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}

.task-vis-row {
    display: grid;
    grid-template-columns: 100px 1fr 40px;
    align-items: center;
    gap: 6px;
}

.task-vis-name {
    font-size: 11px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-vis-bar-wrap {
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.task-vis-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.task-vis-score {
    font-size: 11px;
    font-weight: 600;
    text-align: right;
}

.task-vis-bar.vis-green  { background-color: var(--success); }
.task-vis-bar.vis-amber  { background-color: var(--warning); }
.task-vis-bar.vis-orange { background-color: #f97316; }
.task-vis-bar.vis-red    { background-color: var(--danger); }
.task-vis-score.vis-green  { color: var(--success); }
.task-vis-score.vis-amber  { color: var(--warning); }
.task-vis-score.vis-orange { color: #f97316; }
.task-vis-score.vis-red    { color: var(--danger); }

/* Visibility check — per-channel detail block (matched ad, bots, all ads seen) */
.task-vis-detail {
    margin: 4px 0 10px 0;
    padding: 6px 8px;
    border-left: 2px solid var(--border-color);
    background: var(--bg-secondary, #f8fafc);
    border-radius: 4px;
    font-size: 11px;
    line-height: 1.35;
}
.task-vis-detail .task-vis-sub {
    font-weight: 600;
    color: var(--text-secondary);
    margin: 6px 0 3px 0;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.task-vis-hit {
    padding: 4px 6px;
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.25);
    border-radius: 3px;
    margin-bottom: 6px;
}
.task-vis-hit-title {
    color: var(--success);
    font-weight: 600;
    margin-bottom: 3px;
}
.task-vis-kv {
    display: grid;
    grid-template-columns: 40px 1fr;
    gap: 6px;
    margin: 1px 0;
}
.task-vis-kv .k {
    color: var(--text-secondary);
    font-size: 10px;
    text-transform: uppercase;
}
.task-vis-kv .v {
    word-break: break-all;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 10.5px;
}
.task-vis-bots { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.task-vis-bot {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    background: var(--border-color);
    color: var(--text-secondary);
}
.task-vis-bot.ok   { background: rgba(34, 197, 94, 0.12); color: var(--success); }
.task-vis-bot.fail { background: rgba(239, 68, 68, 0.12); color: var(--danger); }
.task-vis-ads { display: flex; flex-direction: column; gap: 4px; }
.task-vis-ad {
    padding: 3px 6px;
    border-radius: 3px;
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color);
}
.task-vis-ad.ours {
    border-color: rgba(34, 197, 94, 0.35);
    background: rgba(34, 197, 94, 0.04);
}
.task-vis-ad-url {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 10.5px;
    word-break: break-all;
    color: var(--text);
}
.task-vis-ad-title {
    font-size: 11px;
    font-weight: 500;
    margin-top: 1px;
}
.task-vis-ad-msg {
    font-size: 10.5px;
    color: var(--text-secondary);
    margin-top: 1px;
}
.task-vis-ad-meta {
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 2px;
    font-style: italic;
}

/* Task History Modal */
.task-history-item {
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 6px;
    transition: background 0.15s;
}

.task-history-item.has-errors {
    border-color: #fecaca;
    background: #fef2f2;
}

.task-history-item.has-errors:hover {
    background: #fee2e2;
}

.task-history-errors {
    display: none;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(239, 68, 68, 0.15);
    flex-direction: column;
    gap: 3px;
}

.task-history-errors.expanded {
    display: flex;
}

.task-history-error-item {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 11px;
    padding: 4px 8px;
    background: rgba(239, 68, 68, 0.08);
    border-radius: 4px;
}

.task-history-error-count {
    color: #ef4444;
    font-weight: 600;
    flex-shrink: 0;
}

.task-history-error-msg {
    color: #64748b;
    word-break: break-word;
}

/* ============================================
   Modal
   ============================================ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-backdrop.show { display: flex; }

.modal-backdrop .modal-inner {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--radius-xl);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-header h3 svg { width: 16px; height: 16px; color: var(--primary); }

.modal-close {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.modal-close:hover { background: var(--border-light); color: var(--text-primary); }
.modal-close svg { width: 16px; height: 16px; }

.modal-body {
    padding: 12px 14px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    padding: 10px 14px;
    border-top: 1px solid var(--border-color);
}

/* Modal Overlay (alternative) */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-overlay.show { display: flex; }

.modal-overlay .modal {
    display: flex !important;
    flex-direction: column;
    position: relative;
    inset: auto;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--radius-xl);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    overflow: hidden;
    padding: 0;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-icon svg { width: 16px; height: 16px; color: var(--primary); }

.modal-actions {
    display: flex;
    gap: 6px;
    margin-top: 12px;
}

.modal-actions .btn { flex: 1; }

/* ============================================
   Forms
   ============================================ */
.form-group {
    margin-bottom: 10px;
}

.form-group label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 6px 10px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
    border-color: #cbd5e1;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    background: #fefeff;
}

.form-input::placeholder { color: var(--text-muted); }

.form-textarea {
    min-height: 60px;
    resize: vertical;
}

.form-hint {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 3px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

/* Input with icon */
.input-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: var(--text-muted);
}

.form-input.with-icon {
    padding-left: 32px;
}

/* ============================================
   Alerts
   ============================================ */
.alert {
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    margin-bottom: 8px;
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
    text-align: center;
    padding: 28px 16px;
}

.empty-state-icon {
    width: 36px;
    height: 36px;
    margin: 0 auto 10px;
    background: var(--primary-light);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.empty-state-icon svg { width: 18px; height: 18px; }

.empty-state h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.empty-state p {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* ============================================
   Loading
   ============================================ */
.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.loading-spinner.small {
    width: 14px;
    height: 14px;
    border-width: 2px;
}

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border-color);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Skeleton loading rows */
.skeleton-row td {
    padding: 10px 8px !important;
}

.skeleton-box {
    height: 14px;
    background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-hover, #f1f5f9) 50%, var(--bg-secondary) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: 4px;
}

.skeleton-box--checkbox { width: 16px; height: 16px; border-radius: 3px; }
.skeleton-box--avatar   { width: 32px; height: 32px; border-radius: 50%; }
.skeleton-box--icon-lg  { width: 28px; height: 28px; border-radius: 6px; }
.skeleton-box--icon-sm  { width: 24px; height: 24px; }

@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Pagination loader & counter at bottom of campaigns table */
.pagination-loader-cell,
.pagination-counter-cell {
    text-align: center;
    padding: 16px 0;
    border: none !important;
}

.pagination-loader {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 13px;
}

.pagination-counter {
    color: var(--text-muted);
    font-size: 12px;
}

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 12px;
    color: var(--text-muted);
    font-size: 12px;
}

/* ============================================
   Tabs
   ============================================ */
.tabs {
    display: flex;
    gap: 4px;
    background: var(--border-light);
    padding: 3px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}

.tab {
    padding: 6px 14px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.tab:hover { color: var(--text-primary); }
.tab.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* Compact tabs for modals with many options */
.tabs.tabs-compact {
    gap: 2px;
}
.tabs.tabs-compact .tab {
    padding: 6px 10px;
    font-size: 11px;
}

/* ============================================
   Filter Dropdown
   ============================================ */
.filter-dropdown {
    position: relative;
}

.filter-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    z-index: 100;
    display: none;
}

.filter-menu.show { display: block; }

.filter-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.1s;
}

.filter-option:hover { background: var(--border-light); }
.filter-option.active { color: var(--primary); }

/* ============================================
   Pagination
   ============================================ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 12px;
}

.page-btn {
    min-width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-btn svg { width: 14px; height: 14px; }

/* ============================================
   Toast
   ============================================ */
.toast-container {
    position: fixed;
    bottom: 88px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-left: 4px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 350px;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-icon { width: 15px; height: 15px; flex-shrink: 0; }
.toast-message { font-size: 12px; font-weight: 500; color: var(--text-primary); }

.toast.toast-error {
    border-left-color: var(--danger);
    background: rgba(254, 242, 242, 0.9);
}
.toast.toast-error .toast-icon { color: var(--danger); }

.toast.toast-success {
    border-left-color: var(--success);
    background: rgba(240, 253, 244, 0.9);
}
.toast.toast-success .toast-icon { color: var(--success); }

.toast.toast-warning {
    border-left-color: #f59e0b;
    background: rgba(255, 251, 235, 0.9);
}
.toast.toast-warning .toast-icon { color: #f59e0b; }

/* ============================================
   Accounts Page
   ============================================ */
.accounts-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
}

.account-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: var(--radius-md);
}

.account-card:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
    transform: translateY(-1px);
}

.account-card.active {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.account-card-main {
    display: flex;
    align-items: center;
    gap: 10px;
}

.account-icon {
    width: 34px;
    height: 34px;
    background: var(--primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.account-icon svg { width: 16px; height: 16px; }

.account-details h3 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 2px;
}

.account-meta {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: var(--text-muted);
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.meta-item svg { width: 12px; height: 12px; }
.meta-item.balance { color: var(--primary); font-weight: 500; }

/* Cabinet type badges */
.meta-item.cabinet-type {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.meta-item.cabinet-type-ton {
    background: linear-gradient(135deg, rgba(0, 136, 204, 0.15), rgba(0, 136, 204, 0.25));
    color: #0088cc;
    border: 1px solid rgba(0, 136, 204, 0.3);
}

.meta-item.cabinet-type-stars {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.15), rgba(255, 193, 7, 0.25));
    color: #d4a106;
    border: 1px solid rgba(255, 193, 7, 0.3);
}

.meta-item.cabinet-type-euro {
    background: linear-gradient(135deg, rgba(0, 200, 83, 0.15), rgba(0, 200, 83, 0.25));
    color: #00a854;
    border: 1px solid rgba(0, 200, 83, 0.3);
}

.active-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--success-bg);
    border-radius: var(--radius-full);
    color: var(--success);
    font-size: 11px;
    font-weight: 600;
}

.active-badge svg { width: 12px; height: 12px; }

.account-actions {
    display: flex;
    gap: 6px;
}

.add-account-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px;
    border: 2px dashed var(--border-color);
    background: transparent;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
}

.add-account-card:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.add-account-icon svg { width: 20px; height: 20px; }

/* Help Card */
.help-card {
    padding: 12px;
}

.help-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.help-card-icon {
    width: 26px;
    height: 26px;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.help-card-icon svg { width: 13px; height: 13px; }
.help-card-header h3 { font-size: 12px; font-weight: 600; }

.help-steps {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.help-steps li {
    display: flex;
    gap: 10px;
    font-size: 12px;
    color: var(--text-secondary);
}

.step-number {
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 10px;
    font-weight: 600;
    flex-shrink: 0;
}

.help-steps code {
    padding: 2px 6px;
    background: var(--primary-light);
    border-radius: 4px;
    font-size: 11px;
    color: var(--primary);
}

/* Page Header */
.page-header {
    text-align: center;
    margin-bottom: 20px;
}

.page-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.page-title-icon {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--primary) 0%, #60a5fa 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.page-title-icon svg { width: 14px; height: 14px; }
.page-subtitle { font-size: 12px; color: var(--text-muted); letter-spacing: -0.01em; }

/* ============================================
   Login Page
   ============================================ */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-container {
    width: 100%;
    max-width: 380px;
    padding-top: max(env(safe-area-inset-top, 0px), 16px);
}

.auth-card {
    padding: 24px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 8px 32px rgba(0, 0, 0, 0.06), 0 24px 56px rgba(0, 0, 0, 0.04);
}

.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
}

.auth-logo-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-logo-icon svg { width: 26px; height: 26px; }

.auth-logo-text {
    font-size: 26px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.02em;
}

.auth-logo-text .logo-pro {
    font-size: 11px;
    margin-top: 2px;
}

.auth-header { margin-bottom: 16px; }
.auth-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.auth-subtitle { font-size: 12px; color: var(--text-muted); }

.auth-tabs {
    display: flex;
    gap: 4px;
    background: var(--border-light);
    padding: 3px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
}

.auth-tab {
    flex: 1;
    padding: 6px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
}

.auth-tab:hover { color: var(--text-primary); }
.auth-tab.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    font-weight: 600;
}

.auth-form { text-align: left; display: none; }
.auth-form.active { display: block; }

.auth-form .form-group { margin-bottom: 10px; }

.auth-submit {
    width: 100%;
    padding: 7px;
    margin-top: 6px;
}

/* Auth divider */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
    color: var(--text-muted);
    font-size: 12px;
}
.auth-divider::before, .auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* Telegram button */
.btn-telegram {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 8px 16px;
    background: #0088cc;
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}
.btn-telegram:hover {
    background: #0077b5;
    transform: translateY(-1px);
}
.btn-t.btn-lg {
    padding: 10px 18px;
    font-size: 13px;
}
.btn-telegram svg {
    flex-shrink: 0;
}

/* Telegram auth status */
.telegram-auth-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 8px 14px;
    background: rgba(0, 136, 204, 0.1);
    border: 1px solid rgba(0, 136, 204, 0.3);
    border-radius: var(--radius-sm);
    color: #0088cc;
    font-size: 12px;
}

/* Optional hint */
.optional-hint {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 11px;
}
.telegram-hint {
    color: var(--text-muted);
}

.auth-error, .auth-success {
    padding: 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    margin-bottom: 14px;
    display: none;
}

.auth-error {
    background: var(--danger-bg);
    color: var(--danger);
}

.auth-success {
    background: var(--success-bg);
    color: var(--success);
}

.auth-error.show, .auth-success.show { display: block; }

/* Field hints for validation */
.field-hint {
    display: block;
    font-size: 11px;
    margin-top: 4px;
    min-height: 14px;
    color: var(--text-muted);
}
.field-hint.error { color: var(--danger); }
.field-hint.success { color: var(--success); }

/* Terms checkbox */
.terms-group {
    margin-top: 16px;
    margin-bottom: 16px;
}
.terms-group .checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    user-select: none;
}
.terms-group .checkbox-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    margin: 0;
    margin-top: 2px;
    flex-shrink: 0;
    accent-color: var(--primary);
    cursor: pointer;
}
.terms-group .checkbox-label a {
    color: var(--primary);
    text-decoration: none;
}
.terms-group .checkbox-label a:hover {
    text-decoration: underline;
}
.terms-group .checkbox-error {
    display: none;
    font-size: 11px;
    margin-top: 4px;
    margin-left: 22px;
    color: var(--danger, #ef4444);
}
.terms-group.error .checkbox-error {
    display: block;
}
.terms-group.error .checkbox-label {
    color: var(--danger, #ef4444);
}

/* Form field error states */
.form-group.error .form-input {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
}
.form-group.error label {
    color: #ef4444;
}
.field-error-message {
    color: #ef4444;
    font-size: 12px;
    margin-top: 4px;
    display: none;
}
.form-group.error .field-error-message {
    display: block;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-3px); }
    40% { transform: translateX(3px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}

/* Verification Code Form Styles */
.verification-icon {
    text-align: center;
    margin-bottom: 16px;
}

.verification-icon svg {
    color: var(--primary);
    opacity: 0.9;
}

.verification-text {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
    line-height: 1.5;
}

.verification-text strong {
    color: var(--text-primary);
    font-weight: 600;
}

.verification-code-inputs {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 8px;
}

.code-input {
    width: 48px;
    height: 56px;
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.code-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
    background: var(--bg-secondary);
}

.code-input:not(:placeholder-shown) {
    border-color: var(--primary);
    background: rgba(102, 126, 234, 0.05);
}

.resend-code-section {
    text-align: center;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.resend-text {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-link:hover:not(:disabled) {
    background: rgba(102, 126, 234, 0.1);
}

.btn-link:disabled {
    color: var(--text-muted);
    cursor: not-allowed;
}

.back-to-register {
    margin-top: 16px;
    font-size: 13px;
}

.auth-footer {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.auth-footer p {
    font-size: 11px;
    color: var(--text-muted);
}

.auth-footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    font-size: 12px;
}

.auth-footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.auth-footer-links a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.auth-footer-links .footer-divider {
    color: var(--border-color);
}

.password-field { position: relative; }

.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
}

.password-toggle:hover { color: var(--primary); }
.password-toggle svg { width: 16px; height: 16px; }

/* ============================================
   Plans Page
   ============================================ */
.plans-page {
    padding: 16px 12px;
    max-width: 1400px;
    margin: 0 auto;
}

/* ===== PLANS PAGE ===== */
.plans-header {
    text-align: center;
    margin-bottom: 24px;
    padding: 20px 16px;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.06) 0%, rgba(37, 99, 235, 0.06) 50%, rgba(245, 158, 11, 0.04) 100%);
    border-radius: 12px;
    border: 1px solid rgba(37, 99, 235, 0.08);
}

.plans-title {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 6px;
    letter-spacing: -0.5px;
}

.plans-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    max-width: 480px;
    margin: 0 auto;
    line-height: 1.5;
}

.gradient-text {
    background: linear-gradient(135deg, var(--primary) 0%, #60a5fa 50%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.current-plan-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    margin-top: 12px;
    font-size: 12px;
    font-weight: 500;
    background: white;
    border-radius: var(--radius-full);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.current-plan-badge svg { width: 16px; height: 16px; color: var(--success); }
.current-plan-badge strong { color: var(--primary); font-weight: 700; }

/* Billing Toggle Wrapper — full width row inside plans-grid flex */
.billing-toggle-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: 8px;
}
.billing-toggle {
    display: inline-flex;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 4px;
}
.billing-toggle-btn {
    padding: 6px 16px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}
.billing-toggle-btn:hover {
    color: var(--text-primary);
}
.billing-toggle-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}
.billing-toggle-badge {
    background: #22c55e;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 6px;
}
.plan-billed-yearly {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Plan Cards Grid */
.plans-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    margin-bottom: 20px;
    padding-top: 14px;
    align-items: flex-start;
}

@media (max-width: 900px) {
    .plans-grid { flex-direction: column; align-items: center; }
}

.plan-card {
    padding: 20px 18px;
    position: relative;
    flex: 1 1 0;
    min-width: 240px;
    border-radius: 12px;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
    overflow: visible;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 6px 24px rgba(0,0,0,0.06);
    animation: planCardIn 0.5s ease both;
    border: 1px solid rgba(0,0,0,0.04);
}

.plan-card:nth-child(2) { animation-delay: 0.1s; }
.plan-card:nth-child(3) { animation-delay: 0.2s; }
.plan-card:nth-child(4) { animation-delay: 0.3s; }

@keyframes planCardIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.plan-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.08), 0 24px 56px rgba(0,0,0,0.06);
    border-color: rgba(0,0,0,0.06);
}

/* Featured card (Pro) */
.plan-card.featured {
    border: 2px solid var(--primary);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.1), 0 12px 40px rgba(37, 99, 235, 0.08);
    background: linear-gradient(180deg, rgba(37,99,235,0.04) 0%, rgba(255,255,255,1) 40%);
    z-index: 1;
    transform: scale(1.02);
}

.plan-card.featured:hover {
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.15), 0 24px 56px rgba(37, 99, 235, 0.12);
    transform: scale(1.02) translateY(-4px);
}

/* Agency card */
.plan-card.agency-card {
    border: 2px solid rgba(245, 158, 11, 0.25);
}

.plan-card.agency-card:hover {
    box-shadow: 0 20px 40px rgba(245, 158, 11, 0.1);
}

/* Plan badge */
.plan-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--primary) 0%, #60a5fa 100%);
    color: white;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    white-space: nowrap;
    box-shadow: 0 4px 14px rgba(37,99,235,0.4);
}

/* Plan header */
.plan-header { margin-bottom: 16px; }

.plan-icon {
    width: 36px;
    height: 36px;
    background: var(--primary-light);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    margin-bottom: 10px;
}

.plan-card.featured .plan-icon {
    background: linear-gradient(135deg, var(--primary) 0%, #60a5fa 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.plan-card.agency-card .plan-icon {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(217, 119, 6, 0.08) 100%);
    color: #f59e0b;
}

.plan-icon svg { width: 18px; height: 18px; }

.plan-name { font-size: 18px; font-weight: 800; margin-bottom: 2px; color: var(--text-primary); letter-spacing: -0.3px; }
.plan-description { font-size: 12px; color: var(--text-muted); margin-top: 2px; line-height: 1.4; }

/* Plan pricing */
.plan-pricing {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.plan-price {
    display: flex;
    align-items: baseline;
    gap: 2px;
}

.plan-currency { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.plan-amount { font-size: 36px; font-weight: 800; line-height: 1; color: var(--text-primary); letter-spacing: -1.5px; font-variant-numeric: tabular-nums lining-nums; }
.plan-period { font-size: 12px; color: var(--text-muted); margin-left: 4px; }

.plan-daily {
    display: inline-block;
    margin-top: 6px;
    padding: 3px 10px;
    background: var(--success-bg);
    color: var(--success);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
}

/* Plan features */
.plan-features {
    list-style: none;
    margin-bottom: 16px;
}

.plan-features li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    border-radius: 6px;
    transition: background 0.15s, padding-left 0.15s, padding-right 0.15s;
}

.plan-features li:hover {
    background: rgba(0,0,0,0.02);
    padding-left: 4px;
    padding-right: 4px;
}

.plan-features li svg { width: 18px; height: 18px; color: var(--success); flex-shrink: 0; }

.plan-features li.disabled {
    color: var(--text-muted);
    text-decoration: line-through;
}

.plan-features li.disabled svg { color: var(--text-muted); }

.plan-features li.highlight {
    color: var(--text-primary);
    font-weight: 600;
}

.plan-features li.warning {
    color: var(--warning);
}

.plan-features li.warning svg {
    color: var(--warning);
}

/* Features divider (for Agency card: "All Pro features included") */
.plan-features li.features-divider {
    margin: 8px 0 4px;
    padding: 8px 0 4px;
    border-top: 1px solid var(--border-color);
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    justify-content: flex-start;
    gap: 0;
}

/* Plan CTA button */
.plan-cta {
    width: 100%;
    margin-top: auto;
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 700;
    border-radius: var(--radius-lg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.01em;
}

.plan-cta:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37,99,235,0.3);
    filter: brightness(1.05);
}

.plan-card.featured .plan-cta {
    background: linear-gradient(135deg, #2563eb 0%, #60a5fa 100%);
    animation: ctaPulse 3s ease-in-out infinite;
}

.plan-card.featured .plan-cta:hover {
    animation: none;
}

@keyframes ctaPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(37,99,235,0.3); }
    50% { box-shadow: 0 0 0 8px rgba(37,99,235,0); }
}

.btn-current {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
    font-weight: 600;
}

/* ===== PAYMENT INFO ===== */
.payment-info {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px;
    margin-bottom: 32px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.04) 0%, rgba(59, 130, 246, 0.04) 100%);
    border: 1px solid rgba(16, 185, 129, 0.12);
    border-radius: 16px;
}

.payment-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.payment-icon svg { width: 22px; height: 22px; }

.payment-content { flex: 1; }
.payment-content h3 { font-size: 15px; font-weight: 700; margin-bottom: 4px; color: var(--text-primary); }
.payment-content p { font-size: 13px; color: var(--text-secondary); line-height: 1.4; }

.payment-methods { display: flex; gap: 8px; flex-wrap: wrap; }

.payment-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.payment-badge:hover {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}

.payment-badge svg { width: 14px; height: 14px; }

/* ===== FAQ ===== */
.faq-section {
    margin-top: 40px;
    padding: 32px 0;
}

.faq-title {
    font-size: 22px;
    font-weight: 800;
    text-align: center;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.faq-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    align-items: start;
}

@media (max-width: 700px) {
    .faq-grid { grid-template-columns: 1fr; }
}

.faq-item {
    overflow: hidden;
    border-radius: 12px;
    transition: box-shadow 0.2s ease;
}

.faq-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.faq-question {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 16px 18px;
    background: none;
    border: none;
    text-align: left;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: color 0.2s;
}

.faq-question:hover { color: var(--primary); }
.faq-question svg { width: 16px; height: 16px; color: var(--text-muted); transition: transform 0.3s ease; flex-shrink: 0; }
.faq-item.open .faq-question svg { transform: rotate(180deg); color: var(--primary); }

.faq-answer { max-height: 0; overflow: hidden; transition: max-height 0.3s ease-out; }
.faq-item.open .faq-answer { max-height: 500px; }
.faq-answer-content { padding: 0 18px 16px; font-size: 13px; color: var(--text-secondary); line-height: 1.6; }

/* ============================================
   Animated Background (optional)
   ============================================ */
.animated-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.3;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: rgba(37, 99, 235, 0.28);
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 350px;
    height: 350px;
    background: rgba(249, 115, 22, 0.18);
    bottom: -100px;
    right: -100px;
}

.blob-3 {
    width: 250px;
    height: 250px;
    background: rgba(37, 99, 235, 0.14);
    top: 50%;
    right: 20%;
}

/* ============================================
   Responsive - Compact for laptops (1280px)
   ============================================ */
@media (max-width: 1280px) {
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 6px;
    }
    .stat-card {
        padding: 8px 10px;
    }
    .stat-value {
        font-size: 15px;
    }
}

/* ============================================
   Responsive - Mobile First Fixes
   ============================================ */

/* Prevent horizontal scroll on body */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

@media (max-width: 768px) {
    /* ===== GLOBAL MOBILE FIXES ===== */
    html {
        font-size: 14px;
    }

    body {
        -webkit-text-size-adjust: 100%;
    }

    .header {
        padding: 0 12px;
        height: 48px;
    }

    /* ===== DASHBOARD LAYOUT ===== */
    .dashboard-layout {
        min-height: 100vh;
        min-height: 100dvh; /* Dynamic viewport height for mobile */
    }

    .main-content {
        min-width: 0; /* Allow flex child to shrink */
        width: 100%;
    }

    .content-area {
        padding: 12px !important;
        overflow-x: hidden;
    }

    /* ===== TOP BAR ===== */
    .top-bar {
        padding: 0 12px !important;
        gap: 8px;
    }

    .top-bar-left {
        gap: 8px;
        min-width: 0;
        flex: 1;
    }

    .page-title {
        font-size: 16px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Account switcher on mobile */
    .account-switcher {
        margin-left: 8px !important;
        max-width: 140px;
    }

    .account-switcher-btn {
        padding: 6px 8px !important;
    }

    .account-switcher-name {
        max-width: 80px;
        font-size: 12px !important;
    }

    .account-switcher-dropdown {
        min-width: 260px;
        max-width: 360px;
    }

    .account-switcher-list {
        max-height: 400px;
    }

    /* ===== STATS GRID ===== */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .stat-card {
        padding: 8px;
    }

    .stat-value {
        font-size: 15px;
    }

    .stat-label {
        font-size: 10px;
    }

    /* ===== ACTION BAR ===== */
    .action-bar {
        flex-direction: column;
        gap: 8px;
        width: 100%;
        margin: 0 0 12px 0;
        padding: 0;
    }

    .action-bar-left,
    .action-bar-right {
        width: 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 6px;
    }

    .action-bar .search-box {
        width: 100%;
        max-width: none;
    }

    .action-bar .search-input {
        font-size: 14px;
    }

    /* Period buttons */
    .period-btns {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .period-btns::-webkit-scrollbar {
        display: none;
    }

    .period-btn {
        flex-shrink: 0;
        font-size: 11px;
        padding: 6px 10px;
    }

    /* ===== TABLE =====
       Campaigns/groups render as cards on phones — see the "Campaigns table →
       cards" media block at the END of this file. It must live after the
       desktop .campaigns-table rules (~line 5138+) to win the cascade; rules
       placed here would be overridden by them. */

    /* ===== TOOLBAR ===== */
    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .toolbar-left, .toolbar-right {
        flex-wrap: wrap;
        gap: 6px;
    }

    .search-box {
        width: 100%;
    }

    /* ===== BATCH ACTIONS ===== */
    .batch-actions {
        left: 8px;
        right: 8px;
        /* Sit above the fixed bottom tab bar (dashboard.css, 52px) */
        bottom: calc(var(--bottom-tab-height, 52px) + env(safe-area-inset-bottom, 0px) + 10px);
        transform: translateY(150px);
        width: auto;
        padding: 10px;
        border-radius: 12px;
        z-index: 1001;
        flex-wrap: wrap;
    }

    .batch-actions.show {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .batch-actions-left {
        gap: 6px;
        flex-wrap: wrap;
    }

    .batch-btn {
        padding: 6px 10px;
        font-size: 11px;
    }

    /* ===== MODALS ===== */
    .modal-overlay {
        padding: 8px;
        align-items: flex-end;
    }

    .modal,
    .modal-content,
    .glass-card.modal {
        max-width: 100% !important;
        max-height: 90vh !important;
        max-height: 90dvh !important;
        width: 100% !important;
        margin: 0;
        border-radius: 16px 16px 0 0;
    }

    .modal-header {
        padding: 12px 14px;
        position: sticky;
        top: 0;
        background: white;
        z-index: 10;
    }

    .modal-header h3 {
        font-size: 15px;
    }

    .modal-body {
        padding: 12px 14px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-footer,
    .modal-actions {
        padding: 10px 14px;
        position: sticky;
        bottom: 0;
        background: white;
        border-top: 1px solid var(--border-color);
    }

    /* ===== FORMS ===== */
    .form-group {
        margin-bottom: 10px;
    }

    .form-input,
    .form-select,
    .form-textarea,
    select,
    input[type="text"],
    input[type="number"],
    input[type="email"],
    textarea {
        font-size: 16px !important; /* Prevents iOS zoom */
        padding: 8px 10px;
    }

    .form-row {
        flex-direction: column;
        gap: 8px;
    }

    /* ===== BUTTONS ===== */
    .btn {
        padding: 8px 12px;
        font-size: 12px;
    }

    .btn-sm {
        padding: 4px 8px;
        font-size: 11px;
    }

    /* ===== CARDS ===== */
    .account-card {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 10px;
    }

    .account-actions {
        justify-content: flex-end;
        flex-wrap: wrap;
    }

    /* ===== PAYMENT ===== */
    .payment-info {
        flex-direction: column;
        text-align: center;
        padding: 20px;
    }

    .payment-methods {
        justify-content: center;
    }

    /* ===== PLANS ===== */
    .plans-header {
        padding: 24px 16px;
        margin-bottom: 28px;
    }

    .plans-title {
        font-size: 24px;
    }

    .plans-subtitle {
        font-size: 13px;
    }

    .plan-card {
        flex: 0 0 auto;
        width: 100%;
        max-width: 360px;
        padding: 24px 20px;
    }

    /* ===== CREATE CAMPAIGN MODAL ===== */
    .tg-form-group {
        margin-bottom: 12px;
    }

    .tg-form-row {
        flex-direction: column;
        gap: 12px;
    }

    .tg-form-row > .tg-form-group {
        width: 100%;
    }

    /* Channel selector */
    .tg-channel-selector {
        min-height: 40px;
    }

    .tg-channel-input {
        font-size: 16px !important;
    }

    /* Preview panel */
    .telegram-preview-panel {
        margin-top: 16px;
    }

    /* ===== DROPDOWNS ===== */
    .account-switcher-dropdown {
        position: fixed;
        top: auto;
        left: 12px;
        right: 12px;
        min-width: auto;
        max-width: none;
        width: auto;
    }

    .account-switcher-list {
        max-height: 55vh;
    }

    .filter-dropdown-content {
        max-width: calc(100vw - 24px);
    }

    /* ===== POPUPS ===== */
    .text-popup,
    .channels-popup,
    .action-popup {
        max-width: calc(100vw - 32px);
        font-size: 12px;
    }

    /* ===== HIDE LESS IMPORTANT ELEMENTS ON MOBILE ===== */
    .hide-mobile {
        display: none !important;
    }

    /* ===== TOP BAR MOBILE LAYOUT ===== */
    .top-bar-left {
        flex-wrap: wrap;
        max-width: calc(100vw - 80px);
    }

    /* Account switcher and group filter - icon only on mobile */
    .account-switcher,
    .group-filter {
        margin-left: 6px !important;
    }

    .account-switcher-btn,
    .group-filter-btn {
        padding: 8px !important;
        gap: 0 !important;
        min-width: 36px;
        justify-content: center;
    }

    /* Hide text and arrows on mobile - show only icons */
    .account-switcher-name,
    .group-filter-name,
    .account-switcher-arrow,
    .group-filter-arrow {
        display: none !important;
    }

    .account-switcher-icon,
    .group-filter-btn svg:first-child {
        width: 18px !important;
        height: 18px !important;
    }

    /* Action bar groups */
    .action-bar-group {
        flex-wrap: wrap;
        gap: 6px;
    }
}

@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

}

/* ============================================
   Legacy Index Page Styles (campaigns table)
   ============================================ */

/* Header logo - old structure */
.header .logo h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.15s;
}

.nav-link:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.nav-link svg { width: 16px; height: 16px; }

.logout-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.logout-btn:hover {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: var(--danger);
}

.logout-btn svg { width: 14px; height: 14px; }

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-email {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Stats Header */
.stats-header {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    margin-bottom: 16px;
    width: 100%;
}

.stats-header .stat-card {
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.stat-card-icon {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.stat-card-icon svg { width: 16px; height: 16px; }

.stat-card-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.stat-card-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.stat-card-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-sparkline {
    margin-left: auto;
    opacity: 0.7;
}

/* Status badges in stat card */
.stat-card-statuses { }
.status-badges-row {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}
.status-mini-badge {
    display: none;
    align-items: center;
    padding: 1px 6px;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
}
.status-mini-badge.visible { display: inline-flex; }
.status-mini-active { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.status-mini-declined { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
.status-mini-review { background: rgba(148, 163, 184, 0.15); color: #64748b; }
.status-mini-stopped { background: rgba(148, 163, 184, 0.15); color: #64748b; }
.status-mini-hold { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }

/* ============================================
   Stats Header — Responsive (MUST be after base rules)
   ============================================ */
@media (max-width: 1280px) {
    .stats-header {
        grid-template-columns: repeat(4, 1fr);
    }
    .stats-header .stat-card {
        padding: 8px 10px;
    }
}

@media (max-width: 768px) {
    .stats-header {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    .stats-header .stat-card {
        padding: 8px;
        gap: 8px;
    }
    .stats-header .stat-card-icon {
        width: 22px;
        height: 22px;
        border-radius: 6px;
    }
    .stats-header .stat-card-icon svg {
        width: 11px;
        height: 11px;
    }
    .stats-header .stat-sparkline {
        display: none;
    }
    .stats-header .stat-card-value {
        font-size: 14px;
    }
    .stats-header .stat-card-label {
        font-size: 9px;
    }
    .stats-header .stat-card-statuses {
        grid-column: 1 / -1;
    }
}

@media (max-width: 640px) {
    .stats-header {
        grid-template-columns: repeat(2, 1fr);
    }
    .stats-header .stat-card {
        gap: 0;
        padding: 8px 10px;
    }
    .stats-header .stat-card-icon {
        display: none;
    }
    .stats-header .stat-card-statuses {
        grid-column: 1 / -1;
    }
}

/* Action Bar */
.action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    width: 100%;
}

.action-bar-left, .action-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.action-bar-right {
    flex-shrink: 1;
    min-width: 0;
}

.sync-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.sync-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.sync-btn svg { width: 14px; height: 14px; }

.sync-btn.syncing svg {
    animation: spin 1s linear infinite;
}

.last-sync-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 4px;
}

.last-sync-time:not(:empty)::before {
    content: "•";
    margin-right: 4px;
}

.campaign-count {
    font-size: 12px;
    color: var(--text-muted);
}

.campaign-count strong {
    color: var(--text-primary);
}

.reset-filters-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 500;
    color: var(--primary);
    background: rgba(37, 99, 235, 0.08);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    vertical-align: middle;
}

.reset-filters-btn:hover {
    background: rgba(37, 99, 235, 0.15);
    border-color: var(--primary);
}

.reset-filters-btn svg {
    flex-shrink: 0;
}

/* Period Selector */
.period-selector {
    display: flex;
    gap: 2px;
    background: var(--border-light);
    padding: 2px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.period-btn {
    padding: 5px 10px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.period-btn:hover { color: var(--text-primary); }

.period-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.period-custom {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: 4px;
}

.period-custom input[type="number"] {
    width: 40px;
    height: 27px;
    padding: 0 6px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 11px;
    text-align: center;
    background: white;
}

.period-custom input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
}

/* Hide arrows in number input */
.period-custom input[type="number"]::-webkit-inner-spin-button,
.period-custom input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.period-custom input[type="number"] {
    -moz-appearance: textfield;
}

.period-unit-toggle {
    display: flex;
    gap: 1px;
    background: var(--border-light);
    padding: 1px;
    border-radius: var(--radius-sm);
}

.unit-btn {
    padding: 4px 8px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    min-width: 20px;
}

.unit-btn:hover {
    color: var(--text-primary);
}

.unit-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* ===== CUSTOM DATE RANGE PICKER (Campaign Table) ===== */
.period-daterange-wrapper {
    position: relative;
    margin-left: 4px;
}

.period-btn-daterange {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.period-btn-daterange:hover { color: var(--text-primary); }
.period-btn-daterange.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.period-daterange-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 1000;
    background: white;
    border-radius: 14px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.14), 0 0 0 1px rgba(0,0,0,0.06);
    display: none;
    min-width: 560px;
    max-width: calc(100vw - 16px);
    animation: drpSlideIn 0.18s ease-out;
}
.period-daterange-panel.open { display: block; }

@keyframes drpSlideIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.drp-presets {
    display: flex;
    gap: 4px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
}
.drp-preset {
    padding: 5px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.drp-preset:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.drp-preset.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.drp-calendars {
    display: flex;
    gap: 12px;
    padding: 14px;
}
.drp-cal-group {
    flex: 1;
    min-width: 0;
}
.drp-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.drp-hour-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 7px 10px;
    background: var(--bg-secondary);
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    transition: border-color 0.2s;
}
.drp-hour-row:focus-within {
    border-color: var(--primary);
}
.drp-hour-row svg {
    color: var(--text-muted);
    flex-shrink: 0;
}
.drp-hour-select {
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: inherit;
    outline: none;
    cursor: pointer;
    flex: 1;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.drp-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-secondary);
    border-radius: 0 0 14px 14px;
}
.drp-summary {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}
.drp-summary strong {
    color: var(--text-primary);
}
.drp-actions {
    display: flex;
    gap: 6px;
}
.drp-btn {
    padding: 7px 16px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    border: none;
    font-family: inherit;
}
.drp-btn-cancel {
    background: var(--border-light);
    color: var(--text-muted);
}
.drp-btn-cancel:hover { background: var(--border-color); }
.drp-btn-apply {
    background: var(--primary);
    color: white;
}
.drp-btn-apply:hover { background: var(--primary-hover); }
.drp-btn-apply:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Flatpickr overrides inside panel */
.drp-cal-group .flatpickr-calendar {
    box-shadow: none !important;
    border: 1.5px solid var(--border-color) !important;
    border-radius: 10px !important;
    width: 100% !important;
    font-family: inherit !important;
}
.drp-cal-group .flatpickr-day.selected,
.drp-cal-group .flatpickr-day.selected:hover {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
}
.drp-cal-group .flatpickr-day.today:not(.selected) {
    border-color: var(--primary) !important;
}


/* ============================================
   Unified Period Trigger Button
   ============================================ */
.period-trigger-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.period-trigger-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.period-trigger-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(37, 99, 235, 0.06);
}
.period-trigger-arrow {
    opacity: 0.5;
    transition: transform 0.15s;
}
.period-daterange-wrapper.open .period-trigger-arrow {
    transform: rotate(180deg);
}

/* Quick row inside unified panel */
.drp-quick-row {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
}
.drp-quick-btn {
    flex: 1;
    padding: 6px 0;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    text-align: center;
}
.drp-quick-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.drp-quick-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Custom N hours/days row */
.drp-custom-row {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
}
.drp-custom-group {
    display: flex;
    align-items: center;
    gap: 8px;
}
.drp-custom-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}
.drp-custom-input {
    width: 56px;
    height: 30px;
    padding: 0 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    background: white;
    font-family: inherit;
    color: var(--text-primary);
}
.drp-custom-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}
.drp-custom-input::-webkit-inner-spin-button,
.drp-custom-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.drp-custom-input { -moz-appearance: textfield; }

.drp-unit-toggle {
    display: flex;
    gap: 1px;
    background: var(--border-light);
    padding: 2px;
    border-radius: 6px;
}
.drp-unit-btn {
    padding: 5px 10px;
    background: transparent;
    border: none;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.drp-unit-btn:hover { color: var(--text-primary); }
.drp-unit-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.drp-custom-apply {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    background: var(--primary);
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
}
.drp-custom-apply:hover { background: var(--primary-hover); }

/* Divider between period buttons and date presets */
.drp-presets-divider {
    width: 1px;
    height: 20px;
    background: var(--border-color);
    flex-shrink: 0;
    align-self: center;
}

/* Quick buttons inside presets row — same style as drp-preset */
.drp-presets .drp-quick-btn {
    flex: none;
    padding: 5px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    text-align: center;
}
.drp-presets .drp-quick-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.drp-presets .drp-quick-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* ============================================
   More Menu (Settings Popover)
   ============================================ */
.more-menu-wrapper {
    position: relative;
}
.more-menu-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}
.more-menu-trigger:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.more-menu-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 1000;
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.06);
    min-width: 220px;
    padding: 6px 0;
    display: none;
    animation: drpSlideIn 0.15s ease-out;
}
.more-menu-panel.open { display: block; }

.more-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 12px;
    color: var(--text-secondary);
}
.more-menu-item svg { flex-shrink: 0; color: var(--text-muted); }
.more-menu-item span { flex: 1; }

.more-menu-select {
    padding: 3px 6px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 11px;
    font-weight: 500;
    background: white;
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
}

.more-menu-divider {
    height: 1px;
    background: var(--border-light);
    margin: 4px 0;
}

.more-menu-action {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 14px;
    background: none;
    border: none;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.1s;
    font-family: inherit;
    text-align: left;
}
.more-menu-action:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}
.more-menu-action svg { flex-shrink: 0; color: var(--text-muted); }
.more-menu-action.active { color: var(--primary); }
.more-menu-action.active svg { color: var(--primary); }

/* ============================================
   Compact Flatpickr inside panel
   ============================================ */
.drp-cal-group .flatpickr-calendar {
    font-size: 12px !important;
}
.drp-cal-group .flatpickr-day {
    height: 28px !important;
    line-height: 28px !important;
    max-width: 28px !important;
}
.drp-cal-group .flatpickr-months {
    padding: 4px 0 !important;
}
.drp-cal-group .flatpickr-current-month {
    font-size: 12px !important;
}
.drp-cal-group .dayContainer {
    min-width: 196px !important;
    max-width: 196px !important;
}
.drp-cal-group .flatpickr-innerContainer {
    max-width: 224px;
}

/* Unified panel adjustments (desktop) */
.period-daterange-panel {
    min-width: 480px;
}

/* ============================================
   Responsive — Action bar & period panel mobile
   ============================================ */
@media (max-width: 768px) {
    /* Period panel: full-width fixed */
    .period-daterange-panel {
        min-width: unset;
        width: calc(100vw - 24px);
        left: 12px !important;
        right: auto !important;
        max-height: 85vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Presets: wrap into grid */
    .drp-presets {
        gap: 6px;
        padding: 10px 12px;
    }
    .drp-presets .drp-quick-btn,
    .drp-presets .drp-preset {
        padding: 8px 10px;
        font-size: 11px;
        min-height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .drp-presets-divider {
        width: 100%;
        height: 1px;
        align-self: stretch;
    }

    /* Calendars stack */
    .drp-calendars {
        flex-direction: column;
        padding: 10px;
    }
    .drp-cal-group {
        width: 100%;
    }
    .drp-cal-group .flatpickr-calendar {
        width: 100% !important;
    }
    .drp-cal-group .dayContainer {
        min-width: 100% !important;
        max-width: 100% !important;
    }
    .drp-cal-group .flatpickr-innerContainer {
        max-width: 100%;
    }
    .drp-cal-group .flatpickr-day {
        height: 36px !important;
        line-height: 36px !important;
        max-width: 36px !important;
    }

    /* Footer: stack on narrow */
    .drp-footer {
        flex-wrap: wrap;
        gap: 8px;
    }
    .drp-actions {
        width: 100%;
        display: flex;
        gap: 8px;
    }
    .drp-btn {
        flex: 1;
        min-height: 40px;
        padding: 8px 12px;
    }

    /* More menu: constrain width on mobile, keep absolute */
    .more-menu-panel {
        min-width: 200px;
        max-width: calc(100vw - 24px);
    }

    /* Touch targets: bigger more trigger */
    .more-menu-trigger {
        width: 40px;
        height: 40px;
    }
    .period-trigger-btn {
        padding: 8px 10px;
        font-size: 11px;
    }
}

@media (max-width: 640px) {
    /* Action bar: stack left/right */
    .action-bar-left {
        flex-wrap: wrap;
    }
    .action-bar-right {
        width: 100%;
        justify-content: flex-end;
    }

    /* Preset buttons: smaller on tiny phones */
    .drp-presets .drp-quick-btn,
    .drp-presets .drp-preset {
        padding: 7px 8px;
        font-size: 10px;
    }
}

/* Alert */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 12px;
    margin-bottom: 12px;
}

.alert-info {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.alert-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-icon { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-content { flex: 1; }

/* Loading Overlay */
/* Sync progress banner — inline, doesn't hide table */
.sync-progress-banner {
    background: var(--bg-secondary, #f8f9fb);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 12px;
}

.sync-progress-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sync-progress-text {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.sync-progress-text .loading-text {
    font-weight: 500;
    font-size: inherit;
    margin-top: 0;
}

.sync-progress-detail {
    color: var(--text-muted);
    font-size: 12px;
}

/* Legacy loading overlay (used by showLoading/hideLoading for batch operations) */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

.loading-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Table container - popup wrapper */
.table-container {
    position: relative;
    margin: 0 -16px;
    padding: 0 16px;
}

/* Inner scroll container */
.table-scroll {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
    max-width: 100%;
}

.table-scroll::-webkit-scrollbar {
    height: 6px;
}

.table-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.table-scroll::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.table-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Campaigns Table */
.campaigns-table {
    /* Size to content, never stretch columns to fill. With width:100% +
       table-layout:auto, hiding a column made the browser redistribute the freed
       width into the remaining columns (e.g. LEADS ballooned with its value stuck
       left). max-content keeps every column at its natural width: a hidden column
       frees space on the RIGHT, the rest don't move. Still scrolls when the full
       set is wider than the container (it always is on desktop). min-width:0 so a
       narrow (few-column) table can sit content-width, left-aligned, instead of
       being stretched back to the container width. */
    width: max-content;
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 11px;
}

.campaigns-table th,
.campaigns-table td {
    padding: 4px 5px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    vertical-align: middle;
    font-variant-numeric: tabular-nums lining-nums;
}

.campaigns-table th {
    background: #f8f9fb;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    z-index: 2;
    border-bottom: 2px solid var(--border-color);
    padding-top: 8px;
    padding-bottom: 8px;
}

.campaigns-table tbody tr {
    transition: background 0.15s ease;
    /* Browser-native viewport culling: off-screen rows skip layout/paint.
       Reduces lag on tables with 5000+ rows from seconds to imperceptible. */
    content-visibility: auto;
    contain-intrinsic-size: auto 44px;
}

.campaigns-table tbody tr:hover {
    background: rgba(37, 99, 235, 0.035);
}

.campaigns-table tbody tr.row-selected {
    background: rgba(37, 99, 235, 0.06);
    box-shadow: inset 3px 0 0 var(--primary);
}

/* Title column */
.campaigns-table td:nth-child(3) {
    max-width: 150px;
    position: relative;
}

/* Spent column */
.campaigns-table td:nth-child(14) {
    max-width: 140px;
}

/* Budget column */
.campaigns-table td:nth-child(15) {
    max-width: 140px;
}

/* Text column (col 23 after the 7 postback/cost columns: Leads·CPL·Conv·CPCv·Buys·CPS·Revenue) */
.campaigns-table td:nth-child(23) {
    max-width: 140px;
    width: 140px;
}

/* Target column (col 24) */
.campaigns-table td:nth-child(24) {
    max-width: 140px;
}

/* Preview wrapper containers - constrain content without hiding popup */
.text-preview-wrap,
.channels-preview-wrap {
    position: relative;
    display: block;
    width: 100%;
    max-width: calc(100% - 8px);
}

/* Truncate the text span inside preview wrappers */
.campaigns-table td .text-preview-wrap > span:first-child,
.campaigns-table td .channels-preview-wrap > span:first-child {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.campaigns-table tbody tr {
    background: white;
    transition: background 0.1s;
}

/* Group rows styling */
.campaigns-table tbody tr.group-row {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.02) 0%, rgba(37, 99, 235, 0.02) 100%);
}

.campaigns-table tbody tr.group-row:hover {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.06) 0%, rgba(37, 99, 235, 0.06) 100%);
}

.campaigns-table tbody tr.group-row td {
    vertical-align: middle;
}

.campaigns-table tbody tr:hover {
    background: var(--primary-light);
}

.campaigns-table tbody tr.selected {
    background: rgba(37, 99, 235, 0.12);
}

.checkbox-cell {
    width: 32px;
    text-align: center !important;
}

.row-checkbox {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* Sortable headers */
.sortable {
    cursor: pointer;
    user-select: none;
}

.sortable:hover {
    color: var(--primary);
}

.sort-arrow {
    display: inline-block;
    margin-left: 2px;
    font-size: 8px;
    opacity: 0;
    color: var(--primary);
}

.filter-icon {
    background: none;
    border: none;
    padding: 2px;
    cursor: pointer;
    color: var(--text-muted);
    opacity: 0.5;
    transition: opacity 0.15s;
    vertical-align: middle;
    margin-left: 2px;
}

.filter-icon:hover { opacity: 1; color: var(--primary); }
.filter-icon.active { opacity: 1; color: var(--primary); }

/* Filter popup */
.filter-popup {
    position: fixed;
    z-index: 9000;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 12px;
    min-width: 200px;
    max-width: 280px;
}

.filter-popup-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filter-popup select,
.filter-popup input[type="text"],
.filter-popup input[type="number"] {
    width: 100%;
    padding: 6px 10px;
    font-size: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    background: white;
}

.filter-popup select:focus,
.filter-popup input:focus {
    outline: none;
    border-color: var(--primary);
}

.filter-popup .filter-actions,
.filter-popup .filter-buttons {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.filter-popup .filter-actions button,
.filter-popup .filter-buttons button,
.filter-popup .filter-btn {
    flex: 1;
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.filter-popup .filter-actions .apply-btn,
.filter-popup .filter-btn-apply {
    background: var(--primary);
    color: white;
    border: none;
}

.filter-popup .filter-actions .apply-btn:hover,
.filter-popup .filter-btn-apply:hover {
    background: var(--primary-hover);
}

.filter-popup .filter-actions .clear-btn,
.filter-popup .filter-btn-clear {
    background: white;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.filter-popup .filter-actions .clear-btn:hover,
.filter-popup .filter-btn-clear:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* Filter checkbox list (for multiselect status) */
.filter-checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 200px;
    overflow-y: auto;
}

.filter-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
}

.filter-checkbox-item:hover {
    background: var(--bg-secondary);
}

.filter-checkbox-item input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: var(--primary);
}

.filter-checkbox-item .status-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 500;
}

.filter-checkbox-item .status-badge.status-active { background: var(--success-bg); color: var(--success); }
.filter-checkbox-item .status-badge.status-on-hold { background: var(--warning-bg); color: var(--warning); }
.filter-checkbox-item .status-badge.status-stopped { background: rgba(148, 163, 184, 0.15); color: #64748b; }
.filter-checkbox-item .status-badge.status-declined { background: var(--danger-bg); color: var(--danger); }
.filter-checkbox-item .status-badge.status-in-review { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); }
.filter-checkbox-item .status-badge.status-deleted { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); }

/* Date filter quick buttons */
.filter-quick-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.filter-quick-btn {
    padding: 6px 12px;
    font-size: 12px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    color: var(--text-secondary);
}

.filter-quick-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

.filter-quick-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Date filter custom period */
.filter-custom-period {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 4px;
}

.filter-custom-period input[type="number"] {
    flex: 0 0 80px;
}

.filter-custom-period select {
    flex: 0 0 100px;
}

/* Status badges for table */
.status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-active, .status-Active { background: var(--success-bg); color: var(--success); }
.status-on_hold, .status-OnHold { background: var(--warning-bg); color: var(--warning); }
.status-stopped, .status-Stopped { background: rgba(148, 163, 184, 0.15); color: #64748b; }
.status-declined, .status-Declined { background: var(--danger-bg); color: var(--danger); }
.status-pending, .status-Pending, .status-in_review, .status-InReview {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-muted);
}
.status-draft, .status-Draft { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); }

/* Table media cell */
.media-preview {
    width: 36px;
    height: 24px;
    object-fit: cover;
    border-radius: 4px;
}

/* Table action buttons */
.table-actions {
    display: flex;
    gap: 3px;
    align-items: center;
}

.table-action-btn {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.table-action-btn svg { width: 13px; height: 13px; }

.table-action-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.15);
}

.table-action-btn.danger:hover {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: var(--danger);
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.15);
}

.table-action-btn.success:hover {
    background: var(--success-bg);
    border-color: var(--success);
    color: var(--success);
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.15);
}

.table-action-btn.warning:hover {
    background: var(--warning-bg);
    border-color: var(--warning);
    color: var(--warning);
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.15);
}

/* Actions Menu Dropdown */
.actions-menu-wrap {
    position: relative;
    display: inline-block;
}

.actions-menu-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.actions-menu-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.actions-menu-btn svg {
    width: 14px;
    height: 14px;
}

.actions-menu-popup {
    display: none;
    position: fixed;
    z-index: 99999;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    min-width: 160px;
    padding: 6px 0;
    pointer-events: auto;
}

/* Bridge to prevent hover gap with fixed positioning */
.actions-menu-popup::before {
    content: '';
    position: absolute;
    top: -15px;
    left: -30px;
    right: -30px;
    height: 20px;
}

.actions-menu-popup.popup-open,
.actions-menu-popup.show {
    display: block;
}

.actions-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.actions-menu-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.actions-menu-item.actions-menu-danger:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.actions-menu-icon {
    font-size: 14px;
    width: 20px;
    text-align: center;
}

/* Automation badge */
.automation-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.1) 0%, rgba(37, 99, 235, 0.1) 100%);
    border: 1px solid rgba(37, 99, 235, 0.2);
    color: var(--primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.automation-badge:hover {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.2) 0%, rgba(37, 99, 235, 0.2) 100%);
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.2);
}

.automation-badge svg { width: 13px; height: 13px; }

/* No automation placeholder */
.no-automation {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--border-light);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    opacity: 0.5;
    cursor: pointer;
    transition: all 0.15s;
}

.no-automation:hover {
    opacity: 1;
    border-style: solid;
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.no-automation svg { width: 11px; height: 11px; }

/* Batch actions for old structure */
.batch-actions-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    padding-right: 16px;
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    color: var(--text-secondary);
}

.batch-actions-label .count {
    font-weight: 700;
    color: var(--primary);
}

.batch-actions-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Modal legacy structure */
@keyframes modalOverlayIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalContentIn {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal.show {
    display: flex;
    animation: modalOverlayIn 0.2s ease;
}

.modal.show .modal-content {
    animation: modalContentIn 0.25s ease both;
}

.modal-content {
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 16px;
    box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.2), 0 8px 24px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

.modal-content.modal-lg { max-width: 600px; }
.modal-content.modal-xl { max-width: 800px; }

/* Global Rules List */
.rules-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.rules-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
    font-size: 12px;
}

.rule-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.rule-item.inactive {
    opacity: 0.6;
}

.rule-info {
    flex: 1;
    min-width: 0;
}

.rule-name {
    font-weight: 500;
    font-size: 12px;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.rule-description {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rule-stats {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
}

.rule-actions {
    display: flex;
    gap: 4px;
    margin-left: 12px;
}

.rule-actions button {
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    transition: all 0.15s;
}

.rule-actions button:hover {
    background: var(--primary);
    color: white;
}

.rule-actions button.btn-danger:hover {
    background: var(--danger);
}

/* Conditions list for multiple conditions */
.conditions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.condition-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.condition-row select,
.condition-row input {
    flex: 1;
    min-width: 0;
}

.condition-row .condition-source {
    flex: 0 0 90px;
    font-size: 11px;
}

.condition-row .btn-remove-condition {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition: all 0.15s;
}

.condition-row .btn-remove-condition:hover {
    background: var(--danger);
    color: white;
}

.condition-row:only-child .btn-remove-condition {
    visibility: hidden;
}

.check-interval-input {
    display: flex;
    align-items: center;
    gap: 8px;
}

.check-interval-input span {
    font-size: 12px;
    color: var(--text-secondary);
}

.form-hint {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 11px;
}

.mt-1 {
    margin-top: 8px;
}

.rule-form-section {
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
    margin-top: 8px;
}

.form-section-title {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.checkbox-group {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-label input {
    width: 14px;
    height: 14px;
    accent-color: var(--primary);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}

.modal-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
}

/* Form controls legacy */
.form-label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
}

.form-checkbox input {
    width: 14px;
    height: 14px;
    accent-color: var(--primary);
}

/* Tabs legacy */
.tabs {
    display: flex;
    gap: 2px;
    background: var(--border-light);
    padding: 2px;
    border-radius: var(--radius-sm);
}

.tab {
    padding: 6px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.tab:hover { color: var(--text-primary); }
.tab.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* Utility classes */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.p-3 { padding: 12px; }
.w-full { width: 100%; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--border-light);
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
}

.badge-primary {
    background: var(--primary);
    color: white;
}

/* Progress */
.progress-container {
    margin: 12px 0;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.progress-text {
    font-size: 11px;
    color: var(--text-muted);
}

.progress-bar {
    height: 6px;
    background: var(--border-light);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s;
}

/* Upgrade modal */
.upgrade-modal .modal-content {
    max-width: 400px;
    text-align: center;
}

.upgrade-modal .modal-body {
    padding: 32px 24px;
}

.upgrade-modal-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: var(--primary-light);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.upgrade-modal-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

.upgrade-modal-feature {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 8px;
}

.upgrade-modal-text {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.upgrade-modal-features {
    list-style: none;
    padding: 0;
    margin: 0 0 20px 0;
    text-align: left;
}

.upgrade-modal-features li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.upgrade-modal-features li::before {
    content: '';
    width: 16px;
    height: 16px;
    background: var(--success);
    mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='3' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
    -webkit-mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='3' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
    flex-shrink: 0;
}

.upgrade-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Empty state in table */
.campaigns-table .empty-state {
    text-align: center;
    padding: 48px 20px;
}

.empty-state-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    background: var(--primary-light);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.empty-state-icon svg { width: 18px; height: 18px; }

.empty-state-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.empty-state-text {
    font-size: 12px;
    color: var(--text-muted);
}

/* Account switcher */
.account-switcher select {
    padding: 6px 28px 6px 10px;
    font-size: 12px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

/* ============================================
   Table Preview Popups
   ============================================ */

/* Base popup wrapper styles */
.text-preview-wrap,
.media-preview-wrap,
.stats-preview-wrap,
.action-preview-wrap,
.channels-preview-wrap {
    position: relative;
    display: inline-block;
}

/* Base popup styles — position:fixed to escape overflow:auto on .table-scroll */
.text-preview-popup,
.media-preview-popup,
.stats-preview-popup,
.action-preview-popup,
.channels-preview-popup,
.promote-url-popup {
    display: none;
    position: fixed;
    top: -9999px;
    left: -9999px;
    z-index: 99999;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
    padding: 12px 14px;
    font-size: 12px;
    color: var(--text-primary);
    white-space: normal;
    min-width: 200px;
    max-width: 350px;
    pointer-events: auto;
}

/* Invisible bridge between trigger and popup to prevent hover gap */
.text-preview-popup::before,
.media-preview-popup::before,
.stats-preview-popup::before,
.action-preview-popup::before,
.channels-preview-popup::before,
.promote-url-popup::before {
    content: '';
    position: absolute;
    left: -20px;
    right: -20px;
    height: 12px;
}

/* Bridge above popup (when popup is below trigger) */
.text-preview-popup::before,
.media-preview-popup::before,
.stats-preview-popup::before,
.action-preview-popup::before,
.channels-preview-popup::before,
.promote-url-popup::before {
    top: -12px;
}

/* Bridge below popup (when popup is above trigger) */
.text-preview-popup.popup-above::before,
.media-preview-popup.popup-above::before,
.stats-preview-popup.popup-above::before,
.action-preview-popup.popup-above::before,
.channels-preview-popup.popup-above::before,
.promote-url-popup.popup-above::before {
    top: auto;
    bottom: -12px;
}

/* Show popup when JS opens it — hover-intent with a close delay (dashboard.js).
   Pure :hover hid the popup the moment the cursor crossed the trigger→popup gap. */
.text-preview-popup.popup-open,
.media-preview-popup.popup-open,
.stats-preview-popup.popup-open,
.action-preview-popup.popup-open,
.channels-preview-popup.popup-open,
.promote-url-popup.popup-open {
    display: block;
}

/* Text preview popup */
.text-preview-popup {
    word-wrap: break-word;
    line-height: 1.5;
}

/* Media preview popup */
.media-preview-popup {
    padding: 8px;
    min-width: 180px;
}

.media-preview-popup img,
.media-preview-popup video {
    max-width: 250px;
    max-height: 180px;
    border-radius: var(--radius-sm);
    display: block;
}

.media-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--border-light);
    color: var(--text-muted);
}

.media-badge.media-image { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.media-badge.media-video { background: rgba(37, 99, 235, 0.1); color: #3b82f6; }
.media-badge.media-gif { background: rgba(236, 72, 153, 0.1); color: #ec4899; }

/* Stats preview popup */
.stats-preview-popup {
    min-width: 220px;
}

.stats-popup-loading,
.action-popup-loading {
    text-align: center;
    color: var(--text-muted);
    padding: 8px;
}

.stats-popup-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stats-popup-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
}

.stats-popup-row .label {
    color: var(--text-muted);
}

.stats-popup-row .value {
    font-weight: 600;
}

/* Action preview popup */
.action-preview-popup {
    min-width: 280px;
    max-width: 400px;
}

.action-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 9px;
    font-weight: 500;
    background: var(--border-light);
    color: var(--text-muted);
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Auto CPM action — amber/warning color, matches the ⚡ button */
.action-badge.action-cpm_auto,
.action-type.action-type-cpm_auto {
    background: rgba(245, 158, 11, 0.12);
    color: #b45309;
}

.action-popup-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-popup-item {
    padding: 6px 0;
    border-bottom: 1px solid var(--border-light);
}

.action-popup-item:last-child {
    border-bottom: none;
}

.action-popup-item .action-type {
    font-weight: 600;
    font-size: 11px;
    margin-bottom: 2px;
}

.action-popup-item .action-details {
    font-size: 10px;
    color: var(--text-muted);
}

.action-popup-item .action-time {
    font-size: 9px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Action History Popup */
.action-popup-title {
    font-weight: 600;
    font-size: 11px;
    color: var(--text-secondary);
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

.action-popup-empty,
.action-popup-error {
    text-align: center;
    color: var(--text-muted);
    font-size: 11px;
    padding: 12px 8px;
}

.action-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-history-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 8px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 11px;
}

.action-history-row .action-time {
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: 10px;
    min-width: 50px;
}

.action-history-row .action-type {
    flex-shrink: 0;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    min-width: 60px;
    text-align: center;
}

.action-type-edit { background: #dbeafe; color: #1d4ed8; }
.action-type-create { background: #dcfce7; color: #16a34a; }
.action-type-delete { background: #fee2e2; color: #dc2626; }
.action-type-status { background: #fef3c7; color: #d97706; }
.action-type-budget { background: #e0e7ff; color: #1d4ed8; }
.action-type-cpm { background: #eff6ff; color: #3b82f6; }
.action-type-default { background: var(--border-light); color: var(--text-muted); }

.action-history-row .action-values {
    flex: 1;
    font-size: 10px;
    color: var(--text-secondary);
    word-break: break-word;
}

.action-values .action-old {
    color: #dc2626;
    text-decoration: line-through;
    background: #fee2e2;
    padding: 1px 4px;
    border-radius: 2px;
}

.action-values .action-new {
    color: #16a34a;
    font-weight: 500;
    background: #dcfce7;
    padding: 1px 4px;
    border-radius: 2px;
}

.action-values .action-deleted {
    color: #dc2626;
    font-weight: 500;
    background: #fee2e2;
    padding: 1px 4px;
    border-radius: 2px;
}

/* Channels preview popup */
.channels-preview-popup {
    min-width: 250px;
    max-width: 350px;
    max-height: 300px;
    overflow-y: auto;
}

.channels-popup-title {
    font-weight: 600;
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-light);
}

.channels-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.channel-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    transition: background 0.1s;
}

.channel-item:hover {
    background: var(--primary-light);
    cursor: pointer;
}

.channel-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.channel-username {
    color: var(--text-primary);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.channel-item a {
    color: var(--primary);
    text-decoration: none;
}

.channel-item a:hover {
    text-decoration: underline;
}

/* Keyword items for search targeting */
.keywords-list {
    gap: 6px;
}

.keyword-item {
    display: flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    font-size: 12px;
    transition: background 0.1s;
}

.keyword-item:hover {
    background: var(--primary-light);
}

.keyword-text {
    color: var(--text-primary);
    font-weight: 500;
}

.channels-text-with-popup {
    cursor: pointer;
    color: var(--primary);
}

.channels-text-with-popup:hover {
    text-decoration: underline;
}

/* Target secondary info (device, platform) */
.target-secondary {
    color: var(--text-secondary);
    font-size: 0.85em;
}

/* ===== DECLINE REASON POPUP ===== */
.decline-preview-wrap {
    position: relative;
    display: inline-block;
}

.decline-preview-popup {
    display: none;
    position: fixed;
    top: -9999px;
    left: -9999px;
    z-index: 99999;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(239, 68, 68, 0.15);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 30px rgba(239, 68, 68, 0.12), 0 0 0 1px rgba(239, 68, 68, 0.08);
    padding: 14px 16px;
    font-size: 12px;
    color: var(--text-primary);
    min-width: 280px;
    max-width: 380px;
    overflow: hidden;
}

.decline-preview-popup.visible {
    display: block;
}

.status-badge.clickable {
    cursor: pointer;
    transition: all 0.15s;
}

.status-badge.clickable:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.decline-popup-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    padding: 8px 0;
}

.decline-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.decline-header {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.decline-reason {
    font-size: 15px;
    font-weight: 600;
    color: #dc2626;
}

.decline-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    white-space: normal;
}

.decline-link {
    font-size: 11px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.decline-link:hover {
    text-decoration: underline;
}

.decline-review-status {
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
    font-size: 11px;
    font-weight: 500;
}

.decline-review-status.can-review .review-available {
    color: #16a34a;
}

.decline-review-status.no-review .review-unavailable {
    color: #94a3b8;
}

.decline-error {
    color: #dc2626;
    font-size: 12px;
}

/* Stats value in table */
.stats-value {
    cursor: default;
}

/* Upgrade button */
.upgrade-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(135deg, var(--primary) 0%, #60a5fa 100%);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    color: white;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s;
}

.upgrade-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.upgrade-btn svg {
    width: 14px;
    height: 14px;
}

/* Hide upgrade button when user has paid plan */
.upgrade-btn.hidden {
    display: none;
}

/* ===== TABLE ROW ACTION BUTTONS - MODERN DESIGN ===== */

/* Base row button style */
.row-btn {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 10px;
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.row-btn svg {
    width: 12px;
    height: 12px;
}

.row-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.row-btn:active {
    transform: translateY(0);
}

/* Primary button - Edit (blue gradient) */
.row-btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #60a5fa 100%);
    color: white;
}

.row-btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #7273e5 100%);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

/* CPM button (purple gradient) */
.row-btn-cpm {
    background: linear-gradient(135deg, #3b82f6 0%, #93c5fd 100%);
    color: white;
}

.row-btn-cpm:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 100%);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

/* Budget button (amber/orange gradient) */
.row-btn-budget {
    background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
    color: white;
}

.row-btn-budget:hover {
    background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

/* Recreate button (cyan/teal gradient) */
.row-btn-recreate {
    background: linear-gradient(135deg, #06b6d4 0%, #22d3ee 100%);
    color: white;
}

.row-btn-recreate:hover {
    background: linear-gradient(135deg, #0891b2 0%, #06b6d4 100%);
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.4);
}

/* Success button - Play/Start (green gradient) */
.row-btn-success {
    background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    color: white;
}

.row-btn-success:hover {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

/* Warning button - Pause/Stop (orange gradient) */
.row-btn-warning {
    background: linear-gradient(135deg, #f97316 0%, #fb923c 100%);
    color: white;
}

.row-btn-warning:hover {
    background: linear-gradient(135deg, #ea580c 0%, #f97316 100%);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
}

/* Danger button - Delete (red gradient) */
.row-btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #f87171 100%);
    color: white;
}

.row-btn-danger:hover {
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

/* Row actions container */
.row-actions {
    min-width: 40px;
    vertical-align: middle;
}

/* Ensure Actions column cell has minimum width */
.campaigns-table td:last-child,
.campaigns-table th:last-child {
    min-width: 50px;
    position: relative;
    vertical-align: middle;
}

/* Fix actions menu wrap visibility */
.campaigns-table .actions-menu-wrap {
    position: relative;
    display: inline-flex;
}

/* ===== AUTOMATION BUTTON - MODERN DESIGN ===== */

.auto-btn {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.25s ease;
    font-size: 11px;
    background: linear-gradient(135deg, rgba(148, 163, 184, 0.15) 0%, rgba(148, 163, 184, 0.25) 100%);
    color: #64748b;
    position: relative;
    overflow: hidden;
}

.auto-btn svg {
    width: 12px;
    height: 12px;
}

.auto-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.1) 0%, rgba(37, 99, 235, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.auto-btn:hover {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.2) 0%, rgba(37, 99, 235, 0.2) 100%);
    color: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.auto-btn:hover::before {
    opacity: 1;
}

/* Active automation state - vibrant gradient */
.auto-btn.active {
    background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.auto-btn.active:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #1d4ed8 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.45);
}

/* Pulse animation for active automation */
.auto-btn.active::after {
    content: '';
    position: absolute;
    top: -1px;
    right: -1px;
    width: 6px;
    height: 6px;
    background: #22c55e;
    border-radius: 50%;
    border: 1px solid white;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
}

.auto-cpm-btn {
    margin-left: 2px;
}
.auto-cpm-btn.active {
    color: var(--warning, #f59e0b);
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
}
.auto-cpm-btn:hover {
    color: var(--warning, #f59e0b);
    border-color: var(--warning, #f59e0b);
}
.auto-cpm-btn.stopped {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.1);
    border-color: rgba(220, 38, 38, 0.3);
}
.auto-cpm-btn.stopped:hover {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.15);
    border-color: rgba(220, 38, 38, 0.4);
}
.auto-cpm-btn.incompatible {
    color: #cbd5e1;
    cursor: help;
    opacity: 0.6;
}
.auto-cpm-btn.incompatible:hover {
    color: #94a3b8;
    background: rgba(148, 163, 184, 0.1);
    border-color: rgba(148, 163, 184, 0.2);
}

/* Visibility badges in Target column popup */
.channel-item .visibility-badge {
    margin-left: 6px;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
}
.channel-item.vis-green .channel-username { color: #16a34a; }
.channel-item.vis-amber .channel-username { color: #f59e0b; }
.channel-item.vis-orange .channel-username { color: #ea580c; }
.channel-item.vis-red .channel-username { color: #dc2626; }
.channel-item.vis-waiting .channel-username { color: #94a3b8; }

/* More menu hint (?) icon */
.more-menu-hint {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(148, 163, 184, 0.15);
    color: #64748b;
    font-size: 9px;
    font-weight: 600;
    cursor: help;
    margin-left: 2px;
}
.more-menu-hint:hover {
    background: rgba(37, 99, 235, 0.15);
    color: #2563eb;
}

/* Pro plan style for upgrade button */
.upgrade-btn.is-pro {
    background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    cursor: default;
}

.upgrade-btn.is-pro:hover {
    transform: none;
    box-shadow: none;
}

/* Similar Channels Styles */
.similar-channels-list-wrap {
    max-height: 400px;
    overflow-y: auto;
}

.similar-channels-message {
    text-align: center;
    padding: 32px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

.similar-channels-list {
    padding: 8px 0;
}

.similar-channel-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.similar-channel-item:hover {
    background: var(--bg-hover);
}

.similar-channel-checkbox {
    flex-shrink: 0;
    margin-right: 12px;
}

.similar-channel-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.similar-channel-photo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    margin-right: 12px;
    background: var(--bg-secondary);
}

.similar-channel-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.similar-channel-content {
    flex: 1;
    min-width: 0;
    margin-right: 12px;
}

.similar-channel-title {
    display: block;
    font-weight: 500;
    font-size: 14px;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.similar-channel-desc {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.similar-channel-action {
    flex-shrink: 0;
}

.similar-channel-action a {
    font-size: 13px;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.similar-channel-action a:hover {
    text-decoration: underline;
}

/* Dots animated loading */
.dots-animated::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

/* Add Similar Channels button */
.btn-similar-channels {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--primary-color);
    background: transparent;
    border: 1px solid var(--primary-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-top: 8px;
}

.btn-similar-channels:hover {
    background: var(--primary-color);
    color: white;
}

.btn-similar-channels:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-similar-channels svg {
    width: 14px;
    height: 14px;
}

/* Similar Channels Toggle */
.tg-similar-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 0 2px;
}

/* Channel Size Filter Buttons */
.channel-size-filter {
    display: flex;
    gap: 8px;
    padding: 12px 16px 8px;
}

.channel-size-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 8px 8px;
    border: 1.5px solid var(--border, #e2e8f0);
    border-radius: 10px;
    background: var(--bg-primary, #fff);
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

.channel-size-btn:hover {
    border-color: var(--primary, #2563eb);
}

.channel-size-btn.active {
    border-color: var(--primary, #2563eb);
    background: var(--primary-light, #eef2ff);
}

.channel-size-label {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary, #1e293b);
}

.channel-size-btn.active .channel-size-label {
    color: var(--primary, #2563eb);
}

.channel-size-sublabel {
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
    margin-top: 2px;
}

.channel-size-btn.active .channel-size-sublabel {
    color: var(--primary, #2563eb);
    opacity: 0.8;
}

.channel-size-recommended {
    display: none;
    font-size: 10px;
    color: #10b981;
    font-weight: 500;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.channel-size-btn[data-size="small"] .channel-size-recommended {
    display: block;
}

.channel-size-note {
    padding: 4px 16px 10px;
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
    font-style: italic;
    border-bottom: 1px solid var(--border, #e2e8f0);
}

/* ============================================
   Channel Selector (like Telegram Ads)
   ============================================ */

.tg-channel-selector {
    position: relative;
    background: #fff;
    border: none;
    border-radius: 6px;
    box-shadow: inset 0 0 0 1px #d9d9d9;
    min-height: 40px;
    transition: box-shadow 0.2s ease;
}

.tg-channel-selector:focus-within {
    box-shadow: inset 0 0 0 2px #35a3f6;
}

.tg-channel-selector.is-loading {
    pointer-events: none;
}

.tg-channel-selected-items {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding: 5px 7px;
    min-height: 28px;
}

.tg-channel-input-wrap {
    flex: 1;
    min-width: 150px;
}

.tg-channel-input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    font-size: 14px;
    line-height: 18px;
    color: #222;
    padding: 4px 0;
}

.tg-channel-input::placeholder {
    color: var(--text-muted);
}

/* Channel chip item */
.tg-channel-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 9px;
    background: var(--accent-color, #119af5);
    border-radius: 4px;
    font-size: 12px;
    line-height: 16px;
    font-weight: 600;
    -webkit-font-smoothing: antialiased;
    color: #fff;
    max-width: 200px;
    animation: chipAppear 0.2s ease;
}

@keyframes chipAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.tg-channel-item.has-photo {
    padding-left: 3px;
}

.tg-channel-item-photo {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-tertiary);
}

.tg-channel-item-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tg-channel-item-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.tg-channel-item-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 12px;
    line-height: 1;
    transition: background 0.15s ease;
}

.tg-channel-item-close:hover {
    background: rgba(255, 255, 255, 0.5);
}

.tg-channel-item-close::before {
    content: '×';
    font-weight: bold;
}

/* Progress indicator */
.tg-channel-progress {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    display: none;
}

.tg-channel-selector.is-loading .tg-channel-progress {
    display: block;
}

.tg-channel-progress::after {
    content: '';
    display: block;
    width: 100%;
    height: 100%;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: channelSpin 0.8s linear infinite;
}

@keyframes channelSpin {
    to { transform: rotate(360deg); }
}

/* Error state */
.tg-channel-selector.has-error {
    box-shadow: inset 0 0 0 1px #d75959;
}

.tg-channel-selector + .tg-form-error {
    color: var(--danger-color, #ef4444);
    font-size: 12px;
    margin-top: 4px;
}

/* ============================================
   LOCKED CAMPAIGNS (Over Plan Limit)
   ============================================ */

/* Locked row styling */
.row-locked {
    background: linear-gradient(90deg, rgba(148, 163, 184, 0.08) 0%, rgba(148, 163, 184, 0.15) 100%) !important;
    position: relative;
}

.row-locked td {
    color: #94a3b8 !important;
    filter: blur(1px);
    user-select: none;
}

.row-locked td:first-child,
.row-locked td:nth-child(2),
.row-locked td:nth-child(3),
.row-locked td:nth-child(4),
.row-locked td:nth-child(24),
.row-locked td:last-child {
    filter: none;
}

.row-locked .status-badge {
    opacity: 0.6;
}

.row-locked .locked-text {
    font-style: italic;
    color: #94a3b8;
    font-size: 11px;
}

.row-locked button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.row-locked input[type="checkbox"]:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

/* Upgrade overlay row - appears between visible and locked campaigns */
.upgrade-overlay-row {
    background: transparent !important;
}

.upgrade-overlay-row td {
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
}

/* Campaigns limit overlay banner */
.campaigns-limit-overlay {
    padding: 12px;
}

.campaigns-limit-content {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px 28px;
    background: linear-gradient(135deg, #2563eb 0%, #60a5fa 100%);
    border-radius: 16px;
    color: white;
    box-shadow: 0 8px 32px rgba(37, 99, 235, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

.campaigns-limit-icon {
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    backdrop-filter: blur(4px);
}

.campaigns-limit-icon svg {
    stroke: white;
}

.campaigns-limit-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.campaigns-limit-text strong {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.campaigns-limit-text span {
    font-size: 13px;
    opacity: 0.9;
    line-height: 1.5;
}

.campaigns-limit-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    background: white;
    color: #2563eb;
    text-decoration: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 15px;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.campaigns-limit-btn:hover {
    background: #f8fafc;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.campaigns-limit-btn svg {
    stroke: #2563eb;
}

/* Responsive overlay */
@media (max-width: 900px) {
    .campaigns-limit-content {
        flex-direction: column;
        text-align: center;
        padding: 24px;
        gap: 16px;
    }

    .campaigns-limit-text {
        align-items: center;
    }

    .campaigns-limit-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================
   CAMPAIGN TEMPLATES PANEL
   ============================================ */

.campaign-templates-panel {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.05) 0%, rgba(129, 140, 248, 0.05) 100%);
    border: 1px solid rgba(37, 99, 235, 0.15);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    margin-bottom: 20px;
}

.templates-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 8px;
}

.btn-template {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-template:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-template svg {
    flex-shrink: 0;
}

.btn-save-template {
    flex: 1;
}

.template-dropdown {
    position: relative;
    flex: 1;
}

.btn-load-template {
    width: 100%;
    justify-content: space-between;
}

.template-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    margin-left: auto;
}

.dropdown-arrow {
    flex-shrink: 0;
    transition: transform 0.2s;
}

.template-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

.template-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
}

.template-list {
    padding: 4px;
}

.template-empty {
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.template-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    gap: 10px;
}

.template-item:hover {
    background: var(--primary-light);
}

.template-item-content {
    flex: 1;
    min-width: 0;
}

.template-item-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.template-item-date {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.template-item-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}

.template-item:hover .template-item-actions {
    opacity: 1;
}

.template-action-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s;
}

.template-action-btn:hover {
    background: white;
    color: var(--text-primary);
}

.template-action-btn.delete:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.template-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 8px;
    border-top: 1px solid rgba(37, 99, 235, 0.1);
}

.template-limit-text {
    font-size: 12px;
    color: var(--text-muted);
}

/* Save Template Modal */
.save-template-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.save-template-modal.active {
    display: flex;
}

.save-template-content {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 400px;
    width: 100%;
    box-shadow: var(--shadow-lg);
}

.save-template-header {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.save-template-body {
    margin-bottom: 20px;
}

.save-template-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ============================================
   Inline Editing (CPM, Budget, Status)
   ============================================ */

.editable-cell {
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.15s ease;
    display: inline-block;
}

.editable-cell:hover {
    background: var(--primary-bg, rgba(37, 99, 235, 0.1));
    color: var(--primary, #2563eb);
}

.inline-edit-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
}

.inline-edit-input {
    width: 75px;
    padding: 3px 6px;
    font-size: 12px;
    border: 1px solid var(--primary, #2563eb);
    border-radius: 4px;
    background: var(--bg-secondary, #f8fafc);
    color: var(--text-primary, #1e293b);
    outline: none;
}

.inline-edit-input:focus {
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.inline-edit-input:disabled {
    opacity: 0.6;
}

.inline-edit-loading {
    display: inline-flex;
    align-items: center;
}

/* Inline edit vertical layout with slider */
.inline-edit-wrap-vertical {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 6px 8px;
    background: white;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 130px;
    position: relative;
    z-index: 100;
}

.inline-edit-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.inline-edit-wrap-vertical .inline-edit-input {
    width: 65px;
    flex-shrink: 0;
}

.inline-edit-apply {
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: var(--primary, #2563eb);
    color: white;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.inline-edit-apply:hover {
    background: var(--primary-dark, #1d4ed8);
}

.inline-edit-apply:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Slider styles */
.inline-edit-slider-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.inline-edit-slider {
    width: 100%;
    height: 5px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, #ef4444 0%, #e2e8f0 50%, #22c55e 100%);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.inline-edit-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    background: white;
    border: 2px solid var(--primary, #2563eb);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.inline-edit-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: white;
    border: 2px solid var(--primary, #2563eb);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.inline-edit-slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 8px;
    color: var(--text-muted, #94a3b8);
}

.inline-slider-value {
    font-weight: 600;
    font-size: 9px;
}

/* Budget popup (compact, near cell) */
.budget-popup {
    min-width: 200px;
    max-width: 240px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.budget-popup-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary, #f1f5f9);
    border-radius: 6px;
    padding: 2px;
}

.budget-popup-tab {
    flex: 1;
    padding: 5px 8px;
    border: none;
    background: transparent;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-secondary, #64748b);
    transition: all 0.15s;
}

.budget-popup-tab.active {
    background: white;
    color: var(--primary, #2563eb);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.budget-popup-tab:hover:not(.active) {
    color: var(--text-primary, #1e293b);
}

.budget-popup-current {
    font-size: 11px;
    color: var(--text-secondary, #64748b);
    text-align: center;
}

.budget-popup-input-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.budget-popup-input {
    flex: 1;
    width: 100%;
    padding: 6px 8px;
    font-size: 13px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 6px;
    background: var(--bg-secondary, #f8fafc);
    color: var(--text-primary, #1e293b);
    outline: none;
    transition: border-color 0.15s;
}

.budget-popup-input:focus {
    border-color: var(--primary, #2563eb);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.budget-popup-input:disabled {
    opacity: 0.6;
}

.budget-popup-currency {
    font-size: 12px;
    color: var(--text-secondary, #64748b);
    font-weight: 500;
    white-space: nowrap;
}

.budget-popup-hint {
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
}

.budget-popup-apply {
    width: 100%;
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    background: var(--primary, #2563eb);
    color: white;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
}

.budget-popup-apply:hover {
    background: var(--primary-hover, #1d4ed8);
}

.budget-popup-apply:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.budget-popup-apply.destructive {
    background: #ef4444;
}

.budget-popup-apply.destructive:hover {
    background: #dc2626;
}

/* Status dropdown */
.status-dropdown-wrap {
    position: relative;
    display: inline-block;
}

.editable-status {
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.editable-status:hover {
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.status-dropdown-arrow {
    font-size: 8px;
    opacity: 0.6;
    transition: transform 0.15s;
}

.status-dropdown {
    position: fixed;
    top: -9999px;
    left: -9999px;
    z-index: 99999;
    min-width: 120px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
    display: none;
}

.status-dropdown.show {
    display: block;
}

.status-dropdown-item {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-primary, #1e293b);
    transition: background 0.1s;
}

.status-dropdown-item:first-child {
    border-radius: 6px 6px 0 0;
}

.status-dropdown-item:last-child {
    border-radius: 0 0 6px 6px;
}

.status-dropdown-item:hover {
    background: var(--bg-hover, #f1f5f9);
}

.status-dropdown-item.active {
    background: var(--primary-bg, rgba(37, 99, 235, 0.1));
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.status-Active {
    background: #22c55e;
}

.status-dot.status-On-Hold {
    background: #f59e0b;
}

/* ============================================
   Export Modal (Apple Style)
   ============================================ */

/* ============================================
   Export Modal — Configurable Export
   ============================================ */

/* Top bar: scope + format pills */
.exp-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    border-bottom: 1px solid #f1f5f9;
    gap: 12px;
    flex-wrap: wrap;
}
.exp-scope {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #475569;
}
.exp-scope-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #22c55e;
    flex-shrink: 0;
}
.exp-format-pills {
    display: flex;
    gap: 4px;
    background: #f1f5f9;
    border-radius: 8px;
    padding: 3px;
}
.exp-pill {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.exp-pill:hover { color: #1e293b; }
.exp-pill.active {
    background: #fff;
    color: #1e293b;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Sections */
.exp-section {
    padding: 16px 24px;
    border-bottom: 1px solid #f1f5f9;
}
.exp-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    margin-bottom: 10px;
}
.exp-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.exp-section-header .exp-section-label {
    margin-bottom: 0;
}

/* Period chips */
.exp-period-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.exp-chip {
    padding: 6px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    color: #475569;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 4px;
}
.exp-chip:hover { border-color: #2563eb; color: #2563eb; }
.exp-chip.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}
.exp-custom-dates {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    animation: expSlideDown 0.2s ease;
}
@keyframes expSlideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}
.exp-date-input {
    flex: 1;
    padding: 8px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    font-size: 13px;
    font-weight: 500;
    color: #1e293b;
    outline: none;
    transition: border-color 0.15s;
    font-family: inherit;
}
.exp-date-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.exp-date-sep {
    color: #cbd5e1;
    font-size: 14px;
    flex-shrink: 0;
}

/* Column presets */
.exp-col-presets {
    display: flex;
    gap: 4px;
    background: #f1f5f9;
    border-radius: 6px;
    padding: 2px;
}
.exp-preset {
    padding: 4px 10px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #64748b;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.exp-preset:hover { color: #1e293b; }
.exp-preset.active {
    background: #fff;
    color: #2563eb;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* Column grid */
.exp-col-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
.exp-col-group-title {
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid #f1f5f9;
}
.exp-col-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 4px 0;
    cursor: pointer;
    font-size: 13px;
    color: #334155;
    transition: color 0.1s;
}
.exp-col-item:hover { color: #2563eb; }
.exp-col-item input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: #2563eb;
    border-radius: 3px;
    cursor: pointer;
    flex-shrink: 0;
}
.exp-col-count {
    margin-top: 10px;
    font-size: 12px;
    color: #94a3b8;
    text-align: right;
}

/* Footer with download button */
.exp-footer {
    padding: 16px 24px;
    display: flex;
    justify-content: flex-end;
}
.exp-download-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 28px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 10px;
    min-width: 160px;
    justify-content: center;
}
.exp-download-btn.loading {
    pointer-events: none;
    opacity: 0.7;
}
.exp-download-btn.loading svg {
    animation: expSpin 1s linear infinite;
}
@keyframes expSpin { to { transform: rotate(360deg); } }

/* Mobile responsive */
@media (max-width: 640px) {
    .exp-topbar {
        flex-direction: column;
        align-items: flex-start;
        padding: 12px 16px;
    }
    .exp-section { padding: 14px 16px; }
    .exp-col-grid { grid-template-columns: 1fr; gap: 12px; }
    .exp-footer { padding: 14px 16px; }
    .exp-download-btn { width: 100%; }
    .exp-format-pills { width: 100%; justify-content: center; }
}

/* ============================================
   RULE BUILDER - Natural Language Style
   ============================================ */

/* Scope Context Bar */
.rule-scope-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 16px;
}

.rule-scope-bar svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.rule-scope-bar--campaign {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.rule-scope-bar--bulk {
    background: var(--warning-bg);
    color: #b45309;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.rule-scope-bar--global {
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid rgba(37, 99, 235, 0.2);
}

.rule-scope-bar--group {
    background: var(--success-bg);
    color: #047857;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.rule-scope-bar__name {
    font-weight: 600;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Sentence-style Condition Builder */
.rule-sentence {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    position: relative;
}

.rule-sentence + .rule-sentence {
    margin-top: 8px;
}

.rule-sentence__keyword {
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.rule-sentence__keyword--when {
    background: var(--primary-light);
    color: var(--primary);
}

.rule-sentence__keyword--then {
    background: var(--success-bg);
    color: var(--success);
}

.rule-sentence__keyword--and {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-muted);
}

.rule-sentence__select {
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: white;
    font-size: 12px;
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2394a3b8'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    padding-right: 22px;
}

.rule-sentence__select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.rule-sentence__input {
    width: 72px;
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: white;
    font-size: 12px;
    color: var(--text-primary);
    text-align: center;
    outline: none;
    transition: border-color 0.15s;
}

.rule-sentence__input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.rule-sentence__unit {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.rule-sentence__period {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.rule-sentence__period select,
.rule-sentence__period input {
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: white;
    font-size: 12px;
    outline: none;
}

.rule-sentence__period input {
    width: 50px;
    text-align: center;
}

.rule-sentence__remove {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1;
    transition: all 0.15s;
    opacity: 0;
}

.rule-sentence:hover .rule-sentence__remove {
    opacity: 1;
}

.rule-sentence__remove:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.rule-sentence:only-child .rule-sentence__remove {
    display: none;
}

/* Add condition button */
.rule-add-condition {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    margin-top: 8px;
    font-size: 11px;
    font-weight: 500;
    color: var(--primary);
    background: var(--primary-light);
    border: 1px dashed rgba(37, 99, 235, 0.3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.rule-add-condition:hover {
    background: rgba(37, 99, 235, 0.15);
    border-color: var(--primary);
}

/* Action Cards Grid */
.rule-action-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.rule-action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    background: white;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
}

.rule-action-card:hover {
    border-color: var(--primary);
    background: #f8fafc;
}

.rule-action-card--selected {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.rule-action-card__icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.rule-action-card--selected .rule-action-card__icon {
    color: var(--primary);
}

.rule-action-card__icon svg {
    width: 20px;
    height: 20px;
}

.rule-action-card__label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    line-height: 1.2;
}

.rule-action-card--selected .rule-action-card__label {
    color: var(--primary);
    font-weight: 600;
}

/* Action value input (shown when numeric action selected) */
.rule-action-value {
    display: none;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.rule-action-value.visible {
    display: flex;
}

.rule-action-value__label {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.rule-action-value__input {
    width: 90px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: white;
    font-size: 13px;
    text-align: center;
    outline: none;
}

.rule-action-value__input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.rule-action-value__unit {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

/* Amount / % toggle for CPM actions */
.rule-value-mode-toggle {
    display: flex;
    padding: 2px;
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    flex-shrink: 0;
    gap: 1px;
}

.rule-value-mode-btn {
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 500;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    line-height: 1.2;
    border-radius: 6px;
    letter-spacing: 0.01em;
}

.rule-value-mode-btn.active {
    background: white;
    color: var(--text-secondary);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.rule-value-mode-btn:hover:not(.active) {
    color: var(--text-secondary);
}

/* Check Interval */
.rule-check-interval {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Status Pill Toggles */
.rule-status-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.rule-status-pill {
    padding: 4px 14px;
    font-size: 11px;
    font-weight: 500;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-full);
    background: white;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.rule-status-pill:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.rule-status-pill.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Live Preview */
.rule-preview {
    background: #f0fdf4;
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-top: 12px;
}

.rule-preview__label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--success);
    margin-bottom: 4px;
}

.rule-preview__text {
    font-size: 12px;
    color: var(--text-primary);
    font-style: italic;
    line-height: 1.5;
}

/* Enhanced Rule List Cards */
.rule-card {
    border-left: 3px solid var(--border-color);
    padding: 10px 12px;
    background: white;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    border-top: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    transition: all 0.15s;
    cursor: pointer;
}

.rule-card:hover {
    box-shadow: var(--shadow-sm);
}

.rule-card--active {
    border-left-color: var(--success);
}

.rule-card--inactive {
    border-left-color: var(--text-muted);
    opacity: 0.7;
}

.rule-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.rule-card__name {
    font-weight: 600;
    font-size: 12px;
    color: var(--text-primary);
}

/* CSS-only toggle switch */
.rule-card__toggle {
    position: relative;
    width: 34px;
    height: 18px;
    flex-shrink: 0;
}

.rule-card__toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.rule-card__toggle-slider {
    position: absolute;
    inset: 0;
    background: #cbd5e1;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background 0.2s;
}

.rule-card__toggle-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.rule-card__toggle input:checked + .rule-card__toggle-slider {
    background: var(--success);
}

.rule-card__toggle input:checked + .rule-card__toggle-slider::before {
    transform: translateX(16px);
}

.rule-card__body {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 4px;
}

.rule-card__body-keyword {
    font-weight: 700;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rule-card__body-keyword--when {
    color: var(--primary);
}

.rule-card__body-keyword--then {
    color: var(--success);
}

.rule-card__meta {
    display: flex;
    gap: 12px;
    font-size: 10px;
    color: var(--text-muted);
}

.rule-card__meta svg {
    width: 10px;
    height: 10px;
    vertical-align: -1px;
    margin-right: 2px;
}

/* Rule card actions on hover */
.rule-card__actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}

.rule-card:hover .rule-card__actions {
    opacity: 1;
}

.rule-card__action-btn {
    padding: 3px 8px;
    font-size: 10px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    background: var(--bg-base);
    color: var(--text-secondary);
    transition: all 0.15s;
}

.rule-card__action-btn:hover {
    background: var(--primary);
    color: white;
}

.rule-card__action-btn--danger:hover {
    background: var(--danger);
}

/* Section labels inside form */
.rule-section-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    margin-top: 16px;
}

.rule-section-label:first-child {
    margin-top: 0;
}

/* Form actions inside card */
.rule-form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.rule-form-actions .btn-delete {
    margin-right: auto;
}

/* Rule inline error banner */
.rule-inline-error {
    padding: 10px 14px;
    margin-bottom: 12px;
    border-radius: var(--radius-sm);
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: ruleErrorSlide 0.25s ease-out;
}

@keyframes ruleErrorSlide {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Rule field label */
.rule-field-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Rule name input */
.rule-name-input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    margin-bottom: 14px;
    background: var(--bg-secondary, #f8fafc);
}

.rule-name-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
    background: #fff;
}

.rule-name-input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

/* Error state for fields */
.rule-name-input.field-error {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
    background: #fef2f2;
}

.rule-name-input.field-error:focus {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

.rule-action-value__input.field-error {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

/* Responsive */
@media (max-width: 640px) {
    .rule-action-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .rule-sentence {
        flex-direction: column;
        align-items: flex-start;
    }

    .rule-sentence__select,
    .rule-sentence__input {
        width: 100%;
    }

    .rule-sentence__period {
        width: 100%;
        flex-wrap: wrap;
    }

    .rule-scope-bar__name {
        max-width: 120px;
    }
}

/* ==================== A/B Testing ==================== */

/* Campaign Create: A/B Variants */
.ab-add-row {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
}
.ab-add-variant-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px dashed var(--primary);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
.ab-add-variant-btn:hover {
    background: var(--primary-light);
}
.ab-add-row .tg-help-icon {
    margin-left: 0;
}
.ab-main-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    margin-top: 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}
.ab-variant-badge-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}
.ab-variant-group {
    margin-top: 10px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius-sm);
    background: #fafbfe;
}
.ab-variant-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.ab-variant-title {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}
.ab-variant-remove {
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}
.ab-variant-remove:hover {
    background: var(--danger-bg);
    color: var(--danger);
}
.ab-variant-group .tg-form-textarea {
    margin: 0;
}

/* Dashboard: A/B Parent Row */
.ab-test-parent-row {
    background: #f8fafc;
    cursor: pointer;
    transition: background 0.15s;
}
.ab-test-parent-row:hover {
    background: #f1f5f9;
}
.ab-expand-icon {
    font-size: 14px;
    color: var(--text-secondary);
    user-select: none;
}
.ab-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.ab-variant-count {
    font-size: 11px;
    color: var(--text-muted);
}
.ab-badge.ab-status-running {
    background: var(--success-bg);
    color: var(--success);
}
.ab-badge.ab-status-degraded {
    background: var(--warning-bg);
    color: var(--warning);
}
.ab-badge.ab-status-completed {
    background: rgba(100, 116, 139, 0.1);
    color: #64748b;
}
.ab-badge.ab-status-pending {
    background: var(--info-bg);
    color: var(--info);
}
.ab-badge.ab-status-archived {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-muted);
}
.ab-stop-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}
.ab-stop-btn:hover {
    background: var(--danger-bg, #fef2f2);
    border-color: var(--danger, #ef4444);
    color: var(--danger, #ef4444);
}

/* Dashboard: A/B Variant Rows */
.ab-variant-row {
    background: #fafbfc;
}
.ab-variant-row td:first-child {
    padding-left: 24px;
}
.ab-variant-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 11px;
    font-weight: 700;
}
.ab-variant-leader {
    color: var(--success);
    font-weight: 700;
    font-size: 14px;
    margin-left: 4px;
}
.ab-variant-winner {
    font-size: 14px;
    margin-left: 4px;
}
.ab-variant-deleted {
    opacity: 0.5;
}
.ab-snapshot-label {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}

/* Status labels in parent row */
.ab-status-running { color: var(--success); }
.ab-status-degraded { color: var(--warning); }
.ab-status-completed { color: #64748b; }
.ab-status-pending { color: var(--info); }
.ab-status-archived { color: var(--text-muted); }

/* A/B Filter Select */
.ab-filter-select {
    padding: 5px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-secondary);
    background: white;
    cursor: pointer;
    outline: none;
    margin-left: 8px;
}
.ab-filter-select:focus {
    border-color: var(--primary);
}

/* End Test Modal */
.ab-end-test-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ab-end-test-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.4);
}
.ab-end-test-content {
    position: relative;
    background: white;
    border-radius: var(--radius-md);
    padding: 24px;
    width: 420px;
    max-width: 90vw;
    box-shadow: var(--shadow-xl);
}
.ab-end-test-content h3 {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 600;
}
.ab-end-test-section {
    margin-bottom: 16px;
}
.ab-end-test-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.ab-winner-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ab-winner-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.ab-winner-option:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}
.ab-winner-option input[type="radio"] {
    accent-color: var(--primary);
}
.ab-winner-label {
    font-weight: 600;
    font-size: 14px;
    min-width: 20px;
}
.ab-winner-text {
    flex: 1;
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ab-winner-ctr {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}
.ab-loser-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-primary);
    background: white;
    outline: none;
}
.ab-loser-select:focus {
    border-color: var(--primary);
}
.ab-end-test-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

/* Media A/B test grid */
.media-ab-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 6px;
}
.media-ab-tile {
    width: 80px;
    height: 80px;
    border: 2px dashed var(--border-color, #e0e0e0);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s;
}
.media-ab-tile:hover { border-color: var(--primary, #2563eb); }
.media-ab-tile.has-media { border-style: solid; border-color: var(--primary, #2563eb); }
.media-ab-tile.media-ab-add { opacity: 0.6; }
.media-ab-tile.media-ab-add:hover { opacity: 1; }
.media-ab-thumb { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.media-ab-label {
    position: absolute; top: 4px; left: 4px;
    background: var(--primary, #2563eb); color: white;
    font-size: 10px; font-weight: 600;
    width: 18px; height: 18px; border-radius: 4px;
    display: flex; align-items: center; justify-content: center; z-index: 1;
}
.media-ab-remove {
    position: absolute; top: 2px; right: 2px;
    background: rgba(0,0,0,0.5); color: white; border: none;
    border-radius: 50%; width: 18px; height: 18px;
    font-size: 12px; cursor: pointer; z-index: 1;
    display: flex; align-items: center; justify-content: center;
}
.media-ab-remove:hover { background: rgba(0,0,0,0.7); }
.media-ab-upload-icon { font-size: 24px; color: var(--text-secondary, #999); line-height: 1; }
.media-ab-upload-text { font-size: 10px; color: var(--text-secondary, #999); margin-top: 2px; text-align: center; line-height: 1.2; }
.cc-campaign-count {
    font-size: 13px; color: var(--primary, #2563eb);
    padding: 8px 12px; background: var(--primary-bg, #f0f0ff);
    border-radius: 6px; margin-right: auto; text-align: center;
}

/* ============================================
   AGENCY PAGE COMPONENTS
   ============================================ */

/* Utility classes */
.hidden { display: none !important; }

/* Agency cabinet card */
.agency-cabinet-card {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.03);
}
.agency-cabinet-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  border-color: var(--border-color);
}

/* Cabinet card layout */
.cabinet-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.cabinet-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.cabinet-card-balance {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.cabinet-card-health {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.cabinet-card-health .health-good { color: var(--success); }
.cabinet-card-health .health-bad { color: var(--danger); }
.cabinet-card-members {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.cabinet-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Access level badges */
.access-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.access-badge.manager {
  background: var(--primary-light);
  color: var(--primary);
}
.access-badge.viewer {
  background: rgba(148, 163, 184, 0.12);
  color: #64748b;
}

/* Agency member row */
.agency-member-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #f8fafc;
  border-radius: var(--radius-lg);
  margin-bottom: 4px;
  transition: background 0.12s ease;
}
.agency-member-card:hover {
  background: #f1f5f9;
}
.agency-member-info {
  flex: 1;
  min-width: 0;
}
.agency-member-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agency-member-email {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agency-member-meta {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Collapsible section */
.agency-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  cursor: pointer;
  user-select: none;
}
.agency-section-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.agency-section-header .collapse-icon {
  transition: transform 0.2s ease;
  color: var(--text-muted);
}
.agency-section-header.collapsed .collapse-icon {
  transform: rotate(-90deg);
}
.agency-section-body {
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.agency-section-body.collapsed {
  max-height: 0 !important;
  padding: 0;
}

/* Campaign mode card hover (replaces JS inline hover) */
.campaign-mode-card {
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.campaign-mode-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Agency modal standardized */
.agency-modal {
  width: 92%;
  max-width: 480px;
  background: white;
  border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04), 0 8px 40px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
  max-height: 88vh;
  overflow-y: auto;
}
.agency-modal-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.agency-modal-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.agency-modal-body {
  padding: 16px;
}
.agency-modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Access matrix */
.access-matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.access-matrix th {
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  background: rgba(241, 245, 249, 0.8);
  text-align: left;
  position: sticky;
  top: 0;
}
.access-matrix td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--border-light);
}
.access-matrix tr:hover {
  background: rgba(37, 99, 235, 0.04);
}
.access-matrix select {
  padding: 3px 6px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 11px;
  background: white;
  color: var(--text-primary);
  cursor: pointer;
}
.access-matrix select:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

/* Sync indicator */
.sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
}
.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.sync-dot.fresh { background: var(--success); }
.sync-dot.stale { background: var(--warning); }
.sync-dot.old { background: var(--danger); }
.sync-dot.never { background: var(--text-muted); }

/* ============================================
   AGENCY RESPONSIVE (mobile)
   ============================================ */

@media (max-width: 640px) {
  /* Cabinet cards stack fully */
  .agency-cabinet-card {
    padding: 12px;
  }
  .cabinet-card-actions {
    flex-wrap: wrap;
  }
  .cabinet-card-actions .btn {
    min-height: 44px;
    padding: 10px 16px;
  }

  /* Member cards */
  .agency-member-card {
    flex-wrap: wrap;
  }
  .agency-member-card .btn {
    min-height: 44px;
  }

  /* Touch targets */
  .agency-cabinet-card .btn,
  .agency-member-card .btn,
  .agency-section-header {
    min-height: 44px;
  }

  /* Access matrix scroll */
  .access-matrix-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Modal full-width on mobile */
  .agency-modal {
    width: 100%;
    max-width: 100%;
    border-radius: 12px 12px 0 0;
    max-height: 92vh;
  }

  /* Color swatches bigger for touch */
  .color-swatch {
    width: 44px;
    height: 44px;
  }

  /* Fix #1: Member card stacking on mobile */
  .member-card {
    flex-direction: column;
    align-items: stretch !important;
    gap: 8px;
  }
  .member-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
  }

  /* Fix #4: Member buttons touch target */
  .member-btn {
    min-height: 44px;
    padding: 10px 16px;
  }

  /* Fix #2: Invite row wrapping */
  .invite-row {
    flex-wrap: wrap;
  }
  .invite-row input,
  .invite-input {
    min-width: 100%;
    margin-bottom: 8px;
  }

  /* Fix #5: Invite button touch target */
  .invite-btn {
    min-height: 44px;
    padding: 10px 16px;
  }

  /* Fix #6: Slot quantity button touch target */
  .slot-qty-btn {
    width: 44px;
    height: 44px;
  }

  /* Fix #3: Access modals full-width on mobile */
  .modal .modal-content,
  #memberAccessModal .modal-content,
  #cabinetAccessModal .modal-content {
    width: 100%;
    max-width: 100%;
    border-radius: 12px 12px 0 0;
    margin: auto 0 0 0;
  }

  /* Fix #7: Invite confirmation buttons */
  #confirmContent .btn {
    min-height: 44px;
    font-size: 14px;
  }

  /* Fix #8: Access matrix select larger touch area */
  .access-matrix select {
    min-height: 36px;
    padding: 6px 8px;
    font-size: 13px;
  }

  /* Fix #11: Stats grid single column on narrow screens */
  .team-stats {
    grid-template-columns: 1fr !important;
  }

  /* Fix #9: Manager topbar stacking */
  .manager-topbar,
  .top-bar-left {
    flex-wrap: wrap;
    gap: 8px;
  }
}

/* Skeleton loading for agency cards */
.skeleton-card {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius-lg);
  height: 80px;
  margin-bottom: 8px;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (max-width: 400px) {
  /* Fix #10: Stack confirm/decline buttons vertically */
  #confirmContent > div:last-child {
    flex-direction: column;
  }
  #confirmContent > div:last-child .btn {
    width: 100%;
  }
}

/* ============================================================
   Campaigns table → cards (phones)
   Placed at the END of the file on purpose: the desktop table rules
   (.campaigns-table, ~line 5138+) would otherwise override these at equal
   specificity. Column indexes are positional and identical for campaign
   rows, locked rows, A/B parent/variant rows and group rows
   (renderCampaignRow / renderGroupsTable / renderAbTest* in app.js):
     1 checkbox · 2 ID (group name on .group-row, AB badge on A/B rows) ·
     3 title · 4 status · 5 media · 6 views · 7 clicks · 8 CTR · 9 CVR ·
     10 CPC · 11 CPM · 12 actions · 13 CPA · 14 spent · 15 budget ·
     16–22 postback · 23 text · 24 target · 25 date · 26 last edit ·
     27 auto · 28 row actions.
   Keep in sync with TableView.applyColumns() (injected nth-child styles).
   ============================================================ */
@media (max-width: 768px) {
    .table-container {
        margin: 0;
        padding: 0;
        overflow: visible;
    }

    .table-scroll {
        overflow-x: visible;
        padding: 0;
        margin: 0;
    }

    .campaigns-table {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .campaigns-table thead {
        display: none;
    }

    .campaigns-table tbody {
        display: block;
    }

    .campaigns-table tbody tr {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px 10px;
        background: #fff;
        border: 1px solid var(--border-color);
        border-radius: 12px;
        padding: 12px;
        margin-bottom: 8px;
        contain-intrinsic-size: auto 170px;
    }

    .campaigns-table tbody tr.row-selected {
        background: rgba(37, 99, 235, 0.05);
        box-shadow: inset 0 0 0 2px var(--primary);
    }

    .campaigns-table td {
        display: block;
        padding: 0;
        border-bottom: none;
        white-space: normal;
        max-width: none;
    }

    /* Cells without a mobile slot */
    .campaigns-table tbody tr:not(.group-row):not(.ab-test-parent-row):not(.ab-variant-row) td:nth-child(2),
    .campaigns-table td:nth-child(5),   /* Media */
    .campaigns-table td:nth-child(9),   /* CVR */
    .campaigns-table td:nth-child(10),  /* CPC */
    .campaigns-table td:nth-child(12),  /* Actions */
    .campaigns-table td:nth-child(13),  /* CPA */
    .campaigns-table td:nth-child(16),
    .campaigns-table td:nth-child(17),
    .campaigns-table td:nth-child(18),
    .campaigns-table td:nth-child(19),
    .campaigns-table td:nth-child(20),
    .campaigns-table td:nth-child(21),
    .campaigns-table td:nth-child(22),  /* postback Leads…Revenue */
    .campaigns-table td:nth-child(23),  /* Text */
    .campaigns-table td:nth-child(24),  /* Target */
    .campaigns-table td:nth-child(25),  /* Date */
    .campaigns-table td:nth-child(26) { /* Last edit */
        display: none;
    }

    /* Card rows are built with explicit flex line breaks (the ::before/::after
       full-width items below), so packing is deterministic:
         line 1 (order ≤3): checkbox · title · auto-btn · menu
         break            : tr::before (order 4)
         line 2 (order 5-6): status / group count / A/B badge
         break            : tr::after (order 9)
         line 3+ (order 10): metric tiles */
    .campaigns-table tbody tr::before,
    .campaigns-table tbody tr::after {
        content: '';
        flex-basis: 100%;
        height: 0;
    }
    .campaigns-table tbody tr::before { order: 4; }
    .campaigns-table tbody tr::after  { order: 9; }

    .campaigns-table td:nth-child(1) { order: 1; }
    .campaigns-table td:nth-child(3) {
        order: 2;
        flex: 1 1 0;
        min-width: 0;
        max-width: none; /* the desktop 150px cap outranks the bare td rule */
        font-size: 14px;
    }
    .campaigns-table td:nth-child(27) { order: 3; margin-left: auto; }
    .campaigns-table td:nth-child(28) { order: 3; }

    /* Group rows: the name cell (2) is the card title, count goes small */
    .campaigns-table tr.group-row td:nth-child(2) {
        order: 2;
        flex: 1 1 0;
        min-width: 0;
    }
    .campaigns-table tr.group-row td:nth-child(3) {
        order: 5;
        flex: 0 1 auto;
        font-size: 12px;
        color: var(--text-muted);
    }

    /* A/B rows: keep the AB / variant badge as a small chip next to status */
    .campaigns-table tr.ab-test-parent-row td:nth-child(2),
    .campaigns-table tr.ab-variant-row td:nth-child(2) {
        order: 5;
        flex: 0 1 auto;
        font-size: 12px;
    }

    /* Status pill line */
    .campaigns-table td:nth-child(4) {
        order: 6;
        flex: 0 1 auto;
    }
    .campaigns-table tr.group-row td:nth-child(4),
    .campaigns-table tr.ab-test-parent-row td:nth-child(4),
    .campaigns-table tr.ab-variant-row td:nth-child(4) {
        margin-left: auto;
    }

    /* Metric tiles: Views · Clicks · CTR / CPM · Spent · Budget */
    .campaigns-table td:nth-child(6),
    .campaigns-table td:nth-child(7),
    .campaigns-table td:nth-child(8),
    .campaigns-table td:nth-child(11),
    .campaigns-table td:nth-child(14),
    .campaigns-table td:nth-child(15) {
        order: 10;
        flex: 1 1 calc(33.333% - 7px);
        min-width: calc(33.333% - 7px);
        max-width: none; /* the desktop 140px caps on Spent/Budget outrank td */
        background: #f8fafc;
        border-radius: 8px;
        padding: 6px 8px;
        font-size: 13px;
        font-weight: 600;
        line-height: 1.3;
    }

    /* Labels match the (English-only) desktop table headers */
    .campaigns-table td:nth-child(6)::before  { content: 'Views'; }
    .campaigns-table td:nth-child(7)::before  { content: 'Clicks'; }
    .campaigns-table td:nth-child(8)::before  { content: 'CTR'; }
    .campaigns-table td:nth-child(11)::before { content: 'CPM'; }
    .campaigns-table td:nth-child(14)::before { content: 'Spent'; }
    .campaigns-table td:nth-child(15)::before { content: 'Budget'; }

    .campaigns-table td:nth-child(6)::before,
    .campaigns-table td:nth-child(7)::before,
    .campaigns-table td:nth-child(8)::before,
    .campaigns-table td:nth-child(11)::before,
    .campaigns-table td:nth-child(14)::before,
    .campaigns-table td:nth-child(15)::before {
        display: block;
        font-size: 9px;
        font-weight: 600;
        letter-spacing: 0.05em;
        text-transform: uppercase;
        color: var(--text-muted);
        margin-bottom: 1px;
    }

    /* Touch-sized controls inside cards */
    .campaigns-table .td-checkbox input {
        width: 18px;
        height: 18px;
    }

    /* Group rows have no checkbox — drop the empty cell so the flex gap
       doesn't indent the group name */
    .campaigns-table tr.group-row td.td-checkbox {
        display: none;
    }

    .campaigns-table .actions-menu-btn,
    .campaigns-table .auto-btn {
        width: 36px;
        height: 36px;
    }

    .campaigns-table .actions-menu-btn svg,
    .campaigns-table .auto-btn svg {
        width: 16px;
        height: 16px;
    }

    .campaigns-table .campaign-title-text {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    /* Single-cell service rows (empty state, pagination loader/counter,
       upgrade overlay) render as plain full-width cards */
    .campaigns-table td.no-data,
    .campaigns-table td.pagination-loader-cell,
    .campaigns-table td.pagination-counter-cell,
    .campaigns-table tr.upgrade-overlay-row td {
        flex-basis: 100%;
        text-align: center;
        padding: 16px 0;
    }

    /* Search takes the full row (the wrapper carries an inline max-width) */
    .campaign-search > div:first-child {
        max-width: none !important;
    }
}
