:root {
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --accent: #00f2ff;
    --accent-glow: rgba(0, 242, 255, 0.4);
    --text-main: #f1f5f9;
    --text-dim: #94a3b8;
    --border: rgba(255, 255, 255, 0.08);
    --glass-blur: blur(12px);
    --success: #00ff88;
    --radius: 12px;
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 0% 0%, rgba(0, 242, 255, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.1) 0px, transparent 50%);
    color: var(--text-main);
    font-family: var(--font-sans);
    min-height: 100vh;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
}

@media (max-width: 768px) {
    .container { padding: 1rem 1rem; }
}

/* Glassmorphism Utility */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.glass-card:hover {
    border-color: rgba(0, 242, 255, 0.3);
}

/* Header & Logo */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.icon {
    font-size: 2rem;
    filter: drop-shadow(0 0 10px var(--accent-glow));
}

.logo-text h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.logo-text .subtitle {
    color: var(--text-dim);
    font-size: 0.75rem;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.cost-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem !important;
}

.cost-badge input {
    background: transparent;
    border: none;
    color: var(--accent);
    font-weight: 600;
    width: 80px;
    outline: none;
    font-family: inherit;
    font-size: 0.9rem;
}

.glass-select {
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.5rem 1.75rem 0.5rem 0.75rem;
    border-radius: 8px;
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 0.8rem;
    font-size: 0.9rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 100px;
    justify-content: flex-start; /* Consistent top alignment */
    padding-top: 1.25rem !important;
}

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

.card-header .label {
    color: var(--text-dim);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.main-val {
    display: flex;
    align-items: baseline;
    gap: 0.2rem;
}

.main-val .value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
}

.main-val .unit {
    color: var(--text-dim);
    font-size: 0.9rem;
}

.sub-val {
    font-size: 0.8rem;
    color: var(--accent);
    font-weight: 500;
    margin-top: 0.1rem;
}

.live-card {
    border-left: 3px solid var(--accent);
}

.live-indicator {
    background: rgba(0, 255, 136, 0.1);
    color: var(--success);
    font-size: 0.65rem;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    border: 1px solid rgba(0, 255, 136, 0.1);
}

.live-indicator::before {
    content: '';
    width: 5px;
    height: 5px;
    background: var(--success);
    border-radius: 50%;
    animation: flash 1.5s infinite;
}

@keyframes flash {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
    100% { opacity: 1; transform: scale(1); }
}

/* Tooltip Projection - Re-implemented as Overlay */
.price-tooltip {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    text-align: center;
    border-radius: var(--radius);
    z-index: 10;
}

.stat-card:hover .price-tooltip {
    opacity: 1;
    pointer-events: auto;
}

.tooltip-title { color: var(--text-dim); font-size: 0.7rem; text-transform: uppercase; font-weight: 700; margin-bottom: 2px; }
.tooltip-value { color: var(--accent); font-size: 1.25rem; font-weight: 800; }
.price-tooltip p { font-size: 0.6rem; color: rgba(255,255,255,0.4); margin-top: 2px; }

/* Dashboard Layout */
.dashboard-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 1.5rem;
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Charts */
.chart-section {
    min-height: 350px;
    display: flex;
    flex-direction: column;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.chart-title h2 { font-size: 1.1rem; font-weight: 600; }
#last-update { color: var(--text-dim); font-size: 0.7rem; margin-top: 0.1rem; }

.range-selector {
    display: flex;
    background: rgba(0,0,0,0.2);
    padding: 3px;
    border-radius: 8px;
    gap: 1px;
}

.range-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.2s;
}

.range-btn.active {
    background: var(--accent);
    color: white;
}

.chart-container {
    flex-grow: 1;
    position: relative;
    width: 100%;
}

/* Secondary Grid */
.secondary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* Detailed Stats Redesign */
.detailed-stats h2 { font-size: 1.1rem; margin-bottom: 1rem; }
.stats-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.03);
    padding: 0.75rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    transition: background 0.2s;
}

.stat-item:hover {
    background: rgba(255,255,255,0.05);
}

.s-label { 
    color: var(--text-dim); 
    font-size: 0.8rem; 
    font-weight: 500;
}
.s-value { 
    font-weight: 700; 
    color: var(--accent); 
    font-size: 0.9rem;
}

/* Sidebar Peaks */
.peaks-card h2 { font-size: 1.1rem; margin-bottom: 1rem; }
.peaks-list { list-style: none; display: flex; flex-direction: column; gap: 0.75rem; }
.peaks-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.75rem;
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    border-left: 2px solid var(--accent);
}
.peak-val { font-weight: 700; color: var(--text-main); font-size: 0.9rem; }
.peak-date { font-size: 0.7rem; color: var(--text-dim); }

/* Status */
.status-ok { color: var(--success); font-weight: 600; }

/* Footer */
footer {
    margin-top: 2.5rem;
    text-align: center;
    color: var(--text-dim);
    font-size: 0.8rem;
    padding-bottom: 1.5rem;
}

/* Animations */
.animate-fadedown {
    animation: fadeInDown 0.6s ease-out;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1100px) {
    .dashboard-layout { grid-template-columns: 1fr; }
    .secondary-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    .range-selector {
        width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 2px;
    }
}

@media (max-width: 600px) {
    .container { padding: 0.5rem 0.75rem; }
    header { 
        flex-direction: column; 
        align-items: flex-start; 
        gap: 1rem; 
        margin-bottom: 1rem;
    }
    .header-actions { 
        width: 100%; 
        flex-direction: column; 
        gap: 0.5rem;
    }
    .cost-badge, .device-selector-wrapper, .glass-select { 
        width: 100%; 
        justify-content: space-between;
    }
    .logo-text h1 { font-size: 1.1rem; }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
    
    .main-val .value { font-size: 1.4rem; }
    .main-val .unit { font-size: 0.8rem; }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .secondary-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-section {
        min-height: 280px;
    }
    
    .chart-header h2 { font-size: 1rem; }
    
    .stat-item {
        padding: 0.6rem 0.75rem;
    }
    
    .s-label { font-size: 0.75rem; }
    .s-value { font-size: 0.85rem; }
}