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

:root {
    /* TRUE BLACK PALETTE */
    --bg-app: #000000;
    --bg-panel: #050505;
    --bg-card: #0A0A0A;
    --bg-hover: #121212;
    --bg-glass: rgba(5, 5, 5, 0.9);

    /* BORDERS & SEPARATORS */
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.15);

    /* TEXT */
    --text-primary: #FFFFFF;
    --text-secondary: #A1A1AA;
    --text-muted: #52525B;

    /* BRAND & ACCENTS */
    --accent-blue: #2962FF;
    /* TradingView Blue */
    --accent-purple: #7C3AED;
    --accent-cyan: #06B6D4;

    /* SIGNAL COLORS */
    --up: #089981;
    /* TradingView Green */
    --down: #F23645;
    /* TradingView Red */

    /* LAYOUT VARIABLES */
    --header-height: 48px;
    --sidebar-width-left: 260px;
    --sidebar-width-right: 280px;
    --z-header: 50;
    --z-drawer: 40;
    --z-overlay: 30;
}

/* RESET & BASE */
* {
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    overflow: hidden;
    /* App-like */
    margin: 0;
    padding: 0;
    height: 100vh;
    width: 100vw;
}

/* TYPOGRAPHY */
.font-mono {
    font-family: 'JetBrains Mono', monospace;
}

.font-sans {
    font-family: 'Inter', sans-serif;
}

/* UTILITIES */
.text-up {
    color: var(--up);
}

.text-down {
    color: var(--down);
}

.bg-up-dim {
    background-color: rgba(8, 153, 129, 0.12);
}

.bg-down-dim {
    background-color: rgba(242, 54, 69, 0.12);
}

/* SCROLLBAR - Minimalist */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

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

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* LAYOUT HELPERS */
.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
}

.border-b-subtle {
    border-bottom: 1px solid var(--border-subtle);
}

.border-r-subtle {
    border-right: 1px solid var(--border-subtle);
}

.border-t-subtle {
    border-top: 1px solid var(--border-subtle);
}

.border-l-subtle {
    border-left: 1px solid var(--border-subtle);
}

/* ANIMATIONS */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

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

.animate-fade {
    animation: fadeIn 0.3s ease-out forwards;
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

/* INTERACTIVE ELEMENTS */
.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    color: var(--text-secondary);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.btn-icon:hover,
.btn-icon.active {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-icon:active {
    transform: scale(0.95);
}

input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

/* RESPONSIVE LAYOUT - V4 (REFERENCE MATCH) */
@media (min-width: 0px) {
    :root {
        --header-height: 80px;
        /* Taller, cleaner header */
        --chart-height: 55vh;
        /* Fixed chart area */
    }

    /* Main Container */
    .app-grid {
        display: flex !important;
        flex-direction: column;
        height: 100vh;
        width: 100vw;
        background: #000;
    }

    /* 1. Header */
    .grid-header {
        flex: 0 0 var(--header-height);
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        background: #000;
        z-index: 50;
    }

    /* 2. Chart Section */
    .grid-main {
        height: var(--chart-height);
        width: 100%;
        position: relative;
        border-bottom: 1px solid var(--border-subtle);
    }

    /* 3. Data Table Section (Takes remaining space) */
    .grid-countries {
        flex: 1;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        background: #000;
    }
}

/* BIG SELECTOR (Header) */
.big-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.big-selector:hover {
    opacity: 0.8;
}

.big-selector-title {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: #fff;
}

/* DATA GRID (Table) */
.data-grid {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Inter', sans-serif;
}

.grid-head-row th {
    position: sticky;
    top: 0;
    background: #000;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 12px 16px;
    text-align: right;
    border-bottom: 1px solid var(--border-subtle);
    z-index: 10;
}

.grid-head-row th:first-child {
    text-align: left;
}

.grid-row {
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.1s;
}

.grid-row:hover {
    background: #0A0A0A;
}

.grid-cell {
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-primary);
    text-align: right;
    white-space: nowrap;
}

.grid-cell:first-child {
    text-align: left;
}

.cell-sub {
    color: var(--text-secondary);
    font-size: 11px;
    margin-left: 6px;
}

/* Custom Checkbox */
.row-check {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1px solid var(--border-light);
    background: transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 12px;
}

.row-check.checked {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
}

.row-check:hover {
    border-color: white;
}

/* MEGA MENU OVERLAY (Retained & Refined) */
.mega-menu-backdrop {
    position: fixed;
    inset: 0;
    top: var(--header-height);
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.mega-menu-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.mega-menu-content {
    width: 100%;
    max-height: 60vh;
    background: #050505;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    transform: translateY(-20px);
    transition: transform 0.2s ease;
}

.mega-menu-backdrop.active .mega-menu-content {
    transform: translateY(0);
}

.mega-col-cats {
    width: 220px;
    border-right: 1px solid var(--border-subtle);
    background: #020202;
}

.mega-col-items {
    flex: 1;
    background: #000;
    padding: 24px;
}

.mega-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

/* Category Button */
.mega-cat-btn {
    width: 100%;
    text-align: left;
    padding: 14px 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 3px solid transparent;
}

.mega-cat-btn.active {
    background: #090909;
    color: #fff;
    border-left-color: var(--accent-blue);
}

/* Item Button */
.mega-item-btn {
    text-align: left;
    padding: 10px 14px;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    background: #080808;
    transition: all 0.1s;
}

.mega-item-btn:hover {
    border-color: var(--text-secondary);
    background: #111;
}

.mega-item-btn.active {
    border-color: var(--accent-blue);
    background: #111;
}

.mega-item-name {
    font-weight: 600;
    font-size: 13px;
    color: #fff;
    margin-bottom: 2px;
}

.mega-item-code {
    font-size: 10px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono';
}

/* Country Card (Bottom Strip) */
.country-chip {
    flex-shrink: 0;
    height: 48px;
    padding: 0 16px;
    border-radius: 99px;
    /* Pill */
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.country-chip:hover {
    border-color: var(--text-muted);
}

.country-chip.active {
    background: var(--bg-hover);
    border-color: var(--accent-blue);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.country-chip.disabled {
    opacity: 0.3;
    pointer-events: none;
    border-color: transparent;
    background: transparent;
}