:root {
    /* Hardcore DApp / Exchange Dense Palette */
    --bg-base: #0B0E14;
    --bg-surface: #151822;
    --bg-card: #1E2329;
    --text-primary: #EAECEF;
    --text-secondary: #848E9C;
    --accent-primary: #2EBD85;
    --accent-red: #F6465D;
    --border-light: #2B3139;
    
    /* Compact Radii */
    --radius-xl: 12px;
    --radius-lg: 8px;
    --radius-md: 4px;
    --radius-sm: 2px;
    
    /* Ultra-tight DApp Spacing */
    --spacing: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.4;
    overscroll-behavior-y: none;
    font-size: 13px; /* Smaller base font for density */
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
    background: var(--bg-base);
}

.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 0 60px 0; /* Less bottom padding */
}

/* Compact Global Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px var(--spacing);
    background: var(--bg-surface);
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid var(--border-light);
}
.brand-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}
.wallet-status {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border-radius: 100px;
    padding: 4px 10px 4px 4px;
    gap: 6px;
    cursor: pointer;
    border: 1px solid var(--border-light);
}
.wallet-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3B82F6;
    overflow: hidden;
}
.wallet-info { display: flex; align-items: center; gap: 4px; }
.wallet-name { font-size: 11px; font-weight: 500; }
.wallet-address-text { font-size: 10px; color: var(--accent-primary); }

/* Subpage Header */
.compact-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px var(--spacing);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 90;
}
.compact-header h2 { font-size: 15px; font-weight: 600; }
.back-btn { background: transparent; border: none; color: var(--text-secondary); width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; }

/* Dense Overview Card */
.overview-card-wrapper { padding: var(--spacing) var(--spacing) 8px var(--spacing); }
.overview-card {
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    padding: 16px;
    position: relative;
    border: 1px solid var(--border-light);
}
.oc-label { font-size: 11px; color: var(--text-secondary); margin-bottom: 4px; }
.oc-value { font-size: 28px; font-weight: 700; color: var(--text-primary); margin-bottom: 12px; line-height: 1.1; }
.oc-stats { display: flex; gap: 16px; }
.oc-stat-item { display: flex; flex-direction: column; gap: 2px; }
.oc-stat-lbl { font-size: 10px; color: var(--text-secondary); }
.oc-stat-val { font-size: 13px; font-weight: 600; }
.oc-val-green { color: var(--accent-primary); }

/* Quick Actions (Tight Grid) */
.glass-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 8px var(--spacing);
    gap: 8px;
}
.g-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.g-action-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
}
.g-action-icon svg { width: 18px; height: 18px; }
.g-action span { font-size: 11px; color: var(--text-primary); font-weight: 500; }

