        * {
            box-sizing: border-box;
        }

        html,
        body {
            overflow-x: hidden;
            /* Forces vertical only */
            width: 100%;
            position: relative;
        }

        :root {
            --bg-body: #09090b;
            --bg-card: #18181b;
            --bg-panel: #27272a;
            --bg-drawer: #1c1c20;
            --text-main: #e4e4e7;
            --text-muted: #a1a1aa;
            --border: #3f3f46;
            --accent-blue: #3b82f6;
            --accent-green: #22c55e;
            --accent-red: #ef4444;
            --accent-gold: #eab308;
            --neon-green: #00ff88;
        }

        body {
            background-color: var(--bg-body);
            color: var(--text-main);
            font-family: 'Inter', sans-serif;
            margin: 0;
            padding: 20px;
            padding-top: 100px;
            /* Compensate for Fixed Header */
        }

        /* --- HEADER --- */
        .dashboard-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 15px 20px;
            /* Fixed padding */
            /* border-bottom: 1px solid var(--border);*/
            position: fixed;
            /* Fixed for Desktop to handle overflow issues */
            top: 0;
            left: 0;
            width: 100%;
            background-color: var(--bg-body);
            z-index: 1000;
            gap: 15px;
            min-height: 80px;
            /* Explicit height to match padding-top calculation */
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
            transition: top 0.3s;
        }

        .header-logo h1 {
            margin: 0;
            font-size: 1.8rem;
            letter-spacing: -1px;
            font-weight: 800;
        }

        .version-tag {
            font-size: 0.8rem;
            color: var(--text-muted);
            font-family: 'JetBrains Mono', monospace;
            background: rgba(255, 255, 255, 0.05);
            padding: 2px 6px;
            border-radius: 4px;
            border: 1px solid var(--border);
            margin-left: 10px;
            vertical-align: middle;
        }

        .neon-x {
            color: var(--neon-green);
        }

        .header-right {
            display: flex;
            align-items: center;
            gap: 15px;
            justify-content: flex-end;
            z-index: 20;
            /* Ensure buttons are clickable above search if overlap occurs */
        }

        .search-container {
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            /* Perfectly centered */
            width: 100%;
            max-width: 450px;
            /* Fixed width for the search bar */
            z-index: 10;
        }

        .search-input {
            width: 100%;
            padding: 12px 50px 12px 20px;
            /* Increased right padding */
            background: var(--bg-panel);
            border: 1px solid var(--border);
            color: white;
            border-radius: 8px;
            /* Slightly more modern radius */
            font-size: 0.95rem;
            transition: all 0.2s;
            box-sizing: border-box;
            /* Ensure padding doesn't break width */
        }

        .search-input:focus {
            outline: none;
            border-color: var(--accent-blue);
            box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
        }

        /* The Exit/Clear "X" Button */
        .search-clear-btn {
            position: absolute;
            right: 12px;
            top: 50%;
            /* Lowered per user feedback for mobile alignment */
            transform: translateY(-50%);
            width: 32px;
            height: 32px;
            background: none;
            border: none;
            color: var(--text-muted);
            cursor: pointer;
            display: none;
            /* JS toggles to flex */
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            transition: background 0.2s, color 0.2s;
            z-index: 20;
            padding: 0;
        }

        .search-clear-btn:hover {
            color: var(--text-main);
            background: rgba(255, 255, 255, 0.1);
        }

        /* Auto-Suggest Dropdown (UPDATED) */
        .suggestions-box {
            position: absolute;
            top: 100%;
            /* Directly below input */
            left: 0;
            width: 100%;
            /* Spans exact width of parent .search-container */
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 0 0 8px 8px;
            z-index: 1000;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
            max-height: 300px;
            overflow-y: auto;
            display: none;
            margin-top: 4px;
        }

        .suggestion-item {
            padding: 12px 15px;
            cursor: pointer;
            border-bottom: 1px solid rgba(255, 255, 255, 0.05);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .suggestion-item:last-child {
            border-bottom: none;
        }

        .suggestion-item:hover {
            background: rgba(59, 130, 246, 0.1);
            color: var(--accent-blue);
        }

        .s-ticker {
            font-weight: 700;
            font-family: 'JetBrains Mono', monospace;
            font-size: 1rem;
        }

        .s-name {
            font-size: 0.8rem;
            color: var(--text-muted);
        }

        /* --- ACCORDION STYLES --- */
        .accordion-wrapper {
            border-top: 1px solid var(--border);
            background: rgba(0, 0, 0, 0.2);
        }

        .accordion-item {
            border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        }

        .accordion-item:last-child {
            border-bottom: none;
        }

        .accordion-header {
            width: 100%;
            padding: 12px 20px;
            background: transparent;
            border: none;
            color: var(--text-muted);
            font-size: 0.8rem;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 1px;
            text-align: left;
            cursor: pointer;
            display: flex;
            justify-content: space-between;
            align-items: center;
            transition: all 0.2s;
        }

        .accordion-header:hover {
            color: white;
            background: rgba(255, 255, 255, 0.02);
        }

        .accordion-header.active {
            color: var(--accent-blue);
            background: rgba(59, 130, 246, 0.05);
        }

        .accordion-header i {
            transition: transform 0.3s;
        }

        .accordion-header.active i {
            transform: rotate(180deg);
        }

        .accordion-body {
            max-height: 0;
            overflow: hidden;
            transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            background: rgba(0, 0, 0, 0.3);
        }

        .accordion-content {
            padding: 15px 20px;
        }

        /* Inner Data Grids */
        .detail-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 15px;
        }

        .detail-box {
            display: flex;
            flex-direction: column;
        }

        .detail-label {
            font-size: 0.7rem;
            color: var(--text-muted);
            margin-bottom: 4px;
        }

        .detail-val {
            font-size: 0.9rem;
            font-weight: 600;
            font-family: 'JetBrains Mono';
        }

        /* Mobile Responsive Adjustments */
        @media (max-width: 768px) {
            body {
                padding: 10px;
                padding-top: 0;
            }

            .dashboard-header {
                flex-wrap: wrap;
                gap: 10px;
                position: relative;
                top: 0;
                padding: 15px 0 10px 0;
                display: flex;
                justify-content: space-between;
                align-items: center;
                z-index: 1000;
                background-color: var(--bg-body);
                box-shadow: none;
            }

            .header-logo {
                order: 1;
            }

            .header-right {
                order: 2;
            }

            .search-container {
                order: 3;
                position: relative;
                top: 0;
                left: 0;
                transform: none;
                width: 100%;
                max-width: 100%;
                z-index: 10;
                margin-top: 10px;
                background: transparent;
                padding-bottom: 5px;
                margin-bottom: 0;
                transition: none;
            }
        }


        /* --- DRAWER TRIGGERS --- */
        .trigger-btn {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            font-size: 1.2rem;
            transition: all 0.3s ease;
            position: relative;
            flex-shrink: 0;
            /* Prevent shrinking */
        }

        .gear-trigger {
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid var(--border);
            color: var(--text-muted);
        }

        .gear-trigger:hover {
            background: rgba(59, 130, 246, 0.1);
            color: var(--accent-blue);
            border-color: var(--accent-blue);
            transform: rotate(90deg);
        }

        .gear-trigger.active {
            background: var(--accent-blue);
            color: white;
            border-color: var(--accent-blue);
            transform: rotate(90deg);
        }

        .arrow-trigger {
            background: rgba(0, 255, 136, 0.1);
            border: 1px solid var(--neon-green);
            color: var(--neon-green);
            animation: pulse-green 3s infinite;
        }

        .arrow-trigger:hover {
            background: var(--neon-green);
            color: black;
            box-shadow: 0 0 15px var(--neon-green);
        }

        .arrow-trigger.active {
            transform: rotate(180deg);
            background: var(--neon-green);
            color: black;
        }

        @keyframes pulse-green {
            0% {
                box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.4);
            }

            70% {
                box-shadow: 0 0 0 10px rgba(0, 255, 136, 0);
            }

            100% {
                box-shadow: 0 0 0 0 rgba(0, 255, 136, 0);
            }
        }

        /* --- SHARED DRAWER STYLES --- */
        .top-drawer {
            background: var(--bg-drawer);
            overflow: hidden;
            max-height: 0;
            transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
            margin-bottom: 0;
            border-radius: 0 0 12px 12px;
            opacity: 0;
        }

        .top-drawer.open {
            margin-bottom: 20px;
            opacity: 1;
            border-bottom: 1px solid;
        }

        #settingsDrawer.open {
            border-color: var(--accent-blue);
        }

        #filterDrawer.open {
            border-color: var(--neon-green);
        }

        .drawer-content {
            padding: 20px;
            overflow-y: auto;
            flex-grow: 1;
            /* Safe area for mobile bottom nav */
            padding-bottom: 80px;
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            align-items: end;
        }

        /* --- FORM ELEMENTS --- */
        .filter-group label {
            display: block;
            color: var(--text-muted);
            font-size: 0.75rem;
            margin-bottom: 8px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .input-dark {
            width: 100%;
            padding: 10px;
            background: var(--bg-body);
            border: 1px solid var(--border);
            color: white;
            border-radius: 6px;
            box-sizing: border-box;
        }

        .input-dark:focus {
            outline: none;
            border-color: var(--accent-blue);
        }

        .filter-range {
            width: 100%;
            accent-color: var(--neon-green);
        }

        .btn-action {
            width: 100%;
            padding: 10px;
            border-radius: 6px;
            font-weight: 600;
            cursor: pointer;
            border: 1px solid transparent;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
        }

        .btn-add {
            background: var(--accent-blue);
            color: white;
        }

        .btn-add:hover {
            background: #2563eb;
        }

        /* --- GRID & CARDS --- */
        .stock-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
            gap: 20px;
            margin-top: 20px;
        }

        .card {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 12px;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            transition: transform 0.2s;
        }

        .card-header {
            padding: 15px 20px;
            background: rgba(255, 255, 255, 0.02);
            border-bottom: 1px solid var(--border);
            display: flex;
            justify-content: space-between;
            align-items: center;
            /* Allow badges to wrap to next line */
        }

        .ticker-info h2 {
            margin: 0;
            font-size: 1.4rem;
            font-weight: 800;
        }

        .ticker-info p {
            margin: 4px 0 0 0;
            font-size: 0.85rem;
            color: var(--text-muted);
            line-height: 1.2;
        }

        .company-badges {
            display: flex;
            gap: 6px;
            margin-top: 6px;
            flex-wrap: wrap;
        }

        .badge-pill {
            text-align: center;
            font-size: 0.7rem;
            color: var(--text-muted);
            background: rgba(255, 255, 255, 0.05);
            padding: 2px 6px;
            border-radius: 4px;
            border: 1px solid rgba(255, 255, 255, 0.1);
            white-space: nowrap;
        }

        .price-info {
            text-align: right;
        }

        .price-main {
            font-family: 'JetBrains Mono', monospace;
            font-size: 1.25rem;
            font-weight: 700;
        }

        .ai-bar {
            padding: 8px 10px;
            background: rgba(59, 130, 246, 0.08);
            border-bottom: 1px solid var(--border);
            display: grid;
            grid-template-columns: 1fr 1fr 1fr 1fr;
            align-items: center;
            justify-items: center;
        }

        .ai-label {
            font-size: 0.75rem;
            color: var(--accent-blue);
            font-weight: 700;
            text-transform: uppercase;
        }

        .ai-badge {
            font-size: 0.8rem;
            font-weight: 800;
            padding: 3px 8px;
            border-radius: 4px;
        }

        .ai-insight-box {
            padding: 12px 20px;
            background: rgba(59, 130, 246, 0.03);
            border-bottom: 1px solid var(--border);
            font-size: 0.85rem;
            line-height: 1.5;
            color: var(--text-main);
        }

        .ai-insight-box i {
            color: var(--accent-blue);
            margin-right: 8px;
        }

        .ai-rr {
            font-size: 0.8rem;
            font-weight: 700;
            color: var(--accent-gold);
            font-family: 'JetBrains Mono', monospace;
            letter-spacing: -0.5px;
        }

        .badge-buy {
            color: var(--accent-green);
            background: rgba(34, 197, 94, 0.1);
        }

        .badge-sell {
            color: var(--accent-red);
            background: rgba(239, 68, 68, 0.1);
        }

        .badge-hold {
            color: var(--text-muted);
            border: 1px solid var(--border);
        }

        .card-body {
            padding: 20px;
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .data-row {
            display: flex;
            justify-content: space-between;
            font-size: 0.9rem;
        }

        .label {
            color: var(--text-muted);
        }

        .val {
            font-family: 'JetBrains Mono', monospace;
            font-weight: 600;
        }

        .text-green {
            color: var(--accent-green);
        }

        .text-red {
            color: var(--accent-red);
        }

        .card-footer {
            padding: 12px 20px;
            background: var(--bg-panel);
            border-top: 1px solid var(--border);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .icon-btn {
            background: none;
            border: none;
            color: var(--text-muted);
            cursor: pointer;
        }

        .icon-btn:hover {
            color: white;
        }

        /* Shared style for the top data grids */
        .stat-grid {
            display: grid;
            grid-template-columns: 1fr 1fr 1fr;
            gap: 1px;
            /* Tighter gap */
            background: var(--border);
            /* Borders created by gap */
            border: 1px solid var(--border);
            border-radius: 8px;
            overflow: hidden;
            margin-bottom: 10px;
        }

        .stat-item {
            background: var(--bg-card);
            /* Restore card bg */
            padding: 8px 4px;
            text-align: center;
            display: flex;
            flex-direction: column;
            justify-content: center;
        }

        .stat-label {
            font-size: 0.65rem;
            color: var(--text-muted);
            margin-bottom: 2px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .stat-val {
            font-size: 0.85rem;
            font-weight: 700;
            font-family: 'JetBrains Mono';
        }

        /* --- FILTER DRAWER STYLES --- */
        #filterDrawer {
            background: var(--bg-drawer);
            /* border-bottom: 1px solid var(--border);*/
            overflow-y: auto;
            max-height: 0;
            /* Hidden by default */
            transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        }

        #filterDrawer.open {
            max-height: 85vh;
            /* Ample space for content */
            border-bottom: 1px solid var(--accent-blue);
            /* Visual cue when open */
        }

        .filter-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
            gap: 25px;
            padding: 25px;
        }

        .filter-col h4 {
            font-size: 0.75rem;
            font-weight: 700;
            text-transform: uppercase;
            color: var(--accent-blue);
            letter-spacing: 1px;
            margin-bottom: 15px;
            padding-bottom: 5px;
            border-bottom: 1px solid var(--border);
        }

        .filter-group {
            margin-bottom: 12px;
        }

        .filter-label {
            display: block;
            font-size: 0.7rem;
            color: var(--text-muted);
            margin-bottom: 5px;
            text-transform: uppercase;
            font-weight: 600;
        }

        /* Custom Inputs to match your theme */
        .f-input,
        .f-select {
            width: 100%;
            background: rgba(0, 0, 0, 0.3);
            border: 1px solid var(--border);
            color: var(--text-main);
            padding: 8px 10px;
            border-radius: 6px;
            font-size: 0.85rem;
            transition: border-color 0.2s;
        }

        .f-input:focus,
        .f-select:focus {
            outline: none;
            border-color: var(--accent-blue);
            background: rgba(0, 0, 0, 0.5);
        }

        .f-row {
            display: flex;
            gap: 10px;
        }

        /* Checkbox Style */
        .f-check-label {
            display: flex;
            align-items: center;
            gap: 8px;
            cursor: pointer;
            font-size: 0.85rem;
            color: var(--text-muted);
            transition: color 0.2s;
            margin-bottom: 8px;
        }

        .f-check-label:hover {
            color: white;
        }

        .f-check-input {
            accent-color: var(--accent-blue);
        }

        /* Header Actions */
        .drawer-actions {
            padding: 15px 25px;
            background: rgba(0, 0, 0, 0.2);
            border-bottom: 1px solid var(--border);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        @media(max-width: 600px) {
            .drawer-content {
                grid-template-columns: 1fr;
            }
        }

        /* Chart Modal */
        .chart-modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.85);
            z-index: 2000;
            justify-content: center;
            align-items: center;
            backdrop-filter: blur(5px);
        }

        .chart-content {
            background: var(--bg-card);
            width: 95%;
            max-width: 900px;
            height: 70vh;
            border-radius: 12px;
            padding: 20px;
            position: relative;
            border: 1px solid var(--border);
            display: flex;
            flex-direction: column;
            box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
        }

        .chart-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 10px;
        }

        /* --- TIME BADGES --- */
        .time-badge {
            font-size: 0.65rem;
            color: var(--text-muted);
            margin-top: 2px;
            display: flex;
            align-items: center;
            justify-content: flex-end;
            gap: 4px;
            opacity: 0.8;
            font-family: 'JetBrains Mono', monospace;
        }

        .time-badge i {
            font-size: 0.6rem;
        }

        .chart-title {
            font-size: 1.2rem;
            font-weight: 700;
            color: white;
            font-family: 'JetBrains Mono';
        }

        .chart-close {
            color: var(--text-muted);
            font-size: 1.8rem;
            cursor: pointer;
            line-height: 1;
        }

        .chart-close:hover {
            color: var(--accent-red);
        }

        #chartContainer {
            width: 100%;
            flex-grow: 1;
            border-radius: 8px;
            overflow: hidden;
            position: relative;
        }

        /* --- SCROLL TO TOP BTN --- */
        .scroll-to-top {
            position: fixed;
            bottom: 30px;
            left: 30px;
            width: 50px;
            height: 50px;
            background: rgba(34, 197, 94, 0.2);
            /* Low opacity green bg */
            border: 2px solid var(--accent-green);
            color: var(--accent-green);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.5rem;
            cursor: pointer;
            z-index: 999;
            opacity: 0;
            visibility: hidden;
            transition: all 0.3s ease;
            box-shadow: 0 0 15px rgba(34, 197, 94, 0.3);
        }

        .scroll-to-top.visible {
            opacity: 1;
            visibility: visible;
        }

        @media (hover: hover) {
            .scroll-to-top:hover {
                background: var(--accent-green);
                color: black;
                transform: translateY(-5px);
                box-shadow: 0 0 25px var(--accent-green);
            }
        }

        /* --- SKELETON LOADER --- */
        .skeleton-card {
            background: var(--card-bg);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 20px;
            height: 350px;
            position: relative;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            gap: 15px;
        }

        .skeleton-shimmer {
            background: #27272a;
            background-image: linear-gradient(to right,
                    #27272a 0%,
                    #3f3f46 20%,
                    #27272a 40%,
                    #27272a 100%);
            background-repeat: no-repeat;
            background-size: 800px 350px;
            display: inline-block;
            position: relative;

            animation-duration: 1.5s;
            animation-fill-mode: forwards;
            animation-iteration-count: infinite;
            animation-name: placeholderShimmer;
            animation-timing-function: linear;
            border-radius: 4px;
        }

        @keyframes placeholderShimmer {
            0% {
                background-position: -468px 0;
            }

            100% {
                background-position: 468px 0;
            }
        }

        .sk-header {
            height: 40px;
            width: 60%;
        }

        .sk-price {
            height: 30px;
            width: 40%;
            margin-top: 5px;
        }

        .sk-chart {
            height: 100px;
            width: 100%;
            border-radius: 8px;
            margin-top: 10px;
        }

        .sk-row {
            height: 15px;
            width: 100%;
            margin-top: 5px;
        }

        .sk-footer {
            height: 20px;
            width: 80%;
            margin-top: auto;
        }