/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:        #0d1117;
    --surface:   #161b22;
    --surface2:  #21262d;
    --border:    #30363d;
    --text:      #e6edf3;
    --text-dim:  #8b949e;
    --accent:    #58a6ff;
    --green:     #3fb950;
    --red:       #f85149;
    --yellow:    #d29922;
    --purple:    #a371f7;
    --radius:    8px;
    --shadow:    0 4px 24px rgba(0,0,0,0.4);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

.dashboard {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* ===== HEADER ===== */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

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

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

.demo-badge {
    background: var(--purple);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 3px 10px;
    border-radius: 20px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.last-updated {
    color: var(--text-dim);
    font-size: 0.85rem;
}

.btn-refresh {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 6px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s, border-color 0.2s;
}
.btn-refresh:hover {
    background: var(--border);
    border-color: var(--accent);
}

/* ===== PORTFOLIO BANNER ===== */
.portfolio-banner {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.portfolio-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.portfolio-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-dim);
}

.portfolio-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent);
}

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

/* ===== CASH PANEL ===== */
.cash-panel {
    margin-bottom: 16px;
}

/* ===== MAIN GRID ===== */
.main-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

/* ===== PANELS ===== */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel-header {
    background: var(--surface2);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.panel-header h2 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.panel-body {
    padding: 0;
}

/* ===== TABLE WRAP ===== */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

thead tr {
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
}

th {
    padding: 10px 14px;
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    font-weight: 600;
    white-space: nowrap;
}

td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    white-space: nowrap;
}

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

/* ===== SIGNAL BADGE ===== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-buy   { background: rgba(63,185,80,0.15); color: var(--green); }
.badge-sell  { background: rgba(248,81,73,0.15);  color: var(--red); }
.badge-hold  { background: rgba(210,153,34,0.15); color: var(--yellow); }

/* ===== PRICE CELLS ===== */
.price { font-family: 'SF Mono', 'Fira Code', monospace; font-weight: 600; }
.change-pos { color: var(--green); }
.change-neg { color: var(--red); }

/* ===== POSITION P/L ===== */
.pnl-pos { color: var(--green); font-weight: 600; }
.pnl-neg { color: var(--red); font-weight: 600; }

/* ===== TRADE TYPE ===== */
.type-buy  { color: var(--green); font-weight: 600; }
.type-sell { color: var(--red); font-weight: 600; }

/* ===== COIN CELL ===== */
.coin-sym {
    font-weight: 700;
    color: var(--accent);
    font-size: 0.9rem;
}

/* ===== CASH HOLDINGS ===== */
.cash-value {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-weight: 600;
    font-size: 0.95rem;
}

/* ===== LOADING / EMPTY ===== */
.loading, .empty-state {
    padding: 32px;
    text-align: center;
    color: var(--text-dim);
    font-size: 0.9rem;
}

.empty-state { padding: 24px; }

/* ===== ERROR BANNER ===== */
.error-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--red);
    color: #fff;
    padding: 12px 20px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    box-shadow: 0 4px 20px rgba(248,81,73,0.4);
    z-index: 1000;
}
.error-banner.hidden { display: none; }
.error-banner button {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.8;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .main-grid { grid-template-columns: 1fr; }
    .portfolio-banner { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
    .dashboard { padding: 12px; }
    header { flex-direction: column; align-items: flex-start; }
    .portfolio-banner { grid-template-columns: repeat(2, 1fr); }
    table { font-size: 0.8rem; }
    th, td { padding: 8px 10px; }
    .portfolio-value { font-size: 1.3rem; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
