* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0d0e11;
    --bg-secondary: #191a20;
    --bg-card: #12131a;
    --text-primary: #ffffff;
    --text-secondary: #98a1b2;
    --text-tertiary: #5e6573;
    --accent: #c8a951;
    --accent-hover: #b8993f;
    --green: #00ff88;
    --red: #ff4d4d;
    --border: rgba(200, 169, 81, 0.12);
    --border-hover: rgba(200, 169, 81, 0.3);
}

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 56px;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 18px;
}

.logo img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.nav {
    display: flex;
    gap: 8px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 12px;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-primary);
}

.nav-link.active {
    color: var(--text-primary);
    background: rgba(200, 169, 81, 0.1);
}

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

.launch-app-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    border: none;
    border-radius: 20px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.launch-app-btn:hover {
    box-shadow: 0 0 20px rgba(200, 169, 81, 0.4);
}

/* Main Content */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    flex: 1;
    width: 100%;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: rgba(0, 255, 136, 0.15);
    border: 1px solid rgba(0, 255, 136, 0.3);
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    color: #00ff88;
    letter-spacing: 0.5px;
    animation: livePulse 2s ease-in-out infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 280px;
}

.search-bar svg {
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.search-bar input {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    width: 100%;
}

.search-bar input::placeholder {
    color: var(--text-tertiary);
}

.search-bar:focus-within {
    border-color: var(--accent);
}

/* Stats Row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
}

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

.stat-value {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Table */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.token-table {
    width: 100%;
    border-collapse: collapse;
}

.token-table thead {
    background: var(--bg-secondary);
}

.token-table th {
    padding: 14px 16px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.token-table td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

.token-table tbody tr {
    cursor: pointer;
    transition: background 0.15s;
}

.token-table tbody tr:hover {
    background: rgba(200, 169, 81, 0.05);
}

.token-table tbody tr:last-child td {
    border-bottom: none;
}

.th-rank { width: 50px; text-align: center; }
.th-token { text-align: left; }
.th-pair { text-align: left; }
.th-price { text-align: right; }
.th-liquidity { text-align: right; }
.th-pairs { width: 70px; text-align: center; }
.th-tvl { text-align: right; }
.th-volume { text-align: right; }

.td-rank { text-align: center; color: var(--text-secondary); width: 50px; }
.td-price { text-align: right; font-weight: 500; white-space: nowrap; }
.td-liquidity { text-align: right; color: var(--text-primary); white-space: nowrap; }
.td-pairs { text-align: center; color: var(--text-secondary); width: 70px; }
.td-tvl { text-align: right; color: var(--accent); white-space: nowrap; }
.td-volume { text-align: right; color: var(--text-secondary); white-space: nowrap; }

.td-token {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
}

.token-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.token-name-group {
    display: flex;
    flex-direction: column;
}

.token-name {
    font-weight: 500;
    color: var(--text-primary);
}

.token-symbol {
    font-size: 13px;
    color: var(--text-secondary);
}

.td-price {
    text-align: right;
    font-weight: 500;
}

.change-positive { color: var(--green); }
.change-negative { color: var(--red); }

/* Pair Token Icons */
.pair-icons {
    display: flex;
    align-items: center;
}

.pair-icons img:last-child {
    margin-left: -8px;
}

.pair-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--bg-card);
}

.pair-icon:first-child {
    position: relative;
    z-index: 1;
}

.pair-icon:last-child {
    position: relative;
    z-index: 0;
}

/* Token Detail Page */
.detail-header {
    margin-bottom: 24px;
}

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

.back-btn:hover {
    color: var(--text-primary);
}

.token-detail-content,
.pair-detail-content {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 24px;
}

.token-detail-info,
.pair-detail-info {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
}

.token-detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.detail-token-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.detail-token-names h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 2px;
}

.detail-symbol {
    font-size: 14px;
    color: var(--text-secondary);
    margin-right: 8px;
}

.detail-address {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--text-tertiary);
    text-decoration: none;
    transition: color 0.2s;
}

.detail-address:hover {
    color: var(--accent);
}

.detail-price-section {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 24px;
}

.detail-price {
    font-size: 32px;
    font-weight: 700;
}

.detail-change {
    font-size: 16px;
    font-weight: 500;
}

.token-bio {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.token-description {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 12px;
}

.token-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.token-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
}

.token-link:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(200, 169, 81, 0.1);
}

.detail-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.detail-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.detail-stat-value {
    font-size: 16px;
    font-weight: 600;
}

.detail-about {
    margin-bottom: 24px;
}

.detail-about h3,
.detail-pairs-list h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.detail-about p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.detail-pairs-list {
    margin-bottom: 16px;
}

.detail-pair-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.detail-pair-item:hover {
    background: rgba(200, 169, 81, 0.1);
}

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

.detail-pair-icons {
    display: flex;
    align-items: center;
}

.detail-pair-icons img:last-child {
    margin-left: -6px;
}

.detail-pair-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--bg-secondary);
}

