:root {
    --bg: #0d1117;
    --surface: #161b22;
    --surface2: #1c2128;
    --border: #30363d;
    --text: #e6edf3;
    --text-muted: #7d8590;
    --green: #3fb950;
    --red: #f85149;
    --yellow: #d29922;
    --blue: #58a6ff;
    --purple: #bc8cff;
    --orange: #f0883e;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    min-height: 100vh;
}

/* Layout */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 0;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    padding: 20px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 18px;
    font-weight: 700;
    color: var(--blue);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-nav { padding: 12px 0; flex: 1; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 0;
    transition: background .15s, color .15s;
    font-size: 13px;
    border-left: 3px solid transparent;
}

.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { color: var(--blue); border-left-color: var(--blue); background: rgba(88,166,255,.08); }

.nav-section {
    padding: 16px 16px 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
}

.main { flex: 1; overflow: hidden; display: flex; flex-direction: column; }

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.topbar-title { font-size: 16px; font-weight: 600; }

.live-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.live-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--green);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .3; }
}

.content { flex: 1; overflow-y: auto; padding: 24px; }

/* Cards */
.cards-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 18px 20px;
}

.card-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 8px;
}

.card-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
}

.card-sub {
    font-size: 12px;
    margin-top: 4px;
}

.up   { color: var(--green); }
.down { color: var(--red); }
.flat { color: var(--text-muted); }

/* Charts row */
.charts-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 18px 20px;
}

.chart-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.chart-wrap { position: relative; height: 220px; }

/* Table */
.table-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 24px;
    overflow: hidden;
}

.table-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

thead th {
    padding: 10px 20px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
}

thead th:hover { color: var(--text); }

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background .1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }

tbody td {
    padding: 12px 20px;
    font-size: 13px;
}

.symbol-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.coin-icon {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--surface2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: var(--blue);
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.source-tags { display: flex; gap: 4px; flex-wrap: wrap; }

.tag {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

.tag-binance { background: rgba(240,185,11,.15); color: #f0b90b; }
.tag-kucoin  { background: rgba(15,200,120,.15);  color: #0fc878; }
.tag-wallet  { background: rgba(88,166,255,.15);   color: var(--blue); }

/* Exchange breakdown */
.exchange-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.exchange-row:last-child { border-bottom: none; }

.exchange-bar-wrap { flex: 1; background: var(--surface2); border-radius: 4px; height: 6px; }
.exchange-bar { height: 6px; border-radius: 4px; }
.bar-binance { background: #f0b90b; }
.bar-kucoin  { background: #0fc878; }
.bar-wallet  { background: var(--blue); }

/* Spinner */
.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-state { text-align: center; padding: 40px; }

/* Alerts */
.alert-bar {
    background: rgba(240,185,11,.12);
    border: 1px solid rgba(240,185,11,.3);
    border-radius: 6px;
    padding: 10px 16px;
    font-size: 12px;
    color: var(--yellow);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Refresh btn */
.btn {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 7px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: background .15s;
}
.btn:hover { background: var(--border); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #000; font-weight: 600; }
.btn-primary:hover { opacity: .85; }

/* Responsive */
@media (max-width: 900px) {
    .charts-row { grid-template-columns: 1fr; }
    .sidebar { display: none; }
}
