/* ═══════════════════════════════════════════════════════════════════════════
   STITCH DEBUGGER — Modern Dark Theme with Gradient Accents
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── CSS Variables ─── */
:root {
    /* Deep, rich backgrounds with blue undertones */
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a2332;
    --bg-input: #0d1321;
    --bg-hover: #243044;
    
    /* Solid backgrounds (no gradients) */
    --bg-gradient: #0a0e17;
    --card-gradient: #1a2332;
    
    /* Vibrant text colors */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Gradient accents - keep for buttons only */
    --accent-primary: #3b82f6;
    --accent-primary-light: #60a5fa;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    
    /* Status colors with glow */
    --accent-success: #10b981;
    --accent-success-glow: rgba(16, 185, 129, 0.3);
    --accent-warning: #f59e0b;
    --accent-warning-glow: rgba(245, 158, 11, 0.3);
    --accent-danger: #ef4444;
    --accent-danger-glow: rgba(239, 68, 68, 0.3);

    /* Refined borders */
    --border-color: rgba(148, 163, 184, 0.1);
    --border-glow: rgba(59, 130, 246, 0.5);
    --border-radius: 10px;
    --border-radius-sm: 6px;
    --border-radius-lg: 16px;

    /* Enhanced shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.15);
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.25), 0 0 40px rgba(59, 130, 246, 0.05);

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

body {
    font-family: var(--font-family);
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ─── Top Navigation ─── */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 2rem;
    background: rgba(17, 24, 39, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 1.5rem;
    filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.5));
}

.logo h1 {
    font-size: 1.7rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tabs {
    display: flex;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.35rem;
    border-radius: var(--border-radius);
}

.tab {
    background: none;
    border: none;
    padding: 0.5rem 1.25rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
}

.tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.tab.active {
    color: #fff;
    background: var(--accent-gradient);
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
}

/* ─── Main Content ─── */
.content {
    max-width: 1800px;
    margin: 0 auto;
    padding: 2rem;
}

/* ─── Tab Panels ─── */
.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* ─── Input Panel ─── */
.input-panel {
    margin-bottom: 2rem;
}

.input-panel h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
}

.input-form {
    background: var(--card-gradient);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.form-group {
    flex: 1;
    min-width: 160px;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.75px;
}

.form-group select,
.form-group input[type="text"],
.form-group input[type="date"] {
    width: 100%;
    padding: 0.7rem 0.9rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

.form-group select:focus,
.form-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15), var(--shadow-glow);
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(4px);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(148, 163, 184, 0.3);
}

