@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ═══════════════════════════════════════════
   Design Tokens
   ═══════════════════════════════════════════ */
:root {
    /* Colors */
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-hover: rgba(17, 24, 39, 0.9);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --bg-input: rgba(255, 255, 255, 0.06);
    --border-primary: rgba(255, 255, 255, 0.06);
    --border-active: rgba(99, 102, 241, 0.5);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-blue: #6366f1;
    --accent-purple: #8b5cf6;
    --accent-cyan: #22d3ee;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-orange: #f59e0b;
    --accent-pink: #ec4899;
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a78bfa 100%);
    --gradient-card: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.05) 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --gradient-danger: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.15);

    /* Sizing */
    --sidebar-width: 260px;
    --header-height: 64px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
}

/* ═══════════════════════════════════════════
   Reset & Base
   ═══════════════════════════════════════════ */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Background gradient effect */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 20% 30%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(34, 211, 238, 0.04) 0%, transparent 50%);
    z-index: 0;
    animation: bgPulse 20s ease-in-out infinite;
}

@keyframes bgPulse {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(-2%, 1%) scale(1.02);
    }

    66% {
        transform: translate(1%, -1%) scale(0.98);
    }
}

/* ═══════════════════════════════════════════
   Layout
   ═══════════════════════════════════════════ */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* ═══════════════════════════════════════════
   Sidebar
   ═══════════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-width);
    background: rgba(10, 14, 26, 0.95);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-logo {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo .logo-icon {
    width: 40px;
    height: 40px;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.sidebar-logo h1 {
    font-size: 18px;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.3px;
}

.sidebar-logo .subtitle {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    padding: 16px 12px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 2px;
    position: relative;
    overflow: hidden;
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.08);
}

.nav-item.active {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.12);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: var(--gradient-primary);
    border-radius: 0 4px 4px 0;
}

.nav-item .nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.nav-item .nav-badge {
    margin-left: auto;
    background: var(--accent-red);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* Account selector in sidebar */
.account-selector {
    padding: 12px;
    border-top: 1px solid var(--border-primary);
}

.account-selector select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.account-selector select:focus {
    border-color: var(--accent-blue);
}

.account-selector label {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
    font-weight: 600;
}

/* ═══════════════════════════════════════════
   Main Content
   ═══════════════════════════════════════════ */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
}

.page-header {
    padding: 20px 32px;
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(10, 14, 26, 0.6);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-header h2 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.page-header .header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-content {
    padding: 24px 32px;
}

/* ═══════════════════════════════════════════
   Tab Pages
   ═══════════════════════════════════════════ */
.tab-page {
    display: none;
    animation: fadeIn 0.3s ease;
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ═══════════════════════════════════════════
   Cards
   ═══════════════════════════════════════════ */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(99, 102, 241, 0.3) 50%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s;
}

.card:hover::before {
    opacity: 1;
}

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

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title .icon {
    font-size: 16px;
}

/* ═══════════════════════════════════════════
   Metric Cards (Dashboard Top Row)
   ═══════════════════════════════════════════ */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.metric-card:hover {
    border-color: var(--border-active);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.metric-card .metric-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 12px;
}

.metric-card .metric-icon.blue {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-blue);
}

.metric-card .metric-icon.green {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
}

.metric-card .metric-icon.purple {
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-purple);
}

.metric-card .metric-icon.cyan {
    background: rgba(34, 211, 238, 0.15);
    color: var(--accent-cyan);
}

.metric-card .metric-icon.orange {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-orange);
}

.metric-card .metric-icon.red {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
}

.metric-card .metric-value {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 4px;
}

.metric-card .metric-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ═══════════════════════════════════════════
   Charts
   ═══════════════════════════════════════════ */