/* Assets Actions (Compact Buttons) */
.oc-asset-actions { display: flex; gap: 8px; margin-top: 12px; }
.btn-oc {
    flex: 1;
    padding: 8px 0;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    border: 1px solid var(--border-light);
}
.btn-oc.primary { background: var(--accent-primary); color: #000; border: none; font-weight: 700; }

/* DApp Dense Tabs */
.ios-tabs {
    display: flex;
    background: var(--bg-base);
    border-bottom: 1px solid var(--border-light);
    margin: 8px 0;
    padding: 0 var(--spacing);
    gap: 20px;
}
.ios-tab {
    padding: 10px 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
}
.ios-tab.active { color: var(--text-primary); border-bottom-color: var(--accent-primary); font-weight: 600; }

/* Flat Dense List */
.list-wrapper { padding: 0; }
.token-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px var(--spacing);
    background: var(--bg-base);
    border-bottom: 1px solid var(--border-light);
}
.tr-left { display: flex; align-items: center; gap: 10px; }
.tr-icon { width: 28px; height: 28px; border-radius: 50%; }
.tr-name { font-size: 14px; font-weight: 600; color: var(--text-primary); line-height: 1.2; }
.tr-amount { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.tr-right { text-align: right; }
.tr-fiat { font-size: 14px; font-weight: 600; line-height: 1.2; }
.tr-change { font-size: 11px; margin-top: 2px; }

/* Tiny Tickers */
.market-tickers {
    display: flex;
    gap: 8px;
    padding: 8px var(--spacing);
    margin: 8px 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.ticker-item {
    min-width: 100px;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    background: var(--bg-surface);
}
.ticker-pair { font-size: 11px; color: var(--text-secondary); font-weight: 500; }
.ticker-price { font-size: 14px; font-weight: 700; margin: 2px 0; }
.ticker-change { font-size: 11px; }

.text-green { color: var(--accent-primary) !important; }
.text-red { color: var(--accent-red) !important; }

/* --- COMPACT MINING DASHBOARD --- */
.mining-list-wrapper { padding: 0; }
.mining-card {
    background: var(--bg-surface);
    padding: 12px var(--spacing);
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}
.mc-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.mc-title-wrap { display: flex; flex-direction: column; gap: 4px; }
.mc-title { font-size: 14px; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; gap: 6px;}
.mc-badge { background: rgba(246, 70, 93, 0.15); color: var(--accent-red); padding: 2px 4px; border-radius: 2px; font-size: 9px; font-weight: 600; }
.mc-apy-block { text-align: right; }
.mc-apy { font-size: 16px; font-weight: 700; color: var(--accent-primary); line-height: 1; }
.mc-apy-lbl { font-size: 10px; color: var(--text-secondary); margin-top: 2px; }

.mc-grid {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}
.mc-stat { display: flex; flex-direction: column; gap: 2px; }
.mc-stat-lbl { font-size: 10px; color: var(--text-secondary); }
.mc-stat-val { font-size: 12px; font-weight: 600; color: var(--text-primary); }

.mc-action { display: flex; align-items: center; gap: 12px; }
.mc-progress { flex: 1; }
.mc-prog-bar { height: 4px; background: var(--bg-base); border-radius: 2px; overflow: hidden; margin-bottom: 4px; }
.mc-prog-fill { height: 100%; background: var(--accent-primary); }
.mc-prog-txt { font-size: 10px; color: var(--text-secondary); }

.btn-subscribe {
    background: var(--accent-primary);
    color: #000;
    border: none;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 600;
}

/* --- TRADING K-LINE PRO LAYOUT (ULTRA DENSE) --- */
.page-trading { padding-top: 0; }
.tpro-ticker-row {
    padding: 10px var(--spacing);
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    background: var(--bg-surface);
}
.tpro-main-price { font-size: 24px; font-weight: 700; line-height: 1;}
.tpro-stats { display: flex; gap: 12px; }
.tpro-stat { display: flex; flex-direction: column; align-items: flex-end; gap: 2px;}
.tpro-stat span { font-size: 10px; color: var(--text-secondary); }
.tpro-stat strong { font-size: 11px; font-weight: 500; }

.timeframes {
    display: flex; gap: 16px; padding: 6px var(--spacing); background: var(--bg-base);
    font-size: 12px; color: var(--text-secondary); border-bottom: 1px solid var(--border-light);
}
.tf-item { cursor: pointer; }
.tf-item.active { color: var(--accent-primary); font-weight: 600; }

.chart-wrapper {
    width: 100%; height: 320px; position: relative;
    border-bottom: 1px solid var(--border-light); background: var(--bg-base);
}
#tv_chart_container { width: 100%; height: 100%; position: absolute; top:0; left:0; }

.order-book-premium {
    padding: 10px var(--spacing); font-family: monospace; font-size: 12px; display: flex; gap: 12px;
}
.ob-col { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.ob-hdr { display: flex; justify-content: space-between; color: var(--text-secondary); font-size: 10px; margin-bottom: 4px; font-family: sans-serif;}
.ob-row { display: flex; justify-content: space-between; position: relative; z-index: 1;}
.ob-row.sell .p { color: var(--accent-red); }
.ob-row.buy .p { color: var(--accent-primary); }
.ob-row .v { color: var(--text-primary); }
.ob-bar { position: absolute; right: 0; top: 0; height: 100%; z-index: -1; opacity: 0.1; }
.ob-row.sell .ob-bar { background: var(--accent-red); }
.ob-row.buy .ob-bar { background: var(--accent-primary); }

.tpro-footer {
    display: flex; gap: 10px; padding: 10px var(--spacing);
    background: var(--bg-surface); position: fixed; bottom: 0; width: 100%; max-width: 600px;
    border-top: 1px solid var(--border-light); z-index: 100;
}
.btn-trade {
    flex: 1; padding: 10px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; border: none; color: #FFF;
}
.btn-trade.buy { background: var(--accent-primary); }
.btn-trade.sell { background: var(--accent-red); }

/* --- DENSE BOTTOM NAV BAR --- */
.bottom-nav {
    display: flex; justify-content: space-around;
    padding: 6px 0 calc(8px + env(safe-area-inset-bottom)) 0;
    background: #0B0E14; border-top: 1px solid #1E2329;
    position: fixed; bottom: 0; width: 100%; max-width: 600px; z-index: 100;
}
.nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    color: #848E9C; font-size: 10px; font-weight: 500; cursor: pointer;
}
.nav-item.active { color: #EAECEF; }
.nav-item svg { width: 22px; height: 22px; }

/* --- UTILS --- */
.page { display: none; }
.page.active { display: block; }
.ambient-bg { display: none; } /* Disabled for dense mode */

/* Swap Compact */
.swap-wrapper { padding: var(--spacing); }
.swap-card { background: var(--bg-surface); border-radius: var(--radius-lg); padding: 16px; margin-bottom: 2px; }
.swap-inp-head { display: flex; justify-content: space-between; color: var(--text-secondary); font-size: 11px; margin-bottom: 8px;}
.swap-inp-row { display: flex; justify-content: space-between; align-items: center;}
.swap-inp-row input { background: transparent; border: none; font-size: 24px; font-weight: 700; color: var(--text-primary); width: 60%; outline: none;}
.swap-coin { display: flex; align-items: center; gap: 6px; background: var(--bg-card); padding: 4px 10px; border-radius: 100px; font-size: 14px; font-weight: 600; }
.swap-coin img { width: 20px; height: 20px; border-radius: 50%; }
.swap-btn { width: 100%; padding: 14px; background: var(--accent-primary); color: #000; font-size: 15px; font-weight: 700; border-radius: var(--radius-md); border: none; margin-top: 16px; }
