/* NAV (Shared) */
nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 3rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Force Right Side items (Language, Theme, Notif, Wallet, Auth) to stay in one line */
nav>div:last-child {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.logo {
    font-weight: 700;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--black);
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-light);
    font-weight: 500;
    font-size: 0.95rem;
}

/* Dropdown CSS (Shared) */
.dropdown {
    position: relative;
}

.dropdown>a {
    display: flex;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    color: var(--text-light);
}

.dropdown-content {
    display: none;
    position: absolute;
    background: var(--white);
    min-width: 160px;
    box-shadow: var(--shadow-lg);
    padding: 8px 0;
    border-radius: 8px;
    top: 100%;
    z-index: 1000;
    border: 1px solid var(--border);
}

.dropdown:hover .dropdown-content {
    display: block;
}

.dropdown-content a {
    display: block;
    padding: 10px 16px;
    color: var(--text-light);
    margin: 0;
}

.dropdown-content a:hover {
    background: rgba(0, 0, 0, 0.03);
    color: var(--primary);
}

/* Wallet Styles (Header) */
.wallet-pill {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 12px 4px 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
    height: 32px;
}

body.dark .wallet-pill {
    background: #171717;
    border-color: #262626;
    color: #d4d4d4;
}

/* User Dropdown items in Header */
.login-btn-nav {
    background: #171717;
    color: #fff;
    padding: 10px 24px;
    border-radius: 100px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wallet-pill img {
    height: 20px;
    width: auto;
    max-width: 32px;
    object-fit: contain;
    display: block;
    image-rendering: -webkit-optimize-contrast;
}

.login-btn-nav svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

body.dark .login-btn-nav {
    background: #fff;
    color: #000;
}

.user-nav-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

.user-nav-dropdown {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
    padding: 4px;
    border-radius: 30px;
}

.user-nav-dropdown:hover {
    background: rgba(0, 0, 0, 0.05);
}

body.dark .user-nav-dropdown:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* --- GLOBAL MODAL (CHARMY STYLE) --- */
.charmy-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    /* backdrop-filter: blur(8px); */
    z-index: 10000;
    display: none;
    /* Flex when active */
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.charmy-modal-overlay.show {
    opacity: 1;
}

.charmy-modal-box {
    background: #fff;
    width: 90%;
    max-width: 400px;
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform: scale(0.95);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: center;
    position: relative;
    border: 1px solid var(--border);
}

body.dark .charmy-modal-box {
    background: #111;
    border: 1px solid #333;
    color: #fff;
}

.charmy-modal-overlay.show .charmy-modal-box {
    transform: scale(1);
}

.charmy-modal-title {
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 12px;
    color: var(--text-main);
}

body.dark .charmy-modal-title {
    color: #fff;
}

.charmy-modal-msg {
    font-size: 0.95rem;
    color: var(--text-light);
    margin-bottom: 24px;
    line-height: 1.5;
}

body.dark .charmy-modal-msg {
    color: #aaa;
}

.charmy-modal-btns {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.charmy-modal-btns button {
    padding: 10px 24px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 100px;
    transition: transform 0.1s;
}

.charmy-modal-btns button:active {
    transform: scale(0.95);
}

/* --- TOAST NOTIFICATIONS --- */
.charmy-toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 10001;
    pointer-events: none;
}

.charmy-toast {
    background: #fff;
    border: 1px solid var(--border);
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    animation: toastIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: auto;
    min-width: 250px;
}

body.dark .charmy-toast {
    background: #171717;
    border-color: #333;
    color: #fff;
}

.charmy-toast.error {
    border-left: 4px solid #ef4444;
}

.charmy-toast.success {
    border-left: 4px solid #22c55e;
}

.charmy-toast.info {
    border-left: 4px solid #3b82f6;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

/* Restructured Nav */
.nav-left {
    display: flex;
    align-items: center;
    gap: 3rem;
}

/* --- RECOVERED MARKET STYLES --- */

/* Stat Cards */
.stat-container {
    display: flex;
    gap: 1rem;
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 3rem;
    flex-wrap: wrap;
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    flex: 1;
    min-width: 200px;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Market Tables */
.market-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 3rem 4rem;
}

.market-table-wrapper {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.market-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-input {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    flex: 1;
    max-width: 400px;
}

.btn-buy {
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-buy:hover {
    opacity: 0.9;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    background: var(--bg);
    color: var(--text-light);
    font-weight: 600;
    padding: 1rem 1.5rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

/* Global Button Pill */
.pill {
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
}

/* Modals */
.charmy-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    /* backdrop-filter: blur(4px); REMOVED */
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.charmy-modal-box {
    background: var(--white);
    padding: 2rem;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
    position: relative;
    animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.charmy-modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.charmy-modal-msg {
    color: var(--text-light);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.charmy-modal-btns {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

@keyframes modalPop {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* --- RECOVERED HEADER ELEMENTS (Theme & Notifs) --- */

/* Theme Switch - NEUTRAL AESTHETIC (Final Fix v2 - Widened) */
.theme-switch {
    width: 100px;
    /* Widened significantly to fit text comfortably */
    height: 32px;
    background: #e5e5e5;
    /* Neutral Light Grey */
    border-radius: 20px;
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 2px;
    transition: background 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.05);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body.dark .theme-switch {
    background: #27272a;
    /* Neutral Dark Grey (No Blue) */
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.05);
}

.switch-knob {
    width: 26px;
    height: 26px;
    background: #ffffff;
    border-radius: 50%;
    position: absolute;
    left: 3px;
    /* Default (Light Mode): Knob on Right */
    transform: translateX(68px);
    /* Adjusted for 100px width */
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.05);
    z-index: 2;
}

body.dark .switch-knob {
    /* Dark: Knob on Left */
    transform: translateX(0);
    background: #18181b;
    /* Zinc 900 */
    border: 1px solid #3f3f46;
    /* Zinc 700 */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    color: #fff;
}

/* Hide raw text inside switch */
.switch-text {
    position: absolute;
    font-size: 10px;
    font-weight: 700;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    transition: opacity 0.2s;
    letter-spacing: 0.5px;
}

.text-day {
    /* Day Text on Left */
    left: 12px;
    right: auto;
    color: #52525b;
    /* Neutral Grey */
    opacity: 1;
}

.text-night {
    /* Night Text on Right */
    right: 12px;
    left: auto;
    color: #a1a1aa;
    /* Light Neutral Grey */
    opacity: 0;
}

body.dark .text-day {
    opacity: 0;
}

body.dark .text-night {
    opacity: 1;
}

/* Icons within switch */
.switch-icon {
    width: 14px;
    height: 14px;
    stroke-width: 2;
    transition: all 0.3s ease;
    position: absolute;
    /* Stack them */
}

/* Default (Light Mode): Sun Visible */
.theme-switch .icon-sun {
    opacity: 1;
    transform: rotate(0deg);
}

.theme-switch .icon-moon {
    opacity: 0;
    transform: rotate(-90deg);
}

/* Dark Mode: Moon Visible */
body.dark .theme-switch .icon-sun {
    opacity: 0;
    transform: rotate(90deg);
}

body.dark .theme-switch .icon-moon {
    opacity: 1;
    transform: rotate(0deg);
}

/* Removed conflicting global icon styles */


/* Notifications */
.notifications-section {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    cursor: pointer;
    color: var(--text-light);
    border-radius: 50%;
    transition: background 0.2s;
}

.notifications-section:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-main);
}

body.dark .notifications-section:hover {
    background: rgba(255, 255, 255, 0.1);
}

.notif-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
    /* JS toggles this */
}

body.dark .notif-dot {
    border-color: #171717;
}

.notif-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 320px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    /* display: none !important; REMOVED */
    display: none;
    overflow: hidden;
    margin-top: 8px;
}

body.dark .notif-dropdown {
    background: #171717;
    border-color: #333;
}

.notif-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: 0.9rem;
    background: rgba(0, 0, 0, 0.02);
}

body.dark .notif-header {
    background: rgba(255, 255, 255, 0.02);
}


.notif-list {
    max-height: 300px;
    overflow-y: auto;
}

/* Language Switcher (Global Fix) */
.lang-container {
    position: relative;
    z-index: 1001;
}

.lang-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-main);
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    justify-content: center;
    height: 32px;
    user-select: none;
}

.lang-pill:hover {
    background: var(--border);
}

body.dark .lang-pill {
    background: #1e1e1e;
    border-color: #3f3f46;
}

body.dark .lang-pill:hover {
    background: #27272a;
}

.lang-dropdown {
    display: none;
    /* JS toggles strict display */
    position: absolute;
    top: 40px;
    right: 0;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    min-width: 140px;
    z-index: 1000;
    overflow: hidden;
    padding: 4px;
}

body.dark .lang-dropdown {
    background: #18181b;
    border-color: #3f3f46;
}

.lang-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.9rem;
    border-radius: 8px;
    transition: background 0.1s;
}

.lang-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

body.dark .lang-item:hover {
    background: rgba(255, 255, 255, 0.05);
}