.chart-container {
    position: relative;
    height: 380px;
    width: 100%;
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.charts-grid .card {
    min-height: 420px;
}

.chart-full .card {
    margin-bottom: 24px;
}

/* ═══════════════════════════════════════════
   Date Range Picker
   ═══════════════════════════════════════════ */
.date-range-picker {
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-range-picker input[type="date"] {
    background: var(--bg-input);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}

.date-range-picker input[type="date"]:focus {
    border-color: var(--accent-blue);
}

.date-range-picker .separator {
    color: var(--text-muted);
    font-size: 12px;
}

/* ═══════════════════════════════════════════
   Buttons
   ═══════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border-active);
}

.btn-success {
    background: var(--gradient-success);
    color: white;
}

.btn-danger {
    background: var(--gradient-danger);
    color: white;
}

.btn-warning {
    background: var(--gradient-warning);
    color: white;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 11px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: var(--radius-sm);
}

/* ═══════════════════════════════════════════
   Tables
   ═══════════════════════════════════════════ */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: auto;
    scrollbar-color: rgba(99, 102, 241, 0.5) rgba(255, 255, 255, 0.05);
    padding-bottom: 4px;
}

.table-wrapper::-webkit-scrollbar {
    height: 12px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    margin: 0 8px;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.05);
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(90deg, #818cf8, #a78bfa);
}


.data-table {
    width: 100%;
    min-width: 1600px;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 12px 14px;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border-primary);
    white-space: nowrap;
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 2;
}

.data-table td {
    padding: 10px 14px;
    font-size: 12px;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
    white-space: nowrap;
}

.data-table tr {
    transition: background 0.15s;
}

.data-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.04);
}

.data-table .value-cell {
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.data-table .value-cell.highlight-green {
    color: var(--accent-green);
}

.data-table .value-cell.highlight-purple {
    color: var(--accent-purple);
}

.data-table .value-cell.highlight-orange {
    color: var(--accent-orange);
}

/* Sticky name column */
.data-table td.sticky-name,
.data-table th:first-child {
    position: sticky;
    left: 0;
    background: var(--bg-card);
    z-index: 3;
    min-width: 200px;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table td.sticky-name::after,
.data-table th:first-child::after {
    content: '';
    position: absolute;
    top: 0;
    right: -8px;
    bottom: 0;
    width: 8px;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.15), transparent);
    pointer-events: none;
}


/* ═══════════════════════════════════════════
   Status Badges
   ═══════════════════════════════════════════ */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.active {
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent-green);
}

.status-badge.paused {
    background: rgba(245, 158, 11, 0.12);
    color: var(--accent-orange);
}

.status-badge.deleted,
.status-badge.archived {
    background: rgba(239, 68, 68, 0.12);
    color: var(--accent-red);
}

.status-badge .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

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

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* ═══════════════════════════════════════════
   Forms
   ═══════════════════════════════════════════ */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-control::placeholder {
    color: var(--text-muted);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

select.form-control {
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ═══════════════════════════════════════════
   File Upload / Dropzone
   ═══════════════════════════════════════════ */
.dropzone {
    border: 2px dashed var(--border-primary);
    border-radius: var(--radius-lg);
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg-glass);
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--accent-blue);
    background: rgba(99, 102, 241, 0.05);
}

.dropzone .dropzone-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.dropzone .dropzone-text {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 4px;
}

.dropzone .dropzone-hint {
    color: var(--text-muted);
    font-size: 12px;
}

.image-preview {
    max-width: 300px;
    max-height: 200px;
    border-radius: var(--radius-md);
    object-fit: contain;
    margin-top: 12px;
}

/* ═══════════════════════════════════════════
   Optimization Suggestions
   ═══════════════════════════════════════════ */
.suggestion-card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 12px;
    transition: all 0.2s ease;
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.suggestion-card:hover {
    border-color: var(--border-active);
}

.suggestion-card .severity-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 2px;
}

.severity-icon.critical {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
}

.severity-icon.high {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-orange);
}

.severity-icon.medium {
    background: rgba(34, 211, 238, 0.15);
    color: var(--accent-cyan);
}

.severity-icon.opportunity {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
}