.detail-pair-name {
    font-size: 14px;
    font-weight: 500;
}

.detail-pair-volume {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Pair Detail */
.pair-detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.pair-icons-large {
    display: flex;
    align-items: center;
}

.pair-icon-large {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--bg-card);
}

.pair-icon-large:first-child {
    position: relative;
    z-index: 1;
}

.pair-icon-offset {
    margin-left: -12px;
    position: relative;
    z-index: 0;
}

.pair-detail-names h2 {
    font-size: 20px;
    font-weight: 600;
}

.pair-reserves {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 12px;
}

.reserve-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.reserve-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.reserve-info {
    display: flex;
    flex-direction: column;
}

.reserve-info span:first-child {
    font-weight: 500;
}

.reserve-usd {
    font-size: 13px;
    color: var(--text-secondary);
}

.add-liquidity-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    margin-top: 16px;
}

.add-liquidity-btn:hover {
    box-shadow: 0 0 20px rgba(200, 169, 81, 0.4);
}

/* Chart */
.token-detail-chart,
.pair-detail-chart {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
}

.chart-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.chart-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}

.chart-action-btn.swap-btn {
    background: var(--accent);
    color: #000;
}

.chart-action-btn.swap-btn:hover {
    background: var(--accent-hover);
}

.chart-action-btn.liq-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.chart-action-btn.liq-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

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

.chart-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: 8px;
}

.chart-tab {
    padding: 8px 16px;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.chart-tab.active {
    background: var(--accent);
    color: white;
}

.chart-container {
    width: 100%;
    height: 300px;
    position: relative;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
    cursor: crosshair;
}

.chart-legend {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.legend-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.legend-value {
    font-size: 14px;
    font-weight: 600;
}

/* Footer */
.footer {
    text-align: center;
    padding: clamp(6px, 1.5vw, 12px) clamp(8px, 2vw, 16px);
    border-top: 1px solid var(--border);
    margin-top: auto;
    background: var(--bg-primary);
    flex-shrink: 0;
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: clamp(10px, 2.2vw, 13px);
    color: var(--text-tertiary);
    flex-wrap: wrap;
}

.footer-brand strong {
    color: var(--text-secondary);
    font-weight: 600;
}

.footer-powered {
    color: var(--text-tertiary);
}

/* Responsive */
@media (max-width: 900px) {
    .token-detail-content,
    .pair-detail-content {
        grid-template-columns: 1fr;
    }
    
    .stats-row {
        grid-template-columns: 1fr;
    }
    
    .page-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }
    
    .search-bar {
        width: 100%;
    }
    
    .token-table th:nth-child(5),
    .token-table td:nth-child(5),
    .token-table th:nth-child(6),
    .token-table td:nth-child(6) {
        display: none;
    }
}

@media (max-width: 600px) {
    .header {
        padding: 12px 16px;
    }
    
    .logo span {
        display: none;
    }
    
    .nav-link {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .main-content {
        padding: 16px;
    }
    
    .page-header h1 {
        font-size: 18px;
    }
    
    .token-table th:nth-child(4),
    .token-table td:nth-child(4) {
        display: none;
    }
    
    .detail-price {
        font-size: 24px;
    }
}

/* Loading Skeleton */
.skeleton {
    background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-card) 50%, var(--bg-secondary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

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

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

::-webkit-scrollbar-thumb {
    background: rgba(200, 169, 81, 0.3);
    border-radius: 4px;
}

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

/* Swap History */
.swap-history-section {
    margin-top: 32px;
}

.swap-history-section h2,
.swap-history-section h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

.swap-table .th-type { width: 70px; }
.swap-table .th-from,
.swap-table .th-to { min-width: 180px; }
.swap-table .th-arrow { width: 40px; text-align: center; }
.swap-table .th-buyer { width: 120px; text-align: left; }
.swap-table .th-meta { width: 140px; text-align: right; }

.swap-badge {
    display: inline-block;
    padding: 3px 8px;
    background: rgba(200, 169, 81, 0.15);
    border: 1px solid rgba(200, 169, 81, 0.3);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
}

.td-swap-from,
.td-swap-to {
    display: flex;
    align-items: center;
    gap: 8px;
}

.swap-token-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
}

.td-arrow {
    text-align: center;
    color: var(--text-tertiary);
    font-size: 14px;
}

.td-swap-meta {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.tx-link {
    font-size: 12px;
    color: var(--accent);
    text-decoration: none;
    font-family: monospace;
}

.tx-link:hover { text-decoration: underline; }

.td-swap-buyer {
    font-size: 12px;
}

.buyer-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-family: monospace;
}

.buyer-link:hover {
    color: var(--accent);
    text-decoration: underline;
}

.swap-time {
    font-size: 11px;
    color: var(--text-tertiary);
}

@media (max-width: 600px) {
    .swap-table .th-buyer,
    .swap-table td:nth-child(5) {
        display: none;
    }
    .swap-table .th-meta,
    .swap-table td:nth-child(6) {
        display: none;
    }
}