/* ─── Button Group ─── */
.btn-group {
    display: inline-flex;
    gap: 0.25rem;
    background: rgba(17, 24, 39, 0.8);
    padding: 0.3rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.btn-group .btn {
    border-radius: calc(var(--border-radius) - 2px);
    padding: 0.5rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid transparent;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.btn-group .btn:hover:not(.active) {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(148, 163, 184, 0.2);
}

.btn-group .btn.active {
    background: var(--accent-gradient);
    color: white;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.btn-group .btn:first-child {
    border-radius: calc(var(--border-radius) - 2px);
}

.btn-group .btn:last-child {
    border-radius: calc(var(--border-radius) - 2px);
}

.btn-group .btn-secondary {
    border-left: none;
}

.btn-group .btn:first-child.btn-secondary {
    border-left: none;
}

/* ─── Spinner ─── */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: rgba(59, 130, 246, 0.8);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner.hidden {
    display: none;
}

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

/* ─── Results Section ─── */
.results-section {
    margin-top: 1.5rem;
}

.results-section.hidden {
    display: none;
}

/* ─── Cards ─── */
.card {
    background: var(--card-gradient);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-card);
    transition: all var(--transition-normal);
}

.card:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.card h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card h3::before {
    content: '';
    width: 4px;
    height: 1.1em;
    background: var(--accent-gradient);
    border-radius: 2px;
}

/* ─── Overview Card ─── */
.overview-content {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.donut-container {
    width: 200px;
    height: 200px;
    flex-shrink: 0;
}

.overview-stats {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-success .stat-value {
    color: var(--accent-success);
}

.stat-danger .stat-value {
    color: var(--accent-danger);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 0.25rem;
}

/* ─── Steps Cards ─── */
.steps-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.step-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.step-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.step-header:hover {
    background: var(--bg-hover);
}

.step-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.step-title {
    font-weight: 500;
    flex: 1;
}

.step-summary {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.step-toggle {
    color: var(--text-muted);
    font-size: 0.8rem;
    transition: transform var(--transition-fast);
}

.step-card.expanded .step-toggle {
    transform: rotate(180deg);
}

.step-body {
    display: none;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.step-card.expanded .step-body {
    display: block;
}

/* Grid container for simple metrics */
.step-metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem 1.5rem;
    margin-bottom: 1rem;
}

.step-metric {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0;
    gap: 0.25rem;
}

/* Full-width metrics for tables/objects */
.step-metric.full-width {
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.step-metric-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 500;
}

.step-metric-value {
    color: var(--text-primary);
    font-weight: 500;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    overflow-x: auto;
}

/* Nested tables inside step metrics */
.step-metric-value table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.step-metric-value table th,
.step-metric-value table td {
    padding: 0.35rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.step-metric-value table th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.step-metric-value table tr:last-child td {
    border-bottom: none;
}

/* ─── Timeline Chart ─── */
.timeline-container {
    height: 400px;
    position: relative;
}

/* ─── Records Table ─── */
.table-wrapper {
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.75px;
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 2px solid var(--border-color);
}

th:first-child {
    border-radius: var(--border-radius-sm) 0 0 0;
}

th:last-child {
    border-radius: 0 var(--border-radius-sm) 0 0;
}

td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(71, 85, 105, 0.3);
    color: var(--text-primary);
    white-space: nowrap;
    transition: background var(--transition-fast);
}

tbody tr {
    transition: all var(--transition-fast);
}

tbody tr:hover {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.08) 0%, rgba(139, 92, 246, 0.05) 100%);
}

tbody tr:hover td {
    border-bottom-color: rgba(59, 130, 246, 0.2);
}

.status-stitched {
    color: var(--accent-success);
    font-weight: 600;
}

.status-unstitched {
    color: var(--accent-danger);
    font-weight: 600;
}

/* ─── Verdict Box ─── */
.verdict-content {
    padding: 1.25rem;
    border-radius: var(--border-radius);
    font-size: 0.95rem;
}

.verdict-green {
    background: rgba(52, 211, 153, 0.1);
    border: 1px solid var(--accent-success);
}

.verdict-yellow {
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid var(--accent-warning);
}

.verdict-red {
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid var(--accent-danger);
}

.verdict-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.verdict-green .verdict-title { color: var(--accent-success); }
.verdict-yellow .verdict-title { color: var(--accent-warning); }
.verdict-red .verdict-title { color: var(--accent-danger); }

.verdict-issues {
    list-style: none;
    padding: 0;
}

.verdict-issues li {
    padding: 0.3rem 0;
    padding-left: 1.25rem;
    position: relative;
    color: var(--text-secondary);
}

.verdict-issues li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--text-muted);
}

.verdict-issue-message {
    color: var(--text-primary);
}

.verdict-issue-detail {
    display: block;
    margin-top: 0.35rem;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    white-space: normal;
    word-wrap: break-word;
}

/* ─── Discover Tables ─── */
.discover-tables {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.discover-table-card {
    margin-bottom: 0;
}

.table-title.best { color: var(--accent-success); }
.table-title.worst { color: var(--accent-warning); }

.discover-table tbody tr {
    cursor: pointer;
    transition: all var(--transition-fast);
}

.discover-table tbody tr:hover {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.1) 0%, rgba(139, 92, 246, 0.05) 100%);
    transform: scale(1.005);
}

/* ─── Error Box ─── */
.error-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(248, 113, 113, 0.08);
    border: 1px solid var(--accent-danger);
    border-radius: var(--border-radius);
    color: var(--accent-danger);
    font-size: 0.9rem;
}

.error-box.hidden {
    display: none;
}