.suggestion-content .entity-name {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.suggestion-content .rule-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.suggestion-content .suggestion-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ═══════════════════════════════════════════
   Analysis Score
   ═══════════════════════════════════════════ */
.score-ring {
    width: 100px;
    height: 100px;
    position: relative;
    margin: 0 auto 16px;
}

.score-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.score-ring .score-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    font-weight: 800;
}

.frame-score-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
}

.frame-score-card .frame-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.frame-score-card .grade-badge {
    font-size: 14px;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
}

.grade-badge.grade-A {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
}

.grade-badge.grade-B {
    background: rgba(34, 211, 238, 0.15);
    color: var(--accent-cyan);
}

.grade-badge.grade-C {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-orange);
}

.grade-badge.grade-D {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
}

.grade-badge.grade-F {
    background: rgba(239, 68, 68, 0.25);
    color: var(--accent-red);
}

.criterion-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
}

.criterion-row .criterion-name {
    color: var(--text-secondary);
}

.criterion-bar {
    width: 80px;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
    margin: 0 12px;
}

.criterion-bar .fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* ═══════════════════════════════════════════
   Settings
   ═══════════════════════════════════════════ */
.settings-section {
    margin-bottom: 32px;
}

.settings-section h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.json-editor {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 12px;
    line-height: 1.6;
    min-height: 300px;
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    color: var(--accent-cyan);
    padding: 16px;
    border-radius: var(--radius-md);
    width: 100%;
    resize: vertical;
    outline: none;
    tab-size: 2;
}

.json-editor:focus {
    border-color: var(--accent-blue);
}

/* ═══════════════════════════════════════════
   Loading & Empty States
   ═══════════════════════════════════════════ */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-primary);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 14px;
    margin-bottom: 16px;
}

/* ═══════════════════════════════════════════
   Toasts
   ═══════════════════════════════════════════ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 12px 20px;
    color: var(--text-primary);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    min-width: 280px;
}

.toast.success {
    border-left: 3px solid var(--accent-green);
}

.toast.error {
    border-left: 3px solid var(--accent-red);
}

.toast.warning {
    border-left: 3px solid var(--accent-orange);
}

@keyframes toastIn {
    from {
        transform: translateX(100px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ═══════════════════════════════════════════
   Modal
   ═══════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

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

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-xl);
    padding: 28px;
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
}

.modal-close:hover {
    color: var(--text-primary);
}

/* ═══════════════════════════════════════════
   Toggle Switch
   ═══════════════════════════════════════════ */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

.toggle-switch input {
    display: none;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.toggle-switch input:checked+.toggle-slider {
    background: var(--accent-blue);
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(20px);
}

/* ═══════════════════════════════════════════
   Budget Input
   ═══════════════════════════════════════════ */
.budget-input-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.budget-input-group input {
    width: 100px;
    background: var(--bg-input);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    outline: none;
    font-variant-numeric: tabular-nums;
}

.budget-input-group input:focus {
    border-color: var(--accent-blue);
}

/* ═══════════════════════════════════════════
   Scrollbar
   ═══════════════════════════════════════════ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ═══════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════ */
@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .main-content {
        margin-left: 0;
    }

    .metrics-grid {
        grid-template-columns: 1fr 1fr;
    }

    .page-content {
        padding: 16px;
    }
}

/* ═══════════════════════════════════════════
   Score Input for Analysis
   ═══════════════════════════════════════════ */
.score-input {
    width: 50px;
    text-align: center;
    background: var(--bg-input);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    padding: 4px;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 600;
    outline: none;
}

.score-input:focus {
    border-color: var(--accent-blue);
}

/* ═══════════════════════════════════════════
   Connection Status
   ═══════════════════════════════════════════ */
.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-green);
}

.connection-status.offline {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-red);
}

.connection-status .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s ease-in-out infinite;
}

/* ═══════════════════════════════════════════
   Insights Table (wide scroll) — override
   ═══════════════════════════════════════════ */
