:root {
    --bg-color: var(--tg-theme-bg-color, #0b0f19);
    --card-bg: var(--tg-theme-secondary-bg-color, rgba(30, 41, 59, 0.7));
    --text-primary: var(--tg-theme-text-color, #f8fafc);
    --text-secondary: var(--tg-theme-hint-color, #94a3b8);
    --accent-blue: #38bdf8;
    --accent-indigo: #6366f1;
    --accent-emerald: #10b981;
    --accent-rose: #f43f5e;
    --border-color: rgba(255, 255, 255, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 12px;
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: 560px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Header */
.app-header {
    padding: 4px 2px;
}

.header-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.live-badge {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald);
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 5px;
}

.pulse {
    width: 6px;
    height: 6px;
    background: var(--accent-emerald);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent-emerald);
    animation: pulse-anim 1.5s infinite;
}

@keyframes pulse-anim {
    0% { opacity: 0.4; }
    50% { opacity: 1; transform: scale(1.2); }
    100% { opacity: 0.4; }
}

.symbol-tag {
    background: rgba(56, 189, 248, 0.12);
    color: var(--accent-blue);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}

.main-title {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sub-title {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 3px;
}

/* Stats Grid (Single Horizontal Row with 4 Cards) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.stat-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    padding: 8px 6px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    text-align: center;
    overflow: hidden;
}

.stat-label {
    font-size: 10px;
    color: var(--text-secondary);
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.stat-value {
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

/* Trades Split Open | Closed styling */
.trades-split {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.trades-open {
    color: #f87171; /* Light Red for Open (Buy) */
    font-weight: 700;
}

.trades-divider {
    color: var(--text-secondary);
    font-weight: 400;
    opacity: 0.5;
}

.trades-closed {
    color: #34d399; /* Light Green for Closed (Sell) */
    font-weight: 700;
}

/* Colors as requested: Gain USDT is Green, Total Gain Value is Blue */
.gain-btc {
    color: #f59e0b; /* Warm Gold/Orange for BTC */
}

.gain-usdt {
    color: var(--accent-emerald); /* Emerald/Green for Gain USDT */
}

.highlight-price {
    color: var(--accent-blue); /* Cyan/Blue for Total Gain Value */
}

/* Cards */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

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

.card-header h2 {
    font-size: 15px;
    font-weight: 700;
}

.time-filter {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
}

.chart-wrapper {
    position: relative;
    width: 100%;
    height: 230px;
}

/* Trades List */
.record-count {
    font-size: 11px;
    color: var(--text-secondary);
}

.trades-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.trade-item {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.15s ease;
}

.trade-item:hover {
    transform: translateY(-2px);
    border-color: rgba(56, 189, 248, 0.3);
}

.trade-left {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.uid-pill {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    width: fit-content;
}

.trade-date {
    font-size: 11px;
    color: var(--text-secondary);
}

.trade-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
}

.trade-price {
    font-size: 13px;
    font-weight: 700;
}

.trade-details {
    font-size: 11px;
    color: var(--text-secondary);
}
