* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    padding: 20px 30px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    position: relative;
    z-index: 1000;
}

h1 {
    color: #f0b90b;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.controls {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

/* Connection Status */
.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff4d4f;
    transition: background 0.3s ease;
    box-shadow: 0 0 8px rgba(255, 77, 79, 0.5);
}

.status-dot.connected {
    background: #52c41a;
    box-shadow: 0 0 8px rgba(82, 196, 26, 0.5);
}

.status-dot.connecting {
    background: #f0b90b;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
    100% {
        opacity: 1;
    }
}

.status-text {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

.form-control {
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    font-size: 14px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
}

.form-control:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.form-control option {
    background: #1a1a2e;
    color: #fff;
}

.btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, #f0b90b 0%, #e0a90a 100%);
    color: #1a1a2e;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(240, 185, 11, 0.3);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(240, 185, 11, 0.4);
}

.btn:active {
    transform: translateY(0);
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
    margin-left: 10px;
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    margin-right: 10px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    flex-wrap: wrap;
}

/* 用户菜单样式 */
.user-menu {
    position: relative;
    display: inline-block;
}

.menu-btn {
    padding: 10px 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.gear-icon {
    font-size: 16px;
    line-height: 1;
    display: inline-block;
    vertical-align: middle;
}

/* 下拉菜单样式 */
.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 5px;
    background: rgba(26, 26, 46, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    min-width: 120px;
    overflow: hidden;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 15px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s ease;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.dropdown-item:active {
    background: rgba(255, 255, 255, 0.2);
}

@media (max-width: 768px) {
    .user-info {
        justify-content: space-between;
        width: 100%;
    }
    
    .dropdown-menu {
        right: auto;
        left: 0;
        min-width: 100%;
    }
}

/* 弹窗样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: #1a1a2e;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.modal-header h3 {
    margin: 0;
    color: #f0b90b;
    font-size: 18px;
    font-weight: 600;
}

.close-btn {
    color: rgba(255,255,255,0.6);
    float: right;
    font-size: 28px;
    font-weight: bold;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.close-btn:hover,
.close-btn:focus {
    color: #fff;
    text-decoration: none;
    cursor: pointer;
}

.modal-body {
    padding: 10px 0;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: rgba(255,255,255,0.8);
    font-size: 14px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    color: #fff;
    font-size: 14px;
    transition: all 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #f0b90b;
    background: rgba(255,255,255,0.15);
}

.error-message {
    background: rgba(255,77,79,0.1);
    border: 1px solid rgba(255,77,79,0.3);
    border-radius: 6px;
    padding: 8px 12px;
    color: #ff4d4f;
    font-size: 13px;
    margin-top: 5px;
    display: none;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
    gap: 10px;
}

@media (max-width: 768px) {
    .user-info {
        justify-content: space-between;
        width: 100%;
    }
    
    .modal-content {
        margin: 20% auto;
        width: 95%;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .btn-secondary {
        margin-right: 0;
        margin-bottom: 10px;
    }
}

/* Main Content */
main {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Cards */
.ticker-section {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    padding: 24px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.ticker-section:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

h2 {
    font-size: 20px;
    margin-bottom: 20px;
    color: #fff;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

h2::before {
    content: '';
    width: 4px;
    height: 20px;
    background: linear-gradient(135deg, #f0b90b 0%, #e0a90a 100%);
    border-radius: 2px;
}

/* Ticker Card */
.ticker-card {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Trading Card */
.trading-card {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.trading-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.trading-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.trading-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(240, 185, 11, 0.3);
}

.trading-item h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 16px;
    color: #f0b90b;
    font-weight: 600;
}

.trading-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 500;
}

.form-group .form-control {
    width: 100%;
}

.trading-item .btn {
    margin-top: 8px;
    width: 100%;
}

.ticker-row {
    display: grid;
    gap: 20px;
}

.ticker-row-2col {
    grid-template-columns: repeat(2, 1fr);
}

.ticker-row-3col {
    grid-template-columns: repeat(3, 1fr);
}

.ticker-row-4col {
    grid-template-columns: repeat(4, 1fr);
}

.ticker-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    min-width: 0;
}

.ticker-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(240, 185, 11, 0.3);
}

.ticker-item .label {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ticker-item .value {
    font-size: 28px;
    font-weight: 700;
    color: #f0b90b;
    font-family: 'Courier New', monospace;
}

/* Charts and Depth Wrapper */
.charts-depth-wrapper {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

/* Charts Section - 占三分之二宽度 */
.charts-section {
    flex: 2;
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-width: 600px; /* 设置最小宽度，防止过度挤压 */
}

.chart-section {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    padding: 24px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.chart-section:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 400px;
    width: 100%;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    padding: 10px;
    overflow: hidden;
}

/* ECharts Chart */
.echarts-chart {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    overflow: hidden;
}

/* Loading State */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: rgba(255, 255, 255, 0.5);
}

.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: #f0b90b;
    border-radius: 50%;
    margin-left: 10px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Depth Section - 占三分之一宽度，高度等于两个图表加间隔 */
.depth-section {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    padding: 24px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 1016px; /* = 两个chart-section高度(496*2) + gap(24)，减去h2的额外高度 */
    box-sizing: border-box;
}

.depth-section:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.depth-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    height: 40px; /* 固定高度 */
    flex-shrink: 0;
}

.depth-header h2 {
    margin-bottom: 0;
}

/* 固定精度选择框大小 */
#depth-precision {
    width: 80px;
    min-width: 80px;
    max-width: 80px;
    height: 36px;
    padding: 8px 12px;
    font-size: 14px;
    box-sizing: border-box;
}

.depth-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
    min-height: 0;
}

.depth-side {
    flex: 1;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.depth-side h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 16px;
    color: #fff;
    font-weight: 600;
}

.depth-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.depth-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 14px;
    font-family: 'Courier New', monospace;
}

