        :root {
            --bg: #0f0f0f;
            --surface: #1a1a1a;
            --surface2: #242424;
            --border: #333;
            --text: #e8e8e8;
            --text-dim: #999;
            --accent: #ff0000;
            --accent-soft: #cc0000;
            --green: #2ecc71;
            --yellow: #f39c12;
            --red: #e74c3c;
            --blue: #3498db;
        }

        * { margin: 0; padding: 0; box-sizing: border-box; }

        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
            background: var(--bg);
            color: var(--text);
            line-height: 1.5;
        }

        .container {
            max-width: 1100px;
            margin: 0 auto;
            padding: 24px;
        }

        header {
            text-align: center;
            padding: 32px 0 24px;
            border-bottom: 1px solid var(--border);
            margin-bottom: 32px;
        }

        header h1 {
            font-size: 1.6rem;
            font-weight: 600;
            letter-spacing: 0.02em;
        }

        header .date {
            color: var(--text-dim);
            font-size: 0.9rem;
            margin-top: 4px;
        }

        header .last-updated {
            color: var(--text-dim);
            font-size: 0.78rem;
            margin-top: 2px;
        }

        header .last-updated .countdown {
            color: var(--accent);
        }

        .user-info {
            color: var(--text-dim);
            font-size: 0.85rem;
            margin-top: 8px;
        }

        .user-info a {
            color: var(--accent);
            text-decoration: none;
        }

        .user-info a:hover {
            text-decoration: underline;
        }

        .error-banner {
            background: #3a1a1a;
            border: 1px solid var(--red);
            border-radius: 8px;
            padding: 16px 20px;
            margin-bottom: 24px;
            color: #f8d7da;
        }

        /* ── Grid layout ──────────────────────────────────── */
        .grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 20px;
            margin-bottom: 20px;
        }

        .grid .full-width {
            grid-column: 1 / -1;
        }

        .card {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 10px;
            padding: 20px 24px;
        }

        .card h2 {
            font-size: 0.85rem;
            text-transform: uppercase;
            letter-spacing: 0.08em;
            color: var(--text-dim);
            margin-bottom: 16px;
        }

        /* ── Progress card ────────────────────────────────── */
        .big-number {
            font-size: 2.4rem;
            font-weight: 700;
            line-height: 1.1;
        }

        .big-number .unit {
            font-size: 1rem;
            font-weight: 400;
            color: var(--text-dim);
        }

        .progress-track {
            width: 100%;
            height: 12px;
            background: var(--surface2);
            border-radius: 6px;
            margin: 16px 0 12px;
            overflow: hidden;
        }

        .progress-fill {
            height: 100%;
            background: linear-gradient(90deg, var(--accent-soft), var(--accent));
            border-radius: 6px;
            transition: width 0.6s ease;
        }

        .progress-label {
            display: flex;
            justify-content: space-between;
            font-size: 0.85rem;
            color: var(--text-dim);
        }

        /* ── Stat rows ────────────────────────────────────── */
        .stat-row {
            display: flex;
            justify-content: space-between;
            padding: 10px 0;
            border-bottom: 1px solid var(--border);
        }

        .stat-row:last-child { border-bottom: none; }

        .stat-label { color: var(--text-dim); font-size: 0.9rem; }

        .stat-value {
            font-weight: 600;
            font-variant-numeric: tabular-nums;
        }

        .stat-value.green  { color: var(--green); }
        .stat-value.yellow { color: var(--yellow); }
        .stat-value.red    { color: var(--red); }

        /* ── Pace tracker ─────────────────────────────────── */
        .pace-grid {
            display: grid;
            grid-template-columns: 1fr 1fr 1fr;
            gap: 16px;
        }

        .pace-metric {
            background: var(--surface2);
            border-radius: 8px;
            padding: 16px;
            text-align: center;
        }

        .pace-metric .period {
            font-size: 0.8rem;
            color: var(--text-dim);
            text-transform: uppercase;
            letter-spacing: 0.06em;
            margin-bottom: 8px;
        }

        .pace-metric .value {
            font-size: 1.6rem;
            font-weight: 700;
            font-variant-numeric: tabular-nums;
        }

        .pace-metric .delta {
            font-size: 0.85rem;
            margin-top: 4px;
            font-variant-numeric: tabular-nums;
        }

        .pace-metric .pace-bar-track {
            height: 6px;
            background: var(--border);
            border-radius: 3px;
            margin-top: 10px;
            overflow: hidden;
        }

        .pace-metric .pace-bar-fill {
            height: 100%;
            border-radius: 3px;
            transition: width 0.4s ease;
        }

        .pace-status-banner {
            margin-top: 16px;
            padding: 10px 16px;
            border-radius: 6px;
            font-size: 0.9rem;
            font-weight: 600;
            text-align: center;
        }

        .pace-status-banner.on_pace {
            background: rgba(46, 204, 113, 0.12);
            border: 1px solid var(--green);
            color: var(--green);
        }

        .pace-status-banner.warning {
            background: rgba(243, 156, 18, 0.12);
            border: 1px solid var(--yellow);
            color: var(--yellow);
        }

        .pace-status-banner.critical {
            background: rgba(231, 76, 60, 0.12);
            border: 1px solid var(--red);
            color: var(--red);
        }

        /* ── Scenario modeling cards ────────────────────────── */
        .scenario-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 16px;
        }

        .scenario-card {
            background: var(--surface2);
            border-radius: 8px;
            padding: 18px 16px;
            text-align: center;
            border: 2px solid transparent;
        }

        .scenario-card.green {
            border-color: var(--green);
        }

        .scenario-card.yellow {
            border-color: var(--yellow);
        }

        .scenario-card.red {
            border-color: var(--red);
        }

        .scenario-card .sc-name {
            font-size: 0.78rem;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.06em;
            margin-bottom: 2px;
        }

        .scenario-card.green .sc-name { color: var(--green); }
        .scenario-card.yellow .sc-name { color: var(--yellow); }
        .scenario-card.red .sc-name { color: var(--red); }

        .scenario-card .sc-subtitle {
            font-size: 0.72rem;
            color: var(--text-dim);
            margin-bottom: 10px;
        }

        .scenario-card .sc-rate {
            font-size: 1.5rem;
            font-weight: 700;
            font-variant-numeric: tabular-nums;
            line-height: 1.2;
        }

        .scenario-card .sc-rate-unit {
            font-size: 0.78rem;
            font-weight: 400;
            color: var(--text-dim);
        }

        .scenario-card .sc-outcome {
            margin-top: 12px;
            font-size: 0.82rem;
            font-weight: 600;
        }

        .scenario-card.green .sc-outcome { color: var(--green); }
        .scenario-card.yellow .sc-outcome { color: var(--yellow); }
        .scenario-card.red .sc-outcome { color: var(--red); }

        .scenario-card .sc-detail {
            font-size: 0.75rem;
            color: var(--text-dim);
            margin-top: 4px;
        }

        /* ── Data tables (shared by traffic, videos, search) ── */
        .data-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 0.9rem;
        }

        .data-table th {
            text-align: left;
            padding: 8px 0;
            color: var(--text-dim);
            font-weight: 500;
            border-bottom: 1px solid var(--border);
        }

        .data-table th.num { text-align: right; }

        .data-table td {
            padding: 8px 0;
            border-bottom: 1px solid var(--surface2);
        }

        .data-table td.num {
            text-align: right;
            font-variant-numeric: tabular-nums;
        }

        .data-table td.rank {
            color: var(--text-dim);
            width: 32px;
            text-align: right;
            padding-right: 12px;
        }

        .data-table td.title-cell {
            max-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .share-bar-cell {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .share-bar {
            height: 6px;
            background: var(--accent);
            border-radius: 3px;
            flex-shrink: 0;
        }

        /* ── Compact data table variant ──────────────────── */
        .data-table-compact th,
        .data-table-compact td {
            padding: 6px 6px;
            font-size: 0.82rem;
        }

        .data-table-compact th.num,
        .data-table-compact td.num {
            white-space: nowrap;
        }

        /* ── Rolloff section ─────────────────────────────── */
        .rolloff-summary {
            margin-bottom: 16px;
            font-size: 0.95rem;
            color: var(--text-dim);
        }

        .rolloff-total {
            font-size: 1.4rem;
            font-weight: 700;
            color: var(--red);
        }

        .rolloff-period {
            font-size: 0.8rem;
        }

        .rolloff-high td {
            background: rgba(231, 76, 60, 0.08);
        }

        .rolloff-danger {
            color: var(--red) !important;
            font-weight: 700;
        }

        /* ── Stacked daily chart ──────────────────────────── */
        .chart-legend {
            display: flex;
            flex-wrap: wrap;
            gap: 8px 18px;
            margin-bottom: 14px;
        }

        .legend-item {
            display: flex;
            align-items: center;
            gap: 6px;
            font-size: 0.78rem;
            color: var(--text-dim);
        }

        .legend-swatch {
            width: 10px;
            height: 10px;
            border-radius: 2px;
            flex-shrink: 0;
        }

        .legend-label {
            max-width: 160px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .stacked-chart {
            display: flex;
            align-items: flex-end;
            gap: 3px;
            height: 180px;
        }

        .stacked-column {
            flex: 1;
            min-width: 4px;
            display: flex;
            flex-direction: column-reverse;
            border-radius: 2px 2px 0 0;
            overflow: hidden;
            cursor: pointer;
            transition: opacity 0.15s;
        }

        .stacked-column:hover { opacity: 0.8; }

        .stacked-segment { width: 100%; }

        .chart-tooltip {
            position: fixed;
            display: none;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 6px;
            padding: 10px 14px;
            font-size: 0.8rem;
            z-index: 100;
            pointer-events: none;
            min-width: 220px;
            max-width: 340px;
            box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
        }

        .tooltip-header {
            display: flex;
            justify-content: space-between;
            align-items: baseline;
            margin-bottom: 8px;
            padding-bottom: 6px;
            border-bottom: 1px solid var(--border);
            gap: 12px;
        }

        .tooltip-date { font-weight: 600; }

        .tooltip-total {
            color: var(--text-dim);
            font-variant-numeric: tabular-nums;
            white-space: nowrap;
        }

        .tooltip-row {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 2px 0;
        }

        .tooltip-swatch {
            width: 8px;
            height: 8px;
            border-radius: 2px;
            flex-shrink: 0;
        }

        .tooltip-title {
            flex: 1;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            color: var(--text-dim);
        }

        .tooltip-hours {
            font-variant-numeric: tabular-nums;
            white-space: nowrap;
        }

        .chart-dates {
            display: flex;
            justify-content: space-between;
            font-size: 0.75rem;
            color: var(--text-dim);
            margin-top: 6px;
        }

        /* ── Chart toggle buttons ────────────────────────── */
        .chart-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 16px;
        }

        .chart-header h2 {
            margin-bottom: 0;
        }

        .chart-toggles {
            display: flex;
            gap: 2px;
            background: var(--surface2);
            border-radius: 6px;
            padding: 3px;
        }

        .chart-toggle {
            background: none;
            border: none;
            color: var(--text-dim);
            padding: 5px 12px;
            border-radius: 4px;
            font-size: 0.78rem;
            font-family: inherit;
            cursor: pointer;
            transition: all 0.15s;
        }

        .chart-toggle:hover {
            color: var(--text);
        }

        .chart-toggle.active {
            background: var(--accent);
            color: #fff;
        }

        /* ── Content gap badges ─────────────────────────────── */
        .gap-badge {
            display: inline-block;
            padding: 2px 10px;
            border-radius: 10px;
            font-size: 0.75rem;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.04em;
        }

        .gap-none {
            background: rgba(231, 76, 60, 0.15);
            color: var(--red);
            border: 1px solid var(--red);
        }

        .gap-weak {
            background: rgba(243, 156, 18, 0.15);
            color: var(--yellow);
            border: 1px solid var(--yellow);
        }

        .gap-covered {
            background: rgba(46, 204, 113, 0.15);
            color: var(--green);
            border: 1px solid var(--green);
        }

        /* ── Title pattern index scores ─────────────────────── */
        .idx-above {
            color: var(--green);
            font-weight: 600;
        }

        .idx-below {
            color: var(--red);
            font-weight: 600;
        }

        .idx-neutral {
            color: var(--text-dim);
        }

        .pattern-baseline td {
            border-top: 2px solid var(--border);
            font-weight: 600;
            color: var(--text);
        }

        /* ── Loading overlay ─────────────────────────────── */
        .loading-overlay {
            position: fixed;
            inset: 0;
            background: var(--bg);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            z-index: 9999;
        }

        .loading-overlay.hidden {
            display: none;
        }

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

        .loading-overlay p {
            margin-top: 16px;
            color: var(--text-dim);
            font-size: 0.9rem;
        }

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

        /* ── Footer ───────────────────────────────────────── */
        footer {
            text-align: center;
            padding: 24px 0 16px;
            border-top: 1px solid var(--border);
            margin-top: 12px;
            color: var(--text-dim);
            font-size: 0.78rem;
        }

        /* ── Table overflow wrapper ──────────────────────── */
        .table-wrap {
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
        }

        /* ── Responsive — tablets (768px) ────────────────── */
        @media (max-width: 768px) {
            .grid { grid-template-columns: 1fr; }
            .pace-grid { grid-template-columns: 1fr; }
            .scenario-grid { grid-template-columns: 1fr 1fr; }
            .container { padding: 16px; }
            .big-number { font-size: 1.8rem; }
            .pace-metric .value { font-size: 1.3rem; }
            .scenario-card .sc-rate { font-size: 1.3rem; }

            .chart-header {
                flex-direction: column;
                gap: 8px;
                align-items: flex-start;
            }

            /* Hide non-essential table columns */
            .data-table .hide-mobile,
            .data-table-compact .hide-mobile { display: none; }
        }

        /* ── Upgrade CTA ────────────────────────────────── */
        .upgrade-cta {
            text-align: center;
            background: linear-gradient(135deg, #1a1a2e, #1a2a1a);
            border-color: #2ecc71;
        }

        .upgrade-cta h2 {
            color: #e8e8e8;
            font-size: 1.1rem;
            text-transform: none;
            letter-spacing: normal;
            margin-bottom: 8px;
        }

        .upgrade-cta p {
            color: var(--text-dim);
            font-size: 0.9rem;
            margin-bottom: 16px;
        }

        .upgrade-btn {
            display: inline-block;
            background: #2ecc71;
            color: #0f0f0f;
            text-decoration: none;
            font-size: 0.95rem;
            font-weight: 600;
            padding: 10px 28px;
            border-radius: 8px;
            transition: background 0.2s;
        }

        .upgrade-btn:hover { background: #27ae60; }

        /* ── Reconnect banner ─────────────────────────────── */
        .reconnect-banner {
            background: linear-gradient(135deg, #2a1a0a, #3a2a1a);
            border: 1px solid var(--yellow);
            border-radius: 10px;
            padding: 32px 24px;
            margin-bottom: 24px;
            text-align: center;
        }

        .reconnect-banner h2 {
            color: var(--yellow);
            font-size: 1.2rem;
            margin-bottom: 8px;
        }

        .reconnect-banner p {
            color: var(--text);
            font-size: 0.95rem;
            margin-bottom: 16px;
            line-height: 1.5;
        }

        .reconnect-btn {
            display: inline-block;
            background: var(--yellow);
            color: #0f0f0f;
            text-decoration: none;
            font-size: 0.95rem;
            font-weight: 600;
            padding: 10px 28px;
            border-radius: 8px;
            transition: background 0.2s;
        }

        .reconnect-btn:hover { background: #e08c00; }

        /* ── Demo banner ──────────────────────────────────── */
        .demo-banner {
            background: linear-gradient(135deg, #0d253f, #0f2a3f);
            border: 1px solid var(--blue);
            border-radius: 10px;
            padding: 20px 24px;
            margin-bottom: 24px;
            text-align: center;
        }

        .demo-banner p {
            color: var(--text);
            font-size: 0.95rem;
            margin-bottom: 14px;
            line-height: 1.5;
        }

        .demo-cta-btn {
            display: inline-block;
            background: var(--blue);
            color: #fff;
            text-decoration: none;
            font-size: 0.95rem;
            font-weight: 600;
            padding: 10px 28px;
            border-radius: 8px;
            transition: background 0.2s;
        }

        .demo-cta-btn:hover { background: #2980b9; }

        .demo-banner-actions {
            display: flex;
            gap: 12px;
            justify-content: center;
            flex-wrap: wrap;
        }

        /* ── AI Export button ──────────────────────────────── */
        .header-actions {
            margin-top: 12px;
        }

        .btn-ai-export {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 8px 16px;
            background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
            color: #fff;
            border: none;
            border-radius: 8px;
            font-size: 0.875rem;
            font-weight: 600;
            text-decoration: none;
            cursor: pointer;
            transition: all 0.2s ease;
            box-shadow: 0 2px 4px rgba(99, 102, 241, 0.25);
        }

        .btn-ai-export:hover {
            background: linear-gradient(135deg, #5558e6 0%, #7c4fe0 100%);
            box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
            transform: translateY(-1px);
            color: #fff;
            text-decoration: none;
        }

        /* ── Responsive — phones (390px) ─────────────────── */
        @media (max-width: 390px) {
            .scenario-grid { grid-template-columns: 1fr; }
            .container { padding: 12px; }
            .card { padding: 16px; }
            .big-number { font-size: 1.5rem; }

            .chart-toggles {
                flex-wrap: wrap;
            }
        }