#insights-table-wrapper {
    overflow-x: scroll;
    width: 0;
    min-width: 100%;
}


/* Custom scroll slider below table */
.table-scroll-slider {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px 4px;
}

.table-scroll-slider .scroll-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    min-width: 60px;
}

.table-scroll-slider .scroll-label:last-child {
    text-align: right;
}

.table-scroll-slider input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
    transition: background 0.2s;
}

.table-scroll-slider input[type="range"]:hover {
    background: rgba(255, 255, 255, 0.12);
}

/* Webkit (Chrome/Safari) thumb */
.table-scroll-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.5);
    cursor: grab;
    transition: transform 0.15s, box-shadow 0.15s;
}

.table-scroll-slider input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 3px 12px rgba(99, 102, 241, 0.7);
}

.table-scroll-slider input[type="range"]:active::-webkit-slider-thumb {
    cursor: grabbing;
    transform: scale(1.1);
}

/* Firefox thumb */
.table-scroll-slider input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.5);
    cursor: grab;
}

.table-scroll-slider input[type="range"]::-moz-range-track {
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    border: none;
}


/* ═══════════════════════════════════════════
   Action Buttons in Tables
   ═══════════════════════════════════════════ */
.action-btns {
    display: flex;
    gap: 6px;
}


/* ═══════════════════════════════════════════
   Bulk Creative Uploader
   ═══════════════════════════════════════════ */

.bulk-uploader-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    padding: 8px 0;
}

@media (max-width: 960px) {
    .bulk-uploader-grid {
        grid-template-columns: 1fr;
    }
}

.bulk-col-left,
.bulk-col-right {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.section-label {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 12px 0 4px;
}

.section-label:first-child {
    margin-top: 0;
}

.divider {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    margin: 12px 0 4px;
}

/* Toggle buttons (New/Existing, CBO/ABO) */
.toggle-group {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}

.toggle-btn {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
}

.toggle-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.toggle-btn.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(139, 92, 246, 0.2));
    border-color: rgba(99, 102, 241, 0.5);
    color: var(--text-primary);
}

/* Form hint */
.form-hint {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
    opacity: 0.7;
}

.form-hint code {
    background: rgba(138, 92, 246, 0.15);
    color: #a78bfa;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 10px;
}

.form-control-sm {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 12px;
}

.template-toolbar,
.template-actions,
.bulk-row-actions,
.bulk-review-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.template-toolbar,
.bulk-review-header {
    justify-content: space-between;
}

.template-actions {
    flex-wrap: wrap;
}

.bulk-row-actions {
    flex-wrap: wrap;
    margin-top: 12px;
}

.naming-preview {
    margin-top: 6px;
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(138, 92, 246, 0.08);
    border: 1px solid rgba(138, 92, 246, 0.2);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 12px;
    color: #a78bfa;
    letter-spacing: 0.3px;
}

/* Variation fields */
.variation-field {
    margin-bottom: 8px;
    position: relative;
}

.variation-field label {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.variation-remove {
    background: rgba(239, 68, 68, 0.2);
    border: none;
    color: #ef4444;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.variation-remove:hover {
    background: rgba(239, 68, 68, 0.4);
}

/* Creative thumbnails */
.creative-thumbnails {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.thumb-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
    padding: 4px;
}

.thumb-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.88);
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
}

.thumb-badge.warning {
    background: rgba(245, 158, 11, 0.9);
}

.thumb-img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
}

.thumb-video-icon {
    font-size: 32px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 6px;
}