.depth-item:last-child {
    border-bottom: none;
}

.depth-price {
    font-weight: 500;
}

.depth-amount {
    color: rgba(255, 255, 255, 0.6);
}

#asks-container .depth-price {
    color: #ff4d4f;
}

#bids-container .depth-price {
    color: #52c41a;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-thumb {
    background: rgba(240, 185, 11, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(240, 185, 11, 0.5);
}

/* Price Up/Down */
.price-up {
    color: #52c41a !important;
    font-weight: 600;
}

.price-down {
    color: #ff4d4f !important;
    font-weight: 600;
}

/* Positions */
.positions-list {
    min-height: 100px;
}

.no-positions {
    text-align: center;
    padding: 40px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 16px;
}

.positions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.position-item {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.position-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.position-item.long {
    border-left: 4px solid #52c41a;
}

.position-item.short {
    border-left: 4px solid #ff4d4f;
}

.position-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.position-symbol {
    font-size: 18px;
    font-weight: 700;
    color: #f0b90b;
}

.position-side {
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.position-side.long {
    background: rgba(82, 196, 26, 0.2);
    color: #52c41a;
}

.position-side.short {
    background: rgba(255, 77, 79, 0.2);
    color: #ff4d4f;
}

.position-leverage {
    margin-left: auto;
    padding: 4px 10px;
    background: rgba(240, 185, 11, 0.2);
    color: #f0b90b;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.position-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.position-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.position-row .label {
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
}

.position-row .value {
    font-size: 14px;
    font-weight: 500;
}

.position-row .value.positive {
    color: #52c41a;
}

.position-row .value.negative {
    color: #ff4d4f;
}

/* Responsive */
@media (max-width: 1200px) {
    .charts-depth-wrapper {
        flex-direction: column;
    }

    .charts-section {
        flex: none;
        width: 100%;
        min-width: auto; /* 取消最小宽度限制 */
    }
    
    .depth-section {
        flex: none;
        width: 100%;
        height: auto; /* 高度自适应 */
        min-height: 600px;
    }

    .depth-container {
        flex-direction: row;
    }

    .depth-side {
        min-height: 200px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    header {
        padding: 15px 20px;
    }

    h1 {
        font-size: 22px;
    }

    .controls {
        width: 100%;
        flex-wrap: wrap;
    }

    .form-control,
    .btn {
        flex: 1;
        min-width: 100px;
    }

    .ticker-row {
        grid-template-columns: 1fr;
    }
    
    .trading-row {
        grid-template-columns: 1fr;
    }

    .ticker-item .value {
        font-size: 24px;
    }

    .chart-container {
        height: 300px;
    }

    .ticker-section,
    .chart-section,
    .depth-section {
        padding: 18px;
    }

    .depth-container {
        flex-direction: column;
    }

    .depth-side {
        min-height: 150px;
    }
}
