        /* =========================================================
   UI REFRESH (CSS-ONLY) — DO NOT TOUCH PHP/JS LOGIC
   ========================================================= */

        /* Theme tokens */
        :root {
            --bg0: #070A10;
            --bg1: #0B1020;
            --bg2: #0A0F18;
            --surface: #0F172A;
            --surface2: rgba(15, 23, 42, .72);
            --panel: #E9EAEE;
            --panel2: #F4F5F7;
            --card: #FFFFFF;
            --card2: rgba(255, 255, 255, .78);
            --text: #E5E7EB;
            --textDark: #0B1220;
            --muted: rgba(148, 163, 184, .92);
            --border: rgba(148, 163, 184, .20);
            --borderDark: rgba(2, 6, 23, .12);
            --shadow: 0 18px 40px rgba(0, 0, 0, .35);
            --shadowSoft: 0 10px 22px rgba(15, 23, 42, .18);
            --radius: 16px;
            --radiusSm: 12px;
            --accent: #EF4444;
            --accent2: #F43F5E;
            --success: #22C55E;
            --warn: #F59E0B;
            --info: #3B82F6;
        }

        /* App backdrop */
        html,
        body {
            background:
                radial-gradient(1100px 700px at 18% 0%, rgba(239, 68, 68, .18) 0%, rgba(11, 16, 32, 0) 60%),
                radial-gradient(900px 600px at 88% 8%, rgba(59, 130, 246, .16) 0%, rgba(11, 16, 32, 0) 58%),
                radial-gradient(1000px 700px at 50% 120%, rgba(34, 197, 94, .10) 0%, rgba(11, 16, 32, 0) 55%),
                linear-gradient(180deg, var(--bg1) 0%, var(--bg0) 55%, #05070B 100%) !important;
            color: var(--text);
        }

        /* Subtle font/number polish */
        body {
            letter-spacing: .01em;
            font-variant-numeric: tabular-nums;
        }

        /* ---------- Shell layout tuning ---------- */
        .view-section {
            gap: 14px;
        }

        /* Main canvas (right side panels) */
        .view-section>.flex-1 {
            background: linear-gradient(180deg, var(--panel2) 0%, var(--panel) 100%) !important;
            color: var(--textDark) !important;
            border-radius: var(--radius) !important;
            box-shadow: var(--shadowSoft) !important;
            border: 1px solid var(--borderDark) !important;
            position: relative;
        }

        /* Keep scrollbars clean */
        .view-section>.flex-1 {
            scrollbar-width: thin;
            scrollbar-color: rgba(2, 6, 23, .25) transparent;
        }

        .view-section>.flex-1::-webkit-scrollbar {
            height: 10px;
            width: 10px;
        }

        .view-section>.flex-1::-webkit-scrollbar-thumb {
            background: rgba(2, 6, 23, .22);
            border-radius: 999px;
        }

        .view-section>.flex-1::-webkit-scrollbar-track {
            background: transparent;
        }

        /* ---------- Sidebar refresh ---------- */
        @media (min-width: 769px) {
            .side-panel {
                margin: 16px 0 16px 16px !important;
                height: calc(100% - 32px) !important;
                border-radius: var(--radius) !important;
                background:
                    radial-gradient(700px 420px at 20% 0%, rgba(239, 68, 68, .12) 0%, rgba(15, 23, 42, 0) 60%),
                    linear-gradient(180deg, rgba(15, 23, 42, .92) 0%, rgba(2, 6, 23, .92) 100%) !important;
                border: 1px solid var(--border) !important;
                box-shadow: var(--shadow) !important;
                backdrop-filter: blur(10px);
            }
        }

        /* Mobile sidebar */
        @media (max-width: 768px) {
            .side-panel {
                background:
                    radial-gradient(700px 420px at 20% 0%, rgba(239, 68, 68, .12) 0%, rgba(15, 23, 42, 0) 60%),
                    linear-gradient(180deg, rgba(15, 23, 42, .96) 0%, rgba(2, 6, 23, .96) 100%) !important;
                border-right: 1px solid var(--border) !important;
                box-shadow: var(--shadow) !important;
            }
        }

        /* Sidebar headers & list */
        .side-header {
            background: transparent !important;
            border-bottom: 1px solid rgba(148, 163, 184, .14) !important;
        }

        .side-title {
            color: rgba(226, 232, 240, .92) !important;
            letter-spacing: .12em !important;
            font-weight: 800 !important;
        }

        .side-list {
            scrollbar-width: thin;
            scrollbar-color: rgba(148, 163, 184, .35) transparent;
            transition: max-height 0.3s ease-in-out, opacity 0.3s ease-in-out;
            max-height: 800px; /* Arbitrary large height for animation */
            overflow-y: auto;
            opacity: 1;
        }

        .side-list.collapsed {
            max-height: 0;
            opacity: 0;
            overflow: hidden;
            border-bottom: none !important;
            padding-bottom: 0 !important;
            margin-bottom: 0 !important;
        }

        .side-header {
            cursor: pointer;
            transition: background 0.2s;
            user-select: none;
        }

        .side-header:hover {
            background: rgba(255, 255, 255, 0.03) !important;
        }

        .accordion-arrow {
            display: inline-block;
            transition: transform 0.3s ease;
            font-size: 10px;
            margin-right: 6px;
            color: rgba(148, 163, 184, 0.8);
        }

        .side-header.collapsed .accordion-arrow {
            transform: rotate(-90deg);
        }

        /* Multi button (pill) */
        .multi-btn {
            border-radius: 999px !important;
            border: 1px solid rgba(239, 68, 68, .40) !important;
            background: rgba(239, 68, 68, .10) !important;
            color: rgba(254, 226, 226, .95) !important;
            font-weight: 800 !important;
            letter-spacing: .08em;
            transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
        }

        .multi-btn:hover {
            background: rgba(239, 68, 68, .20) !important;
            box-shadow: 0 0 0 4px rgba(239, 68, 68, .14);
            transform: translateY(-1px);
        }

        /* ---------- Cards (Intelligence grid + others) ---------- */
        .company-card,
        .card,
        .panel-card {
            border-radius: var(--radius) !important;
        }

        .company-card {
            background: linear-gradient(180deg, rgba(255, 255, 255, .92) 0%, rgba(255, 255, 255, .78) 100%) !important;
            border: 1px solid rgba(2, 6, 23, .10) !important;
            box-shadow: 0 14px 28px rgba(2, 6, 23, .10) !important;
            transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
        }

        .company-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 18px 40px rgba(2, 6, 23, .14) !important;
            border-color: rgba(239, 68, 68, .22) !important;
        }

        /* Clamp utility for cards */
        .clamp-category {
            display: -webkit-box;
            -webkit-line-clamp: 3;
            -webkit-box-orient: vertical;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: normal;
        }

        /* Card title row */
        .company-card h3 {
            color: rgba(11, 18, 32, .92) !important;
        }

        .company-card .meta,
        .company-card .muted,
        .company-card .sub {
            color: rgba(71, 85, 105, .92) !important;
        }

        /* Checkbox polish (existing selectors remain) */
        .company-card input[type="checkbox"],
        .card-cb {
            accent-color: var(--accent);
        }

        /* ---------- Tabs / segmented controls ---------- */
        .tab-btn,
        .h-sub-btn {
            border-radius: 999px !important;
            border: 1px solid rgba(148, 163, 184, .28) !important;
            background: rgba(255, 255, 255, .08) !important;
            color: rgba(226, 232, 240, .92) !important;
            transition: background .15s ease, box-shadow .15s ease, transform .15s ease;
        }

        .tab-btn:hover,
        .h-sub-btn:hover {
            background: rgba(255, 255, 255, .14) !important;
            transform: translateY(-1px);
        }

        .tab-btn.active,
        .h-sub-btn.active {
            background: linear-gradient(90deg, rgba(239, 68, 68, .28) 0%, rgba(244, 63, 94, .20) 100%) !important;
            border-color: rgba(239, 68, 68, .48) !important;
            box-shadow: 0 0 0 4px rgba(239, 68, 68, .12);
        }

        /* Hunter sub bar container */
        #view-hunter .bg-\[\#1e293b\] {
            background: rgba(2, 6, 23, .55) !important;
            border-radius: var(--radius) !important;
            margin: 16px 16px 0 16px !important;
            border: 1px solid var(--border) !important;
            backdrop-filter: blur(10px);
        }

        /* ---------- Modals ---------- */
        .modal .modal-content,
        .modal-content {
            border-radius: calc(var(--radius) + 2px) !important;
            border: 1px solid rgba(148, 163, 184, .22) !important;
            box-shadow: 0 30px 70px rgba(0, 0, 0, .45) !important;
        }

        /* ---------- Buttons (existing IDs/classes preserved) ---------- */
        button {
            transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
        }

        button:hover {
            transform: translateY(-1px);
        }

        button:active {
            transform: translateY(0px);
        }

        /* Keep existing color semantics but soften edges */
        #saveBtnHeader {
            border-radius: 999px !important;
            box-shadow: 0 10px 20px rgba(34, 197, 94, .22) !important;
        }

        #refreshBtn {
            border-radius: 999px !important;
        }

        /* ---------- Login screen ---------- */
        #login-screen {
            background: radial-gradient(1200px 800px at 20% 0%, rgba(239, 68, 68, .18) 0%, rgba(11, 16, 32, 0) 60%),
                linear-gradient(180deg, #0B1120 0%, #05070B 100%) !important;
        }

        /* ---------- Leaflet / map aesthetic alignment ---------- */
        .leaflet-container {
            border-radius: var(--radius) !important;
            overflow: hidden;
        }

        .scout-popup .leaflet-popup-content-wrapper {
            border-radius: var(--radiusSm) !important;
        }

        /* ---------- STATS TAB UPGRADE (CSS-ONLY) ---------- */
        #view-stats .stats-shell {
            background:
                radial-gradient(900px 520px at 18% 0%, rgba(99, 102, 241, .10) 0%, rgba(11, 16, 32, 0) 60%),
                radial-gradient(900px 520px at 82% 10%, rgba(20, 184, 166, .08) 0%, rgba(11, 16, 32, 0) 60%),
                linear-gradient(180deg, rgba(2, 6, 23, .10) 0%, rgba(2, 6, 23, .00) 65%) !important;
            color: var(--text) !important;
        }

        #view-stats h2,
        #view-stats h3,
        #view-stats .kpi-value {
            color: var(--text) !important;
        }

        #view-stats .border-t,
        #view-stats .border-b,
        #view-stats .divide-y> :not([hidden])~ :not([hidden]) {
            border-color: rgba(148, 163, 184, .18) !important;
        }

        #view-stats .kpi-card {
            background: linear-gradient(180deg, rgba(15, 23, 42, .82) 0%, rgba(2, 6, 23, .82) 100%) !important;
            border: 1px solid rgba(148, 163, 184, .18) !important;
            border-radius: var(--radius) !important;
            box-shadow: 0 12px 24px rgba(0, 0, 0, .25) !important;
        }

        #view-stats .kpi-card .text-slate-400,
        #view-stats .kpi-card .text-slate-500 {
            color: rgba(148, 163, 184, .85) !important;
        }

        #view-stats .kpi-value {
            font-variant-numeric: tabular-nums;
            letter-spacing: .01em;
        }

        #view-stats .bg-white.rounded-xl.shadow {
            background: linear-gradient(180deg, rgba(15, 23, 42, .78) 0%, rgba(2, 6, 23, .78) 100%) !important;
            border: 1px solid rgba(148, 163, 184, .18) !important;
            border-radius: var(--radius) !important;
            box-shadow: 0 14px 28px rgba(0, 0, 0, .28) !important;
        }

        #view-stats .bg-white.rounded-xl.shadow .text-slate-500,
        #view-stats .bg-white.rounded-xl.shadow .text-slate-600 {
            color: rgba(148, 163, 184, .90) !important;
        }

        #view-stats #tactical-briefing h2 {
            letter-spacing: .08em;
            text-transform: uppercase;
            font-size: 12px !important;
        }

        #view-stats #tactical-briefing .bg-white {
            background: linear-gradient(180deg, rgba(15, 23, 42, .80) 0%, rgba(2, 6, 23, .80) 100%) !important;
            border: 1px solid rgba(99, 102, 241, .24) !important;
            border-left-width: 4px !important;
            border-radius: var(--radius) !important;
        }

        /* Professionalize briefing list colors (override tailwind utility classes only within STATS) */
        #view-stats #task-list .bg-red-100 {
            background: rgba(99, 102, 241, .14) !important;
        }

        #view-stats #task-list .text-red-700 {
            color: rgba(226, 232, 240, .92) !important;
        }

        #view-stats #task-list .bg-amber-100 {
            background: rgba(14, 165, 233, .12) !important;
        }

        #view-stats #task-list .text-amber-700 {
            color: rgba(226, 232, 240, .92) !important;
        }

        #view-stats #task-list .bg-green-100 {
            background: rgba(16, 185, 129, .14) !important;
        }

        #view-stats #task-list .text-green-700 {
            color: rgba(226, 232, 240, .92) !important;
        }

        #view-stats #task-list .hover\:bg-slate-50:hover {
            background: rgba(148, 163, 184, .08) !important;
        }

        /* Ensure briefing rows match the dark system */
        #view-stats #task-list .font-bold.text-slate-800 {
            color: rgba(241, 245, 249, .94) !important;
        }

        #view-stats #task-list .text-slate-400 {
            color: rgba(148, 163, 184, .88) !important;
        }

        #view-stats #task-list .text-slate-500 {
            color: rgba(148, 163, 184, .86) !important;
        }

        /* "OPEN DOSSIER" button restyle (keep DOM intact; override visuals) */
        #view-stats #task-list button {
            background: rgba(15, 23, 42, .55) !important;
            border: 1px solid rgba(148, 163, 184, .22) !important;
            color: rgba(226, 232, 240, .92) !important;
            border-radius: 999px !important;
            padding: 6px 12px !important;
        }

        #view-stats #task-list button:hover {
            background: rgba(99, 102, 241, .18) !important;
            border-color: rgba(99, 102, 241, .28) !important;
            color: rgba(255, 255, 255, .96) !important;
        }

        /* Load more button */
        #view-stats .briefing-loadmore {
            height: 40px;
            border-radius: 999px;
            font-weight: 800;
            letter-spacing: .04em;
            font-size: 12px;
            text-transform: uppercase;
            background: rgba(15, 23, 42, .65);
            border: 1px solid rgba(148, 163, 184, .22);
            color: rgba(226, 232, 240, .92);
        }

        #view-stats .briefing-loadmore:hover {
            background: rgba(99, 102, 241, .18);
            border-color: rgba(99, 102, 241, .30);
        }

        #view-stats #task-list {
            color: var(--text) !important;
        }

        #view-stats .text-[#0B1120] {
            color: var(--text) !important;
        }

        #view-stats .bg-[#f3f4f6] {
            background: transparent !important;
        }

        /* ─── PHASE 2: SPEED & FEEL ───────────────────────────────── */

        /* Save Indicator Pill */
        #ay-save-indicator {
            position: fixed;
            bottom: 24px;
            right: 24px;
            padding: 7px 16px;
            border-radius: 999px;
            font-size: 11px;
            font-weight: 800;
            letter-spacing: .06em;
            text-transform: uppercase;
            z-index: 99990;
            pointer-events: none;
            opacity: 0;
            transform: translateY(8px);
            transition: opacity 0.25s ease, transform 0.25s ease;
            font-family: 'Inter', sans-serif;
            backdrop-filter: blur(8px);
            border: 1px solid transparent;
        }
        #ay-save-indicator.visible {
            opacity: 1;
            transform: translateY(0);
        }
        #ay-save-indicator.saving {
            background: rgba(197, 160, 89, 0.18);
            border-color: rgba(197, 160, 89, 0.4);
            color: #C5A059;
        }
        #ay-save-indicator.ok {
            background: rgba(5, 150, 105, 0.18);
            border-color: rgba(5, 150, 105, 0.4);
            color: #34d399;
        }
        #ay-save-indicator.error {
            background: rgba(239, 68, 68, 0.18);
            border-color: rgba(239, 68, 68, 0.4);
            color: #f87171;
        }

        /* Skeleton Loaders */
        @keyframes ay-skeleton-pulse {
            0%, 100% { opacity: 1; }
            50%       { opacity: 0.45; }
        }
        .ay-skeleton {
            border-radius: 16px;
            background: rgba(255,255,255,0.06);
            border: 1px solid rgba(148,163,184,0.10);
            padding: 16px;
            animation: ay-skeleton-pulse 1.6s ease-in-out infinite;
        }
        .ay-skeleton-line {
            height: 10px;
            border-radius: 999px;
            background: rgba(148,163,184,0.18);
            margin-bottom: 10px;
        }
        .ay-skeleton-line.short { width: 55%; }
        .ay-skeleton-line.medium { width: 75%; }
        .ay-skeleton-line.long  { width: 90%; }
        .ay-skeleton-line.thin  { height: 7px; }

        /* Page Tab Fade-In */
        .view-section {
            animation: ay-fadein 0.18s ease both;
        }
        @keyframes ay-fadein {
            from { opacity: 0; transform: translateY(5px); }
            to   { opacity: 1; transform: translateY(0); }
        }

        /* Kanban drag-over column highlight */
        .kanban-col.ay-drag-over {
            background: rgba(197, 160, 89, 0.07) !important;
            outline: 2px dashed rgba(197, 160, 89, 0.5);
            outline-offset: -2px;
            border-radius: 12px;
        }

        /* Kanban card drag ghost opacity */
        .kanban-item[draggable="true"]:active {
            opacity: 0.6;
            transform: scale(0.97);
        }

        /* Search highlight */
        mark.ay-hi {
            background: rgba(197, 160, 89, 0.3);
            color: inherit;
            border-radius: 2px;
            padding: 0 1px;
        }

        /* ─── PHASE 3: ACTIVITY TIMELINE ──────────────────────────── */

        .ay-timeline {
            border-top: 1px solid rgba(148,163,184,0.15);
            margin-top: 16px;
            padding-top: 14px;
        }
        .ay-timeline-title {
            font-size: 10px;
            font-weight: 800;
            letter-spacing: .1em;
            text-transform: uppercase;
            color: rgba(148,163,184,0.8);
            margin-bottom: 10px;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        .ay-timeline-actions {
            display: flex;
            gap: 6px;
            margin-bottom: 12px;
            flex-wrap: wrap;
        }
        .ay-act-btn {
            padding: 5px 12px;
            border-radius: 999px;
            border: 1px solid rgba(148,163,184,0.25);
            background: rgba(15,23,42,0.6);
            color: rgba(226,232,240,0.9);
            font-size: 11px;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.15s ease;
        }
        .ay-act-btn:hover {
            background: rgba(197,160,89,0.15);
            border-color: rgba(197,160,89,0.4);
            color: #C5A059;
            transform: translateY(-1px);
        }
        .ay-act-btn.active {
            background: rgba(197,160,89,0.2);
            border-color: rgba(197,160,89,0.5);
            color: #C5A059;
        }
        .ay-timeline-input {
            width: 100%;
            background: rgba(15,23,42,0.7);
            border: 1px solid rgba(148,163,184,0.2);
            border-radius: 8px;
            padding: 8px 12px;
            color: white;
            font-size: 12px;
            margin-bottom: 8px;
            outline: none;
            transition: border-color 0.15s ease;
            box-sizing: border-box;
        }
        .ay-timeline-input:focus {
            border-color: rgba(197,160,89,0.5);
        }
        .ay-timeline-add-btn {
            background: rgba(197,160,89,0.2);
            border: 1px solid rgba(197,160,89,0.4);
            color: #C5A059;
            font-weight: 800;
            font-size: 11px;
            padding: 6px 16px;
            border-radius: 999px;
            cursor: pointer;
            transition: all 0.15s ease;
            letter-spacing: .05em;
        }
        .ay-timeline-add-btn:hover {
            background: rgba(197,160,89,0.35);
        }
        .ay-timeline-entries {
            display: flex;
            flex-direction: column;
            gap: 8px;
            max-height: 240px;
            overflow-y: auto;
            scrollbar-width: thin;
            scrollbar-color: rgba(148,163,184,0.2) transparent;
        }
        .ay-entry {
            display: flex;
            gap: 10px;
            align-items: flex-start;
            padding: 8px 10px;
            background: rgba(15,23,42,0.4);
            border-radius: 8px;
            border: 1px solid rgba(148,163,184,0.08);
            position: relative;
        }
        .ay-entry-icon {
            font-size: 15px;
            flex-shrink: 0;
            margin-top: 1px;
        }
        .ay-entry-body { flex: 1; min-width: 0; }
        .ay-entry-note {
            font-size: 12px;
            color: rgba(226,232,240,0.9);
            line-height: 1.5;
        }
        .ay-entry-meta {
            font-size: 10px;
            color: rgba(148,163,184,0.7);
            margin-top: 2px;
        }
        .ay-entry-del {
            opacity: 0;
            background: none;
            border: none;
            color: rgba(239,68,68,0.7);
            cursor: pointer;
            font-size: 13px;
            padding: 0 4px;
            transition: opacity 0.15s ease;
        }
        .ay-entry:hover .ay-entry-del { opacity: 1; }

        /* ─── PWA / MOBILE BOTTOM NAV ─────────────────────────────── */

        @media (max-width: 768px) {
            #ay-mobile-nav {
                display: flex !important;
            }
            #nav-tabs .hidden.md\:flex { display: none !important; }

            /* Push content above bottom nav */
            #app { padding-bottom: 64px; }
        }

        #ay-mobile-nav {
            display: none;
            position: fixed;
            bottom: 0; left: 0; right: 0;
            height: 60px;
            background: rgba(11,16,32,0.97);
            backdrop-filter: blur(16px);
            border-top: 1px solid rgba(148,163,184,0.15);
            z-index: 9000;
            align-items: center;
            justify-content: space-around;
            padding: 0 8px;
        }
        .ay-mob-btn {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 3px;
            padding: 6px 12px;
            border-radius: 12px;
            border: none;
            background: transparent;
            color: rgba(148,163,184,0.7);
            font-size: 10px;
            font-weight: 700;
            letter-spacing: .05em;
            cursor: pointer;
            transition: all 0.15s ease;
            min-width: 50px;
        }
        .ay-mob-btn .ay-mob-icon { font-size: 18px; }
        .ay-mob-btn.active, .ay-mob-btn:hover {
            color: #C5A059;
            background: rgba(197,160,89,0.08);
        }
    </style>