.thumb-name {
    font-size: 10px;
    color: var(--text-muted);
    padding: 4px 0 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.thumb-meta,
.thumb-warning {
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.3;
}

.thumb-warning {
    color: #fcd34d;
}

.thumb-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.thumb-item:hover .thumb-remove {
    opacity: 1;
}

/* Ad count badge */
.ad-count-badge {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    font-size: 13px;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* Progress log */
.bulk-progress {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 12px 16px;
    margin-top: 12px;
}

.progress-header {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.progress-text {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: pre-wrap;
    line-height: 1.6;
    max-height: 200px;
    overflow-y: auto;
}

.bulk-review-wrap,
.bulk-history-panel {
    margin-top: 14px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.025);
}

.bulk-table-scroll {
    margin-top: 8px;
    overflow-x: auto;
}

.bulk-review-table {
    width: 100%;
    min-width: 980px;
    border-collapse: collapse;
}

.bulk-review-table th,
.bulk-review-table td {
    padding: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    vertical-align: top;
    font-size: 12px;
}

.bulk-review-table th {
    color: var(--text-muted);
    font-weight: 700;
    text-align: left;
}

.bulk-review-table tr.row-disabled {
    opacity: 0.5;
}

.row-creative-cell {
    display: grid;
    grid-template-columns: 48px minmax(150px, 1fr);
    gap: 8px;
    min-width: 230px;
}

.row-creative-img,
.row-creative-icon {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
}

.row-creative-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.row-creative-meta strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.aspect-pill {
    width: max-content;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.14);
    color: #86efac;
    font-size: 10px;
    font-weight: 700;
}

.aspect-pill.warning,
.row-warning {
    color: #fcd34d;
}

.aspect-pill.warning {
    background: rgba(245, 158, 11, 0.12);
}

.row-warning {
    font-size: 10px;
}

.table-input,
.table-textarea,
.table-select {
    width: 100%;
    min-width: 120px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.72);
    color: var(--text-primary);
    font-size: 12px;
    padding: 7px 8px;
}

.table-input.url {
    min-width: 190px;
}

.table-textarea {
    min-width: 220px;
    min-height: 58px;
    resize: vertical;
}

.row-actions {
    display: flex;
    gap: 6px;
    min-width: 150px;
}

.bulk-history-list {
    display: grid;
    gap: 8px;
    margin-top: 8px;
}

.history-item {
    display: grid;
    grid-template-columns: minmax(150px, 0.8fr) minmax(180px, 1fr) auto;
    gap: 8px;
    align-items: center;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    font-size: 12px;
}

.history-item code {
    color: #a78bfa;
}

.bulk-confirm-modal {
    max-width: 560px;
}

.bulk-confirm-summary {
    display: grid;
    gap: 8px;
    margin-bottom: 12px;
}

.bulk-confirm-summary div {
    display: grid;
    grid-template-columns: 130px minmax(0, 1fr);
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.bulk-confirm-summary strong {
    color: var(--text-muted);
}

.bulk-confirm-summary span {
    color: var(--text-primary);
    min-width: 0;
    overflow-wrap: anywhere;
}

.bulk-confirm-warning {
    margin: 10px 0 14px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(245, 158, 11, 0.28);
    background: rgba(245, 158, 11, 0.1);
    color: #fcd34d;
    font-size: 13px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

.create-ad-status {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 12px;
    line-height: 1.5;
}

.create-ad-status.info {
    background: rgba(59, 130, 246, 0.08);
    border-color: rgba(59, 130, 246, 0.22);
    color: #93c5fd;
}

.create-ad-status.success {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.22);
    color: #86efac;
}

.create-ad-status.warning {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.24);
    color: #fcd34d;
}

/* Large create button */
.btn-lg {
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 700;
    border-radius: 12px;
}

/* Outline button */
.btn-outline {
    background: transparent;
    border: 1px dashed rgba(255, 255, 255, 0.15);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-outline:hover {
    border-color: rgba(99, 102, 241, 0.5);
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.1);
}

/* ═══════════════════════════════════════════
   Target Cost Inputs & Color-Coded Cells
   ═══════════════════════════════════════════ */
.target-input-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.target-input-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.target-input {
    width: 80px !important;
    padding: 4px 8px !important;
    font-size: 0.8rem !important;
    text-align: center;
}

