:root {
    /* Colors */
    --bg-app: #0a0f1a;
    --bg-card: #111827;
    --bg-card-hover: #1f2937;
    --bg-accent: rgba(59, 130, 246, 0.1);

    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --border-color: #1f2937;
    --border-hover: #374151;

    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-yellow: #fbbf24;
    --accent-purple: #a78bfa;
    --accent-orange: #f97316;

    /* Asset Colors */
    --color-gold: #fbbf24;
    --color-silver: #e5e7eb;
    --color-platinum: #a78bfa;
    --color-btc: #f97316;
    --color-eur: #3b82f6;
    --color-pln-usd: #10b981;
    --color-pln-eur: #ef4444;

    /* Layout */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);

    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background: var(--bg-app);
    background-image:
        radial-gradient(ellipse at top, rgba(59, 130, 246, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(168, 139, 250, 0.05) 0%, transparent 50%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ==================== HEADER ==================== */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 28px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
}

.logo {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-icon {
    font-size: 2.5rem;
    filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.3));
}

.logo-text h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 2px;
}

.logo-text .accent {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

.last-update {
    text-align: right;
    font-size: 0.85rem;
}

.last-update .label {
    color: var(--text-muted);
    display: block;
}

.last-update #last-update-time {
    color: var(--text-secondary);
    font-weight: 600;
}

.countdown {
    display: block;
    font-size: 0.75rem;
    color: var(--accent-blue);
    margin-top: 2px;
}

.refresh-btn {
    padding: 10px 16px;
    background: var(--accent-blue);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-main);
}

.refresh-btn:hover {
    background: #2563eb;
    transform: translateY(-2px);
}

.refresh-btn:active {
    transform: translateY(0);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.dot {
    width: 10px;
    height: 10px;
    background: var(--accent-yellow);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(0.9);
    }
}

/* ==================== PRICE CARDS ==================== */
.price-cards-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.price-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.price-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: currentColor;
    opacity: 0.8;
}

.price-card[data-asset="gold"] {
    color: var(--color-gold);
}

.price-card[data-asset="silver"] {
    color: var(--color-silver);
}

.price-card[data-asset="btc"] {
    color: var(--color-btc);
}

.price-card[data-asset="eur_usd"] {
    color: var(--color-eur);
}

.price-card[data-asset="pln_usd"] {
    color: var(--color-pln-usd);
}

.price-card[data-asset="platinum"] {
    color: var(--color-platinum);
}

.price-card[data-asset="pln_eur"] {
    color: var(--color-pln-eur);
}

.price-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: currentColor;
}

.source-tag {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

.source-tag.nbp {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.source-tag.binance {
    background: rgba(251, 191, 36, 0.2);
    color: #fcd34d;
}

.source-tag.calc {
    background: rgba(168, 139, 250, 0.2);
    color: #c4b5fd;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.card-icon {
    font-size: 1.5rem;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.card-price {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.card-unit {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.card-change {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.card-change .change-value {
    font-size: 0.95rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
}

.card-change .change-value.positive {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
}

.card-change .change-value.negative {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
}

.card-change .change-period {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ==================== MAIN GRID ==================== */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
}

@media (max-width: 1024px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
}

/* ==================== CHART SECTION ==================== */
.chart-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 24px;
    box-shadow: var(--shadow-card);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
}

.chart-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.normalize-toggle {
    display: flex;
    gap: 4px;
    background: rgba(16, 185, 129, 0.15);
    padding: 4px;
    border-radius: var(--radius-sm);
}

.normalize-btn {
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-main);
}

.normalize-btn:hover {
    color: var(--text-secondary);
}

.normalize-btn.active {
    background: var(--accent-green);
    color: white;
}

.chart-type-toggle {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.3);
    padding: 4px;
    border-radius: var(--radius-sm);
}

.chart-type-btn {
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-main);
}

.chart-type-btn:hover {
    color: var(--text-secondary);
}

.chart-type-btn.active {
    background: var(--accent-blue);
    color: white;
}

.time-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 10px 18px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-main);
}

.filter-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.filter-btn.active {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

.chart-container {
    position: relative;
    height: 450px;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.sidebar-card h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

/* Asset Toggles */
.toggles-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.asset-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.asset-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: currentColor;
}

.asset-toggle.active {
    background: rgba(255, 255, 255, 0.08);
    border-color: currentColor;
}

.checkbox-visual {
    width: 18px;
    height: 18px;
    border: 2px solid var(--text-muted);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.asset-toggle.active .checkbox-visual {
    background: currentColor;
    border-color: currentColor;
}

.asset-toggle.active .checkbox-visual::after {
    content: '✓';
    color: var(--bg-app);
    font-size: 12px;
    font-weight: 800;
}

/* Stats */
.stats-card .stat-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.stats-card .stat-row:last-child {
    border-bottom: none;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.stat-value {
    font-weight: 700;
    color: var(--text-primary);
}

.stat-value.positive {
    color: var(--accent-green);
}

.stat-value.negative {
    color: var(--accent-red);
}

/* Sources */
.sources-list {
    list-style: none;
}

.sources-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.source-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.source-badge.nbp {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
}

.source-badge.binance {
    background: rgba(251, 191, 36, 0.15);
    color: var(--accent-yellow);
}

.source-badge.calc {
    background: rgba(168, 139, 250, 0.15);
    color: var(--accent-purple);
}

/* ==================== FOOTER ==================== */
.main-footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-color);
}

.main-footer .copyright {
    margin-top: 8px;
    opacity: 0.7;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .app-container {
        padding: 16px;
    }

    .main-header {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    .header-right {
        flex-direction: column;
        gap: 12px;
    }

    .price-cards-section {
        grid-template-columns: repeat(2, 1fr);
    }

    .chart-container {
        height: 350px;
    }

    .section-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
}