/* ─── Utility ─── */
.hidden {
    display: none !important;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .top-nav {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
    }

    .content {
        padding: 1rem;
    }

    .form-row {
        flex-direction: column;
    }

    .form-group {
        min-width: 100%;
    }

    .overview-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .donut-container {
        width: 150px;
        height: 150px;
        margin: 0 auto;
    }

    .overview-stats {
        justify-content: center;
        width: 100%;
    }

    .discover-tables {
        grid-template-columns: 1fr;
    }

    .settings-field {
        flex-direction: column;
        align-items: flex-start;
    }

    .settings-field label {
        min-width: unset;
    }

    .settings-field input {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .tabs {
        flex-wrap: wrap;
    }

    .tab {
        padding: 0.4rem 0.75rem;
        font-size: 0.85rem;
    }
}

/* ─── Device Info Panel ─── */
.device-info-panel {
    border-left: 1px solid var(--border-color);
    padding-left: 2rem;
    margin-left: 1rem;
    display: flex;
    flex-direction: row;
    gap: 2rem;
    min-width: 200px;
    align-items: flex-start;
}

.device-section {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.device-header {
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    font-weight: 600;
    white-space: nowrap;
}

.device-count {
    font-size: 0.95rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.device-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.device-id {
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 3px 8px;
    border-radius: 3px;
    color: var(--accent-primary);
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* DASHBOARD                                                                   */
/* ═══════════════════════════════════════════════════════════════════════════ */

.dashboard-header { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    margin-bottom: 2rem;
    position: sticky;
    top: 56px;  /* Below the top-nav */
    background: var(--bg-primary);
    padding: 1rem 0;
    z-index: 90;  /* Below nav's z-index of 100 */
    border-bottom: 1px solid var(--border-color);
}
.dashboard-header h2 { margin: 0; font-size: 1.75rem; font-weight: 700; }
.dashboard-controls { display: flex; align-items: center; gap: 1rem; }
.dashboard-cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; margin-bottom: 2rem; max-width: 900px; margin-left: auto; margin-right: auto; }
.platform-card { 
    background: var(--card-gradient); 
    border: 1px solid var(--border-color); 
    border-radius: var(--border-radius); 
    padding: 1.25rem 1.5rem; 
    position: relative; 
    overflow: visible; 
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
    flex: 1;
    min-width: 300px;
    max-width: 440px;
}
.platform-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity var(--transition-fast);
}
.platform-card:hover { 
    transform: translateY(-2px); 
    box-shadow: var(--shadow-md);
}
.platform-card:hover::before {
    opacity: 1;
}
.platform-card.health-good { border-left: 3px solid var(--accent-success); }
.platform-card.health-medium { border-left: 3px solid var(--accent-warning); }
.platform-card.health-bad { border-left: 3px solid var(--accent-danger); }
.platform-card-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border-color); }
.platform-card-icon { font-size: 1.25rem; }
.platform-card-name { font-size: 1.25rem; font-weight: 700; }
.platform-card-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.metric-item { display: flex; flex-direction: column; padding: 0.25rem; border-radius: var(--border-radius-sm); transition: background var(--transition-fast); }
.metric-item:hover { background: rgba(255, 255, 255, 0.03); }
.metric-value { font-size: 1.25rem; font-weight: 700; font-family: var(--font-mono); color: var(--text-primary); }
.metric-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 0.25rem; display: flex; align-items: center; gap: 0.25rem; }

/* Info Icon with Tooltip */
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    cursor: help;
    opacity: 0.6;
    transition: opacity var(--transition-fast), color var(--transition-fast);
    position: relative;
}

.info-icon:hover {
    opacity: 1;
    color: var(--accent-primary);
}

.info-icon[data-tooltip] {
    position: relative;
}

.info-icon[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    color: var(--text-secondary);
    white-space: normal;
    width: 220px;
    line-height: 1.4;
    z-index: 1000;
    box-shadow: var(--shadow-md);
    margin-top: 0.25rem;
}

.info-icon[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: var(--border-color);
    margin-top: -6px;
    z-index: 1001;
}

/* Trend Arrow Tooltip */
.trend-arrow {
    position: relative;
    display: inline-block;
    font-weight: bold;
}

.trend-arrow:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 0.35rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-secondary);
    white-space: nowrap;
    z-index: 100;
    box-shadow: var(--shadow-md);
    margin-top: 0.25rem;
}

.dashboard-trends { margin-bottom: 2.5rem; }
.dashboard-trends h3 { margin-bottom: 1.25rem; font-size: 1.25rem; font-weight: 600; }
.trends-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.trends-column { display: flex; flex-direction: column; gap: 1.5rem; }
.trend-chart { background: var(--card-gradient); border: 1px solid var(--border-color); border-radius: var(--border-radius); padding: 1rem; height: 300px; box-shadow: var(--shadow-sm); }
.trend-chart-large { background: var(--card-gradient); border: 1px solid var(--border-color); border-radius: var(--border-radius); padding: 1rem; height: 380px; box-shadow: var(--shadow-sm); }
.dashboard-placeholder { background: var(--card-gradient); border: 1px solid var(--border-color); border-radius: var(--border-radius-lg); padding: 3rem; text-align: center; grid-column: 1 / -1; box-shadow: var(--shadow-card); }
.dashboard-placeholder p { color: var(--text-secondary); margin: 0; font-size: 1rem; }
.dashboard-placeholder code { background: var(--bg-input); padding: 0.3em 0.6em; border-radius: var(--border-radius-sm); font-size: 0.85em; color: var(--accent-primary); }