/* Color-coded cost cells */
.cost-bright-green {
    background: rgba(16, 185, 129, 0.3) !important;
    color: #34d399 !important;
    font-weight: 600;
}

.cost-green {
    background: rgba(16, 185, 129, 0.15) !important;
    color: #6ee7b7 !important;
    font-weight: 600;
}

.cost-yellow {
    background: rgba(245, 158, 11, 0.2) !important;
    color: #fbbf24 !important;
    font-weight: 600;
}

.cost-light-red {
    background: rgba(239, 68, 68, 0.2) !important;
    color: #fca5a5 !important;
    font-weight: 600;
}

.cost-hard-red {
    background: rgba(220, 38, 38, 0.4) !important;
    color: #ff6b6b !important;
    font-weight: 700;
}

/* Breadcrumb navigation */
.insights-breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.breadcrumb-link {
    cursor: pointer;
    color: var(--accent-blue);
    transition: color 0.2s;
}

.breadcrumb-link:hover {
    color: var(--accent-cyan);
    text-decoration: underline;
}

.breadcrumb-sep {
    color: var(--text-muted);
    font-size: 16px;
}

.breadcrumb-current {
    color: var(--text-primary);
    font-weight: 600;
}

/* Drillable table rows */
.sticky-name.drillable {
    cursor: pointer;
    color: var(--accent-blue);
    transition: color 0.2s;
}

.sticky-name.drillable:hover {
    color: var(--accent-cyan);
    text-decoration: underline;
}

/* Active optimization window button */
.opt-window-btn.active {
    border-color: var(--accent-blue) !important;
    background: rgba(99, 102, 241, 0.15) !important;
    color: var(--accent-blue) !important;
}

/* Per-campaign inline target inputs */
.camp-target-cell {
    padding: 2px 4px !important;
    min-width: 70px;
}

.camp-target-input {
    width: 60px;
    padding: 3px 5px;
    font-size: 12px;
    background: var(--bg-secondary);
    border: 1px dashed var(--border-primary);
    border-radius: 4px;
    color: var(--text-primary);
    text-align: center;
}

.camp-target-input:focus {
    border-color: var(--accent-blue);
    border-style: solid;
    outline: none;
}

.camp-target-input::placeholder {
    color: var(--text-muted);
    font-size: 10px;
}

.camp-target-th {
    color: var(--accent-blue) !important;
    font-size: 11px !important;
    white-space: nowrap;
}

/* Playbook suggestion card */
.playbook-card {
    border-left-color: var(--accent-cyan) !important;
    background: rgba(6, 182, 212, 0.05) !important;
}

.playbook-text {
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
    font-size: 12px;
    line-height: 1.6;
}

.severity-icon.playbook {
    background: rgba(6, 182, 212, 0.15);
    color: var(--accent-cyan);
}

/* Level badges in optimization suggestions */
.level-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    margin-right: 6px;
    letter-spacing: 0.5px;
}

.level-campaign {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-blue);
}

.level-adset {
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
}

.level-ad {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.level-account,
.level-reference {
    background: rgba(6, 182, 212, 0.15);
    color: var(--accent-cyan);
}

/* Optimization level sub-tabs */
.opt-level-tab {
    padding: 8px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.opt-level-tab:hover {
    color: var(--text-primary);
}

.opt-level-tab.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
    font-weight: 600;
}

.opt-level-panel {
    min-height: 60px;
}

/* Combined optimization window sections */
.combined-window-section {
    border-bottom: 1px solid var(--border-primary);
    padding-bottom: 8px;
    margin-bottom: 0;
}

.combined-window-section:last-child {
    border-bottom: none;
}

.combined-window-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
}

.combined-window-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-blue);
    letter-spacing: 0.3px;
}

.combined-window-count {
    font-size: 11px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 10px;
}

/* Gemini Analysis Output */
.gemini-analysis-output {
    line-height: 1.7;
    font-size: 14px;
    color: var(--text-primary);
}

