/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #0b0e11;
    color: #b8bcc8;
    overflow-x: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Variables */
:root {
    /* PerpsPlex Theme Colors */
    --bg-primary: #0b0e11;
    --bg-secondary: #161a1e;
    --bg-tertiary: #1c2127;
    --border-color: #2a2d35;
    --text-primary: #f0f4f8;
    --text-secondary: #b8bcc8;
    --text-muted: #6e7681;
    --green: #00d395;
    --red: #ff3b69;
    --yellow: #ffc107;
    --blue: #2196f3;
    
    /* PerpsPlex Brand Identity */
    --perpsplex-primary: #8b5cf6;
    --perpsplex-secondary: #a78bfa;
    --perpsplex-gradient: linear-gradient(135deg, #8b5cf6, #00d395);
    --lp-purple: #8b5cf6;
    --lp-gradient: linear-gradient(135deg, #8b5cf6, #00d395);
}

/* Mobile Responsive Styles */
@media (max-width: 1200px) {
    .main-container {
        grid-template-columns: 1fr 320px;
    }
    
    .right-panel {
        width: 320px;
    }
}

@media (max-width: 768px) {
    /* Mobile Layout - Single Column */
    body {
        overflow-x: hidden;
        overflow-y: auto;
        margin: 0;
        padding: 0;
    }
    
    .header {
        padding: 8px 12px;
        height: 50px;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1001;
        background: var(--bg-primary);
    }
    
    .logo {
        font-size: 18px;
    }
    
    .nav-menu {
        display: none;
    }
    
    .header-actions {
        gap: 8px;
    }
    
    .wallet-btn {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    .main-container {
        display: block !important;
        height: auto;
        margin-top: 50px; /* Account for fixed header */
        padding: 0;
        grid-template-columns: none !important;
        grid-template-rows: none !important;
        gap: 0;
    }
    
    /* 1. Mobile Chart - First View (80vh) */
    .left-panel {
        display: block !important;
        width: 100%;
        height: 80vh !important;
        min-height: 400px;
        max-height: 80vh;
        border: none;
        border-bottom: 2px solid var(--border-color);
        position: relative;
        margin: 0;
        padding: 0;
    }
    
    .chart-header {
        padding: 8px 12px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        background: var(--bg-secondary);
    }
    
    .market-selector {
        font-size: 14px;
        padding: 6px 10px;
    }
    
    .chart-controls {
        display: none;
    }
    
    .chart-container {
        height: calc(100% - 40px) !important;
        width: 100% !important;
        display: block !important;
        position: relative;
    }
    
    /* Ensure TradingView widget is visible */
    .tradingview-widget-container,
    #tradingview_chart {
        width: 100% !important;
        height: 100% !important;
        display: block !important;
        position: relative !important;
    }
    
    #tradingview_chart iframe {
        width: 100% !important;
        height: 100% !important;
    }
    
    /* 2. Mobile Order Book - Second */
    .side-panels {
        display: block !important;
        width: 100%;
        position: relative !important;
        margin: 0;
        padding: 0;
    }
    
    .middle-section {
        display: block !important;
        width: 100%;
        height: auto;
        position: relative !important;
        border-bottom: 2px solid var(--border-color);
        margin: 0;
    }
    
    .orderbook {
        width: 100%;
        height: auto;
        padding: 12px;
        background: var(--bg-primary);
    }
    
    .orderbook-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 12px;
    }
    
    .orderbook-header span {
        font-size: 14px;
        font-weight: 600;
    }
    
    /* Order Book Tabs for Buy/Sell */
    .order-book-tabs {
        display: flex !important;
        gap: 4px;
        margin: 12px 0;
        padding: 0;
        border-bottom: 1px solid var(--border-color);
    }
    
    .order-book-tab {
        flex: 1;
        padding: 8px;
        background: transparent;
        border: none;
        color: var(--text-secondary);
        cursor: pointer;
        border-bottom: 2px solid transparent;
        transition: all 0.2s;
        font-size: 12px;
        font-weight: 500;
    }
    
    .order-book-tab.active {
        color: var(--text-primary);
        border-bottom-color: var(--lp-purple);
    }
    
    .order-book-tab.buy.active {
        color: var(--green);
        border-bottom-color: var(--green);
    }
    
    .order-book-tab.sell.active {
        color: var(--red);
        border-bottom-color: var(--red);
    }
    
    .order-book-tab.both.active {
        color: var(--lp-purple);
        border-bottom-color: var(--lp-purple);
    }
    
    .orderbook-content {
        max-height: 350px;
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .orderbook-head,
    .orderbook-row {
        padding: 6px 0;
        font-size: 11px;
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
    }
    
    /* Recent trades on mobile - hide to save space */
    .recent-trades {
        display: none !important;
    }
    
    /* 3. Mobile Order Panel - Third */
    .right-panel {
        display: block !important;
        width: 100%;
        height: auto;
        position: relative !important;
        border: none;
        border-bottom: 2px solid var(--border-color);
        margin: 0;
        background: var(--bg-primary);
    }
    
    .order-panel {
        padding: 16px;
    }
    
    .order-type-tabs {
        display: flex;
        gap: 4px;
        margin-bottom: 16px;
    }
    
    .order-type-tabs button {
        flex: 1;
        padding: 10px;
        font-size: 12px;
    }
    
    .leverage-section {
        padding: 12px;
        margin: 16px 0;
        background: var(--bg-secondary);
        border-radius: 8px;
    }
    
    .leverage-display {
        font-size: 18px;
        font-weight: 600;
    }
    
    .input-group {
        margin-bottom: 16px;
    }
    
    .input-group label {
        font-size: 12px;
        margin-bottom: 6px;
        display: block;
    }
    
    .input-group input {
        padding: 12px;
        font-size: 14px;
        width: 100%;
    }
    
    .order-actions {
        display: flex;
        gap: 10px;
        margin-top: 20px;
    }
    
    .order-btn {
        flex: 1;
        padding: 14px;
        font-size: 15px;
        font-weight: 600;
        border-radius: 8px;
    }
    
    /* Dark Pool Toggle */
    .dark-pool-toggle {
        margin: 16px 0;
    }
    
    /* 4. Mobile Positions - Fourth */
    .positions-section {
        display: block !important;
        width: 100%;
        height: auto;
        min-height: 400px;
        position: relative !important;
        margin: 0;
        padding: 0;
        border: none;
        background: var(--bg-primary);
    }
    
    .section-tabs {
        overflow-x: auto;
        white-space: nowrap;
        padding: 0 12px;
        scrollbar-width: none;
        position: sticky;
        top: 50px;
        background: var(--bg-primary);
        z-index: 100;
        border-bottom: 1px solid var(--border-color);
    }
    
    .section-tabs::-webkit-scrollbar {
        display: none;
    }
    
    .tab-btn {
        font-size: 11px;
        padding: 10px 12px;
    }
    
    .table-container {
        height: auto;
        min-height: 250px;
        max-height: 400px;
        overflow-x: auto;
        overflow-y: auto;
    }
    
    .data-table {
        min-width: 800px;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px 6px;
        font-size: 11px;
    }
    
    /* Remove mobile bottom nav - everything in single scroll */
    .mobile-bottom-nav {
        display: none !important;
    }
    
    /* Fix overlapping issues */
    .main-container > * {
        position: relative !important;
        z-index: 1;
        margin: 0;
    }
    
    /* Remove any absolute positioning that causes overlap */
    .left-panel,
    .side-panels,
    .right-panel,
    .positions-section {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
    }
    
    /* Mobile-specific info banner */
    .lp-info-banner {
        padding: 8px;
        font-size: 11px;
    }
    
    /* Compact market info */
    .market-info {
        flex-wrap: wrap;
        gap: 8px;
        padding: 8px 12px;
    }
    
    .info-item {
        font-size: 10px;
    }
    
    /* Hide desktop grid system on mobile */
    .main-container {
        grid-template-columns: none !important;
        display: block !important;
    }
    
    /* Ensure visibility of main sections */
    .left-panel,
    .middle-section,
    .right-panel,
    .positions-section {
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    /* Fix any flexbox issues */
    .side-panels {
        flex-direction: column !important;
        align-items: stretch !important;
    }
}

@media (max-width: 480px) {
    /* Extra Small Screens */
    .header {
        padding: 8px;
    }
    
    .logo {
        font-size: 16px;
    }
    
    .logo span {
        display: none; /* Hide "Perps DEX" text, keep only icon */
    }
    
    .wallet-btn span {
        display: none; /* Show only address */
    }
    
    .left-panel {
        height: 35vh;
        min-height: 250px;
    }
    
    .market-info {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .info-item {
        font-size: 10px;
    }
    
    .order-panel {
        padding: 10px;
    }
    
    .input-group label {
        font-size: 10px;
    }
    
    .positions-section {
        min-height: 150px;
    }
    
    .tab-btn {
        font-size: 10px;
        padding: 6px 10px;
    }
    
    .data-table {
        font-size: 10px;
    }
    
    .action-btn {
        padding: 3px 6px;
        font-size: 9px;
    }
}

/* Landscape Mode Adjustments */
@media (max-height: 600px) and (orientation: landscape) {
    .left-panel {
        height: 50vh;
    }
    
    .positions-section {
        max-height: 200px;
    }
    
    .mobile-bottom-nav {
        height: 48px;
    }
    
    .mobile-nav-item {
        padding: 6px;
    }
    
    .mobile-nav-item i {
        font-size: 16px;
    }
}

/* Tablet Portrait */
@media (min-width: 769px) and (max-width: 1024px) {
    .main-container {
        grid-template-columns: 1fr 350px;
    }
    
    .right-panel {
        width: 350px;
    }
    
    .positions-section {
        height: 300px;
    }
}

/* Hide mobile-only elements on desktop */
@media (min-width: 769px) {
    .mobile-bottom-nav {
        display: none;
    }
    
    .mobile-view-toggle {
        display: none;
    }
    
    .mobile-only {
        display: none !important;
    }
    
    .desktop-only {
        display: flex;
    }
}

/* Hide desktop-only elements on mobile */
@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
    
    .mobile-only {
        display: flex;
    }
}

/* Touch-friendly adjustments */
@media (hover: none) and (pointer: coarse) {
    .tab-btn:hover,
    .order-btn:hover,
    .action-btn:hover {
        transform: none;
    }
    
    .order-book-row:hover {
        background: transparent;
    }
    
    /* Larger touch targets */
    .tab-btn,
    .order-btn,
    .action-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    input, select, button {
        min-height: 44px;
    }
    
    .leverage-slider {
        height: 8px;
    }
    
    .leverage-slider::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }
}

/* Animations */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes flashGreen {
    0% { background: transparent; }
    50% { background: rgba(0, 211, 149, 0.2); }
    100% { background: transparent; }
}

@keyframes flashRed {
    0% { background: transparent; }
    50% { background: rgba(255, 59, 105, 0.2); }
    100% { background: transparent; }
}

@keyframes orderFlash {
    0% { background: transparent; }
    50% { background: rgba(255, 255, 255, 0.05); }
    100% { background: transparent; }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes orderSlideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes lpGlow {
    0% { box-shadow: 0 0 5px rgba(153, 69, 255, 0.5); }
    50% { box-shadow: 0 0 20px rgba(153, 69, 255, 0.8); }
    100% { box-shadow: 0 0 5px rgba(153, 69, 255, 0.5); }
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    height: 48px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 30px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 18px;
}

.logo-icon {
    background: var(--lp-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: lpGlow 3s infinite;
}

.logo-badge {
    font-size: 10px;
    background: var(--lp-purple);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 8px;
    font-weight: 500;
    animation: pulse 2s infinite;
}

.main-nav {
    display: flex;
    gap: 24px;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s;
}

.nav-link:hover,
.nav-link.active {
    color: var(--text-primary);
}

.nav-link i {
    font-size: 10px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.deposit-btn {
    background: var(--yellow);
    color: #000;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}

.theme-toggle,
.menu-toggle {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 20px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
}

/* Sub Header */
.sub-header {
    display: flex;
    align-items: center;
    padding: 8px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    gap: 20px;
    position: relative;
}

.market-selector-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 6px;
    transition: background 0.2s;
}

.market-selector-btn:hover {
    background: var(--bg-tertiary);
}

.market-stats {
    display: flex;
    flex: 1;
    gap: 24px;
    overflow-x: auto;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

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

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

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
}

.countdown {
    font-size: 11px;
    color: var(--yellow);
    margin-left: 4px;
}

.settings-btn {
    background: var(--yellow);
    color: #000;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Trading Container */
.trading-container {
    display: flex;
    height: calc(100vh - 96px); /* Full height minus headers */
    overflow: hidden;
}

/* Main Content Wrapper - Scrollable */
.main-content-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Left Section - Chart */
.left-section {
    display: flex;
    flex-direction: column;
    min-height: 120vh; /* Extend beyond viewport to push positions below fold */
}

/* Side Panels Container */
.side-panels {
    display: flex;
    position: sticky;
    top: 0;
    height: calc(100vh - 96px);
}

.chart-tabs {
    display: flex;
    padding: 0 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.tab {
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--text-secondary);
}

.tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--green);
}

.chart-wrapper {
    height: calc(100vh - 140px); /* Take up almost all viewport height */
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

.timeframe-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.timeframe-group {
    display: flex;
    gap: 4px;
}

.tf-btn {
    padding: 6px 10px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.tf-btn:hover {
    color: var(--text-secondary);
    background: var(--bg-tertiary);
}

.tf-btn.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.chart-tools {
    display: flex;
    gap: 8px;
}

.tool-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
}

.chart-container {
    flex: 1;
    position: relative;
    background: var(--bg-primary);
}

.chart-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.bottom-section {
    min-height: 300px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: relative;
}

.bottom-tabs {
    display: flex;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-color);
}

.bottom-tab {
    padding: 6px 12px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.bottom-tab.active {
    color: var(--text-primary);
}

.bottom-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* Middle Section - Order Book */
.middle-section {
    width: 320px;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
}

.orderbook {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.orderbook-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.orderbook-header span {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.orderbook-controls {
    display: flex;
    gap: 4px;
}

.ob-btn {
    padding: 4px 8px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    border-radius: 3px;
}

.ob-btn.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.orderbook-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.orderbook-head {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    padding: 8px 12px;
    font-size: 11px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

.orderbook-head span {
    text-align: right;
}

.orderbook-head span:first-child {
    text-align: left;
}

.order-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    padding: 4px 12px;
    font-size: 12px;
    position: relative;
    font-family: 'JetBrains Mono', monospace;
}

.order-row span {
    text-align: right;
}

.order-row span:first-child {
    text-align: left;
}

.order-row.sell .price {
    color: var(--red);
}

.order-row.buy .price {
    color: var(--green);
}

.order-row::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    background: currentColor;
    opacity: 0.1;
}

.order-row.sell::before {
    background: var(--red);
    width: var(--depth, 0%);
}

.order-row.buy::before {
    background: var(--green);
    width: var(--depth, 0%);
}

.orderbook-spread {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.current-price {
    font-size: 14px;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

.current-price.up {
    color: var(--green);
}

.current-price.down {
    color: var(--red);
}

.spread-value {
    font-size: 12px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.recent-trades {
    height: 200px;
    border-top: 1px solid var(--border-color);
}

.trades-header {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.trades-head {
    display: grid;
    grid-template-columns: 1fr 1fr 0.8fr;
    padding: 8px 12px;
    font-size: 11px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

.trades-list {
    overflow-y: auto;
    max-height: 120px;
}

.trade-row {
    display: grid;
    grid-template-columns: 1fr 1fr 0.8fr;
    padding: 4px 12px;
    font-size: 12px;
    font-family: 'JetBrains Mono', monospace;
}

.trade-row .price.up {
    color: var(--green);
}

.trade-row .price.down {
    color: var(--red);
}

.trade-row .time {
    color: var(--text-muted);
}

/* Right Section - Order Entry */
.right-section {
    width: 320px;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    overflow-y: auto;
}

.order-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px;
}

.order-type-selector {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.order-type {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.available {
    font-size: 12px;
    color: var(--text-muted);
}

.buysell-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    margin-bottom: 16px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.buy-btn,
.sell-btn {
    padding: 10px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.buy-btn.active {
    background: var(--green);
    color: white;
}

.sell-btn.active {
    background: var(--red);
    color: white;
}

.order-form-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.form-tab {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.form-tab:hover {
    color: var(--text-secondary);
}

.form-tab.active {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

.order-form {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding-right: 12px;
}

.input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: 'JetBrains Mono', monospace;
    outline: none;
}

.unit {
    color: var(--text-muted);
    font-size: 13px;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
}

.checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--green);
}

.place-order-btn {
    width: 100%;
    padding: 12px;
    background: var(--green);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.place-order-btn:hover {
    opacity: 0.9;
}

.order-info {
    margin-top: 16px;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: 6px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 12px;
}

.info-row:last-child {
    margin-bottom: 0;
}

.info-row span:first-child {
    color: var(--text-muted);
}

.info-row span:last-child {
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
}

.perpetual-section {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.perpetual-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.perpetual-header span {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.perpetual-header i {
    color: var(--text-muted);
    cursor: pointer;
}

.perpetual-balance {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.balance-amount {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

.balance-unit {
    font-size: 14px;
    color: var(--text-muted);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Markets Dropdown */
.markets-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 20px;
    width: 600px;
    max-height: 500px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    z-index: 1000;
    display: none;
    overflow: hidden;
}

.markets-dropdown.active {
    display: block;
}

.dropdown-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.market-search-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    margin-bottom: 12px;
}

.market-categories {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.cat-btn {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.cat-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.cat-btn.active {
    background: var(--green);
    color: white;
    border-color: var(--green);
}

.cat-btn.dark-pool-filter {
    background: #1a1a2e;
    border-color: #6a5acd;
    color: #b19cd9;
}

.market-list-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr;
    padding: 12px 16px;
    font-size: 11px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    font-weight: 500;
}

.market-list-items {
    max-height: 350px;
    overflow-y: auto;
}

.market-item {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr;
    padding: 12px 16px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
    align-items: center;
}

.market-item:hover {
    background: var(--bg-tertiary);
}

.market-item.active {
    background: var(--bg-tertiary);
    border-left: 3px solid var(--green);
}

.pair-name {
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
}

.badge.v2 {
    background: var(--green);
    color: white;
}

.badge.v3 {
    background: var(--blue);
    color: white;
}

.badge.stable {
    background: var(--yellow);
    color: black;
}

.badge.dark-pool {
    background: #1a1a2e;
    color: #b19cd9;
}

/* Margin Type Toggle */
.margin-type-toggle {
    display: flex;
    gap: 0;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.margin-btn {
    padding: 6px 12px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.margin-btn.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Quantity Presets */
.qty-presets {
    display: flex;
    gap: 4px;
    margin-top: 8px;
}

.preset-btn {
    flex: 1;
    padding: 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 11px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* Leverage Slider */
.leverage-group {
    margin: 20px 0;
}

.leverage-group label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

.leverage-value {
    color: var(--yellow);
    font-weight: 600;
    font-size: 14px;
}

.leverage-slider-container {
    position: relative;
    margin-bottom: 8px;
}

.leverage-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, 
        var(--green) 0%, 
        var(--yellow) 50%, 
        var(--red) 100%);
    border-radius: 3px;
    outline: none;
}

.leverage-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: white;
    border: 2px solid var(--yellow);
    border-radius: 50%;
    cursor: pointer;
}

.leverage-marks {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
}

.leverage-input-group {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 12px;
}

.leverage-input {
    width: 80px;
    padding: 6px 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 13px;
    text-align: center;
}

.leverage-suffix {
    color: var(--text-muted);
    font-size: 13px;
}

/* Dark Pool Options */
.dark-pool-options {
    padding: 12px;
    background: #1a1a2e;
    border-radius: 6px;
    margin: 12px 0;
    border: 1px solid #6a5acd;
}

.dark-pool-tab {
    background: #1a1a2e !important;
    border-color: #6a5acd !important;
    color: #b19cd9 !important;
}

.time-window-select {
    width: 100%;
    padding: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 13px;
}

/* TP/SL Inputs */
.tpsl-inputs {
    padding: 12px;
    background: var(--bg-primary);
    border-radius: 6px;
    margin: 12px 0;
}

/* Tables */
.table-container {
    display: none;
    overflow-x: auto;
    overflow-y: auto;
    height: calc(100% - 80px);
}

.table-container.active {
    display: block;
}

/* Ensure table has minimum width for proper display */
.data-table {
    min-width: 1200px;
}

/* Table Controls */
.table-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.control-btn {
    padding: 8px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.control-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--lp-purple);
}

.control-btn i {
    font-size: 14px;
}

.total-pnl {
    margin-left: auto;
    font-size: 14px;
    color: var(--text-secondary);
}

.pnl-value {
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    margin-left: 8px;
}

.pnl-value.positive {
    color: var(--green);
}

.pnl-value.negative {
    color: var(--red);
}

.data-table {
    width: 100%;
    font-size: 12px;
    border-collapse: collapse;
    table-layout: auto;
}

.data-table thead {
    background: var(--bg-tertiary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table th {
    padding: 10px;
    text-align: left;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table th:nth-child(1) { width: 12%; } /* LP Market */
.data-table th:nth-child(2) { width: 10%; } /* Side */
.data-table th:nth-child(3) { width: 8%; }  /* Qty */
.data-table th:nth-child(4) { width: 10%; } /* Value */
.data-table th:nth-child(5) { width: 9%; }  /* Entry NAV */
.data-table th:nth-child(6) { width: 9%; }  /* Mark NAV */
.data-table th:nth-child(7) { width: 9%; }  /* Liq NAV */
.data-table th:nth-child(8) { width: 11%; } /* P&L */
.data-table th:nth-child(9) { width: 7%; }  /* IL Impact */
.data-table th:nth-child(10) { width: 7%; } /* LP Points */
.data-table th:nth-child(11) { width: 8%; } /* Actions */

.data-table td {
    padding: 10px;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(42, 45, 53, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.no-data td {
    text-align: center;
    color: var(--text-muted);
    padding: 40px;
}

.tab-count {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    margin-left: 4px;
}

.dark-pool-count {
    background: #6a5acd;
    color: white;
}

.dark-pool-notice {
    padding: 12px;
    background: #1a1a2e;
    border: 1px solid #6a5acd;
    border-radius: 6px;
    margin: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #b19cd9;
    font-size: 12px;
}

.status-badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.status-badge.active {
    background: var(--green);
    color: white;
}

.cancel-btn {
    padding: 4px 12px;
    background: transparent;
    border: 1px solid var(--red);
    color: var(--red);
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.cancel-btn:hover {
    background: var(--red);
    color: white;
}

/* Position Table Styles */
.position-row {
    transition: all 0.2s;
}

.position-row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.position-row.long {
    border-left: 3px solid var(--green);
}

.position-row.short {
    border-left: 3px solid var(--red);
}

.lp-market-info {
    display: flex;
    align-items: center;
    gap: 6px;
}

.lp-pair {
    font-weight: 600;
    color: var(--text-primary);
}

.pool-type {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
}

.pool-type.v2 {
    background: var(--green);
    color: white;
}

.pool-type.v3 {
    background: var(--blue);
    color: white;
}

.pool-type.stable {
    background: var(--yellow);
    color: black;
}

.side-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    display: inline-block;
    min-width: 80px;
    text-align: center;
}

.side-badge.long {
    background: rgba(0, 211, 149, 0.2);
    color: var(--green);
    border: 1px solid var(--green);
}

.side-badge.short {
    background: rgba(255, 59, 105, 0.2);
    color: var(--red);
    border: 1px solid var(--red);
}

.liq-price {
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

.liq-price.safe {
    color: var(--green);
}

.liq-price.warning {
    color: var(--yellow);
}

.liq-price.danger {
    color: var(--red);
    animation: pulse 2s infinite;
}

.pnl {
    display: flex;
    flex-direction: column;
    gap: 2px;
    white-space: normal !important;
}

.pnl.positive {
    color: var(--green);
}

.pnl.negative {
    color: var(--red);
}

.pnl-percent {
    font-size: 10px;
    opacity: 0.8;
    white-space: nowrap;
}

/* Allow P&L column to wrap */
.data-table td:nth-child(8) {
    white-space: normal;
}

.il-impact {
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

.il-impact.low {
    color: var(--green);
}

.il-impact.medium {
    color: var(--yellow);
}

.il-impact.high {
    color: var(--red);
}

.lp-points {
    font-weight: 600;
    color: var(--lp-purple);
    font-family: 'JetBrains Mono', monospace;
}

.position-actions {
    display: flex;
    gap: 4px;
    white-space: nowrap;
}

.action-btn {
    padding: 4px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

/* Allow actions column to not wrap */
.data-table td:nth-child(11) {
    white-space: nowrap;
}

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

.action-btn.adjust {
    border-color: var(--blue);
    color: var(--blue);
}

.action-btn.close {
    border-color: var(--yellow);
    color: var(--yellow);
}

.action-btn.urgent {
    background: var(--red);
    color: white;
    border-color: var(--red);
    animation: pulse 1s infinite;
}

.action-btn.tp-sl {
    border-color: var(--lp-purple);
    color: var(--lp-purple);
}

.action-btn.cancel {
    border-color: var(--red);
    color: var(--red);
}

.action-btn.modify {
    border-color: var(--blue);
    color: var(--blue);
}

/* Status Badges */
.status-badge.partial {
    background: var(--yellow);
    color: black;
}

/* Dark Pool Indicator */
.dark-indicator {
    font-size: 14px;
    animation: lpGlow 3s infinite;
}

/* LP Token Specific Styles */
.lp-info-banner {
    padding: 8px 12px;
    background: linear-gradient(90deg, rgba(153, 69, 255, 0.1), rgba(0, 211, 149, 0.1));
    border-left: 3px solid var(--lp-purple);
    margin: 8px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-secondary);
    animation: slideIn 0.5s;
}

.lp-info-banner i {
    color: var(--lp-purple);
}

.lp-trading-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: linear-gradient(135deg, rgba(153, 69, 255, 0.05), rgba(0, 211, 149, 0.05));
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 12px;
}

.lp-icon-container {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--lp-gradient);
    border-radius: 8px;
    animation: lpGlow 3s infinite;
}

.lp-icon-container i {
    color: white;
    font-size: 20px;
}

.lp-trading-info {
    display: flex;
    flex-direction: column;
}

.lp-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.lp-subtitle {
    font-size: 11px;
    color: var(--text-muted);
}

.lp-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.lp-badge {
    background: var(--lp-purple);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
}

.lp-text {
    font-size: 11px;
    color: var(--text-muted);
}

/* Order Row Animations */
.order-row {
    transition: all 0.2s ease;
}

.order-row.sell::before {
    transition: width 0.3s ease;
}

.order-row.buy::before {
    transition: width 0.3s ease;
}

/* Trade Row Animation */
.trade-row {
    transition: all 0.2s ease;
}

/* Real-time Price Animation */
.stat-value {
    transition: color 0.3s ease;
}

.current-price {
    transition: all 0.2s ease;
    font-weight: 600;
}

/* Liquidity Info Section */
.liquidity-info {
    margin-top: 16px;
    padding: 12px;
    background: linear-gradient(135deg, rgba(153, 69, 255, 0.05), rgba(0, 211, 149, 0.05));
    border: 1px solid var(--border-color);
    border-radius: 8px;
    animation: slideIn 0.3s;
}

.liquidity-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.liquidity-header span {
    font-size: 12px;
    font-weight: 600;
    color: var(--lp-purple);
}

.liquidity-header i {
    color: var(--lp-purple);
}

.points-value {
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

.yield-value {
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

.il-risk-value {
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

.depth-value {
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

/* Risk Indicator */
.risk-indicator {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.risk-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.risk-fill {
    height: 100%;
    width: 0%;
    transition: width 0.3s ease, background 0.3s ease;
    border-radius: 4px;
}

.risk-label {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
}

.risk-label span:first-child {
    color: var(--text-muted);
}

.risk-text {
    font-weight: 600;
    transition: color 0.3s ease;
}

/* Responsive */
@media (max-width: 1200px) {
    .middle-section {
        width: 280px;
    }
    
    .right-section {
        width: 280px;
    }
    
    .markets-dropdown {
        width: 500px;
    }
}

@media (max-width: 768px) {
    .main-nav {
        display: none;
    }
    
    .market-stats {
        display: none;
    }
    
    .middle-section {
        display: none;
    }
    
    .markets-dropdown {
        width: calc(100vw - 40px);
    }
}