/* ─── Section Divider ─── */
.section-divider {
    height: 1px;
    background: linear-gradient(to right, transparent, var(--accent-primary), var(--accent-secondary), transparent);
    margin: 2.5rem 0 2rem;
    opacity: 0.3;
}

/* ─── Unified Funnel ─── */
.funnel-container {
    background: var(--card-gradient);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    max-width: 900px;
    margin: 0 auto;
}

.funnel-charts-row {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.funnel-chart-wrapper {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    height: 280px;
    width: 100%;
    max-width: 400px;
    transition: all var(--transition-normal);
}

.funnel-chart-wrapper:hover {
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.funnel-metrics-grid {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.funnel-platform-metrics {
    background: var(--bg-secondary);
    flex: 1;
    max-width: 400px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    transition: all var(--transition-fast);
}

.funnel-platform-metrics:hover {
    border-color: rgba(59, 130, 246, 0.3);
}

.funnel-platform-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.funnel-metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.25rem;
    font-size: 0.85rem;
    border-radius: var(--border-radius-sm);
    transition: background var(--transition-fast);
}

.funnel-metric-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.funnel-metric-label {
    color: var(--text-secondary);
}

.funnel-metric-value {
    font-weight: 700;
    font-family: var(--font-mono);
}

.funnel-metric-value.highlight-good { color: var(--accent-success); }
.funnel-metric-value.highlight-warn { color: var(--accent-warning); }
.funnel-metric-value.highlight-bad { color: var(--accent-danger); }

@media (max-width: 1024px) {
    .funnel-charts-row,
    .funnel-metrics-grid {
        flex-direction: column;
        align-items: center;
    }
    .funnel-chart-wrapper,
    .funnel-platform-metrics {
        max-width: 100%;
    }
}


/* ─── Toggle Switch for Include Ads ─── */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.toggle-switch input {
    display: none;
}

.toggle-slider {
    width: 44px;
    height: 24px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    position: relative;
    transition: all var(--transition-fast);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-slider::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: var(--text-secondary);
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.toggle-switch:hover .toggle-slider {
    border-color: rgba(148, 163, 184, 0.4);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent-gradient);
    border-color: transparent;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.3), inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.toggle-switch input:checked + .toggle-slider::after {
    background: white;
    transform: translateX(20px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.toggle-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.toggle-switch:hover .toggle-slider {
    border-color: var(--accent-primary);
}

/* ─── Date Range Filter ─── */
.trends-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.trends-header h3 {
    margin: 0;
}

.date-range-filter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.date-range-filter label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.date-range-filter select {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--bg-surface);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
}

.date-range-filter select:hover {
    border-color: var(--accent-primary);
}

.date-range-filter select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.15);
}

/* Dashboard controls layout */
.dashboard-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    position: sticky;
    top: 56px;  /* Below the top-nav */
    background: var(--bg-primary);
    padding: 1rem 0;
    z-index: 90;  /* Below nav's z-index of 100 */
    border-bottom: 1px solid var(--border-color);
}


/* ─── Loading States ─── */
.loading-shimmer {
    background: linear-gradient(90deg, 
        var(--bg-secondary) 25%, 
        rgba(59, 130, 246, 0.1) 50%, 
        var(--bg-secondary) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ─── Empty States ─── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* ─── Pulse Animation for Live Indicators ─── */
.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ─── Gradient Text Utility ─── */
.gradient-text {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ─── Responsive Adjustments ─── */
@media (max-width: 768px) {
    .dashboard-cards {
        grid-template-columns: 1fr;
    }
    
    .trends-row {
        grid-template-columns: 1fr;
    }
    
    .discover-tables {
        grid-template-columns: 1fr;
    }
    
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .dashboard-controls {
        width: 100%;
        flex-wrap: wrap;
    }
}

/* ─── Scrollbar Styling ─── */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
}

/* ─── Selection Styling ─── */
::selection {
    background: rgba(59, 130, 246, 0.3);
    color: var(--text-primary);
}

/* ─── Focus Visible for Accessibility ─── */
:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

button:focus-visible,
.btn:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* ─── Date Picker Calendar Icon ─── */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}