.gemini-analysis-output h1 {
    font-size: 22px;
    font-weight: 800;
    margin: 24px 0 12px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gemini-analysis-output h2 {
    font-size: 18px;
    font-weight: 700;
    margin: 20px 0 10px;
    color: var(--accent-blue);
    border-bottom: 1px solid var(--border-primary);
    padding-bottom: 6px;
}

.gemini-analysis-output h3 {
    font-size: 15px;
    font-weight: 700;
    margin: 16px 0 8px;
    color: var(--text-primary);
}

.gemini-analysis-output h4 {
    font-size: 14px;
    font-weight: 600;
    margin: 12px 0 6px;
    color: var(--text-secondary);
}

.gemini-analysis-output p {
    margin: 8px 0;
}

.gemini-analysis-output strong {
    color: var(--text-primary);
    font-weight: 700;
}

.gemini-analysis-output em {
    color: var(--accent-cyan);
}

.gemini-analysis-output ul,
.gemini-analysis-output ol {
    margin: 8px 0;
    padding-left: 24px;
}

.gemini-analysis-output li {
    margin: 4px 0;
}

.gemini-analysis-output hr {
    border: none;
    border-top: 1px solid var(--border-primary);
    margin: 20px 0;
}

table.gemini-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 13px;
}

.gemini-table th {
    background: var(--bg-secondary);
    padding: 8px 12px;
    text-align: left;
    font-weight: 700;
    border-bottom: 2px solid var(--border-primary);
    color: var(--text-primary);
}

.gemini-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-primary);
    color: var(--text-secondary);
}

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

.gemini-analysis-output pre {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    padding: 12px;
    overflow-x: auto;
    font-size: 12px;
    margin: 12px 0;
}

code.inline-code {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-blue);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

/* Automatic ad spend breakdown */
.auto-ad-results {
    margin-top: 16px;
}

.auto-ad-ai-output {
    margin-top: 14px;
    padding: 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
}

.auto-ad-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.auto-ad-summary>div,
.auto-ad-metrics>div {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    padding: 10px;
}

.auto-ad-summary span,
.auto-ad-metrics span {
    display: block;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.auto-ad-summary strong,
.auto-ad-metrics strong {
    color: var(--text-primary);
    font-size: 15px;
}

.auto-ad-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auto-ad-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    overflow: hidden;
}

.auto-ad-card summary {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) 120px 150px;
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
    cursor: pointer;
    list-style: none;
}

.auto-ad-card summary::-webkit-details-marker {
    display: none;
}

.auto-ad-rank {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 800;
}

.auto-ad-main {
    min-width: 0;
}

.auto-ad-name {
    color: var(--text-primary);
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auto-ad-path {
    color: var(--text-muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auto-ad-spend {
    color: var(--text-primary);
    font-weight: 800;
    text-align: right;
}

.auto-ad-verdict {
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    padding: 5px 10px;
    text-align: center;
}

.auto-ad-verdict.good {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.auto-ad-verdict.watch {
    background: rgba(245, 158, 11, 0.16);
    color: #f59e0b;
}

.auto-ad-verdict.bad {
    background: rgba(239, 68, 68, 0.16);
    color: #ef4444;
}

.auto-ad-verdict.neutral {
    background: rgba(148, 163, 184, 0.14);
    color: var(--text-secondary);
}

.auto-ad-breakdown {
    border-top: 1px solid var(--border-primary);
    padding: 14px;
}

.auto-ad-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
}

.auto-ad-funnel {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    color: var(--text-secondary);
    font-size: 13px;
    margin: 12px 0;
}

.auto-ad-action {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
    border-left: 3px solid var(--accent-blue);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 13px;
}

@media (max-width: 760px) {
    .auto-ad-card summary {
        grid-template-columns: 40px minmax(0, 1fr);
    }

    .auto-ad-spend,
    .auto-ad-verdict {
        grid-column: 2;
        text-align: left;
        width: fit-content;
    }
}
