:root {
    --primary-green: #50ae3d;
    --secondary-green: #0e5430;
    --background-body: #f0f4f8;
    --surface-white: #ffffff;
    --text-primary: #212529;
    --text-muted: #6c757d;
    --border-color: #e9ecef;

    --gradient-primary: linear-gradient(135deg, var(--primary-green) 0%, var(--secondary-green) 100%);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.08); 
    --shadow-header: 0 4px 12px rgba(0, 0, 0, 0.1);

    --radius-lg: 1rem;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100vh;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    background: var(--background-body);
    color: var(--text-primary);
}

.exchange-container {
    width: 100%;
    padding: 0.5rem 1rem 5rem 1rem;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.header-section {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    background: var(--surface-white);
    border: 1px solid rgba(0,0,0,0.05); /* Легкая рамка */
    border-radius: var(--radius-lg);
    padding: 0.75rem 1.5rem;
    
    box-shadow: var(--shadow-header);
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

.logo-section { display: flex; align-items: center; gap: 1.5rem; }
.company-logo { max-height: 50px; width: auto; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1)); }
.logo-placeholder { background: var(--background-body); padding: 0.5rem 1rem; border: 2px dashed var(--border-color); color: var(--text-muted); }
.date-time { font-size: 1.25rem; font-weight: 700; color: var(--primary-green); }

.table-header {
    background: var(--gradient-primary);
    padding: 0.75rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    flex-shrink: 0;
    color: white;
}

.table-header .bank-name { font-size: 1.5rem; font-weight: 700; color: white; text-transform: uppercase; letter-spacing: 0.5px; }
.update-time { color: rgba(255, 255, 255, 0.95); font-size: 0.875rem; font-weight: 500; }

.currency-cards-grid {
    display: grid;
    gap: 1.5rem; 
    overflow: hidden;
    flex: 1;
    min-height: 0;
    height: 100%;
    grid-auto-rows: 1fr;
    align-content: stretch;
    width: 100%;
}

.currency-cards-grid[data-count="1"] { grid-template-columns: 1fr; max-width: 1400px; margin: 0 auto; }
.currency-cards-grid[data-count="2"],
.currency-cards-grid[data-count="3"],
.currency-cards-grid[data-count="4"] { grid-template-columns: repeat(2, 1fr); }

.currency-cards-grid[data-count="5"],
.currency-cards-grid[data-count="6"],
.currency-cards-grid[data-count="7"],
.currency-cards-grid[data-count="8"],
.currency-cards-grid[data-count="9"],
.currency-cards-grid[data-count="10"],
.currency-cards-grid[data-count="11"],
.currency-cards-grid[data-count="12"] { 
    grid-template-columns: repeat(3, 1fr); 
}

.currency-card-wrapper { position: relative; height: 100%; }

.currency-card.vertical-layout {
    background: var(--surface-white);
    border-radius: 20px;
    padding: 2vmin;
    
    box-shadow: var(--shadow-card);
    border: 1px solid rgba(255,255,255,0.5); /* Легкий блик */
    
    transition: var(--transition);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    justify-content: flex-start;
}

.card-header-centered { display: flex; align-items: center; justify-content: center; gap: 1rem; flex: 0 0 auto; margin-bottom: 1vh; }
.currency-flag-sm { width: clamp(30px, 5vh, 60px); height: auto; border-radius: 4px; box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
.currency-title { font-size: clamp(1.5rem, 4vh, 3.5rem); font-weight: 800; color: var(--text-primary); line-height: 1; }

.card-content { width: 100%; flex: 1 1 auto; display: flex; flex-direction: column; justify-content: space-evenly; gap: 1vh; }
.rate-section { width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; flex-grow: 1; }
.section-title { font-size: clamp(0.8rem, 2vh, 1.5rem); font-weight: 700; color: var(--text-muted); text-transform: uppercase; margin-bottom: 0.5vh; text-align: center; width: 100%; border-bottom: 1px solid rgba(0,0,0,0.05); }

.labels-row, .values-row { display: flex; justify-content: space-around; width: 100%; padding: 0 1rem; }
.lbl { font-size: clamp(0.7rem, 1.5vh, 1.2rem); color: #999; font-weight: 600; text-transform: uppercase; }
.val { font-size: clamp(2rem, 6vh, 5rem); font-weight: 900; color: var(--text-primary); line-height: 1.1; letter-spacing: -0.03em; }
.section-divider { height: 1px; width: 80%; background: #eee; margin: 0 auto; flex-shrink: 0; }


.currency-card.mode-unified {
    padding: 2vmin;
}

.currency-card.mode-unified .card-content {
    justify-content: center;
    gap: 0;
}

.currency-card.mode-unified .labels-row,
.currency-card.mode-unified .values-row {
    justify-content: space-between;
    width: 100%;
    padding: 0;
    gap: 0;
}

.currency-card.mode-unified .lbl,
.currency-card.mode-unified .val {
    flex: 0 0 50%;     
    width: 50%;        
    text-align: center; 
    display: flex;
    justify-content: center;
    align-items: center;
}

.currency-card.mode-unified .lbl {
    font-size: clamp(1.2rem, 2vw, 2.2rem); 
    color: var(--text-muted);
    font-weight: 800;
    margin-bottom: 0.5vh;
}

.currency-card.mode-unified .val {
    font-size: clamp(2.5rem, 4.5vw, 6rem);
    padding: 0;
}

.d-none { display: none !important; }

@media (max-width: 768px) {
    .exchange-container { padding: 0.5rem; padding-bottom: 4rem; }
    .currency-cards-grid[data-count] { grid-template-columns: 1fr; }
    .val { font-size: clamp(2rem, 5vh, 4rem); }
}

@media (max-width: 1366px) {
    .val { 
        font-size: clamp(1.8rem, 5vh, 4rem); 
    }
    .currency-card.mode-unified .val {
        font-size: clamp(2.2rem, 4vw, 5rem);
    }
    .currency-title {
        font-size: clamp(1.2rem, 3vh, 2.5rem);
    }
}

@media (max-width: 1024px) {
    .exchange-container { 
        padding-bottom: 4.5rem;
    }
    
    .val { 
        font-size: clamp(1.5rem, 4vh, 3.5rem); 
    }
    .lbl {
        font-size: 0.9rem;
    }
    
    .currency-card.mode-unified .lbl {
        font-size: clamp(1rem, 1.5vw, 1.8rem);
    }
    .currency-card.mode-unified .val {
        font-size: clamp(2rem, 4vw, 4rem);
    }
}

@media (max-width: 768px) {
    .exchange-container { 
        padding: 0.5rem; 
        padding-bottom: 4rem; 
        height: auto; 
        overflow-y: auto;
    }

    .currency-cards-grid[data-count] { 
        grid-template-columns: 1fr !important; 
        height: auto; 
        display: block; 
    }
    
    .currency-card-wrapper {
        margin-bottom: 1rem;
        height: auto; 
        min-height: 200px;
    }

    .currency-card.vertical-layout {
        padding: 1.5rem;
    }

    .val { 
        font-size: clamp(2.5rem, 8vw, 4.5rem); 
    }
    
    .currency-card.mode-unified .val {
        font-size: clamp(3rem, 12vw, 5rem);
    }
    
    .currency-title {
        font-size: 2rem;
    }
    
    .header-section {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .table-header {
        justify-content: center;
        text-align: center;
        flex-direction: column;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .val { 
        font-size: clamp(2rem, 10vw, 3.5rem); 
    }
    
    .currency-card.mode-unified .val {
        font-size: clamp(2.2rem, 11vw, 3.5rem);
    }
    
    .currency-card.mode-unified .lbl {
        font-size: 1rem;
    }
    
    .currency-title {
        font-size: 1.5rem;
    }
    
    .currency-flag-sm {
        width: 40px;
    }
    
    .lbl {
        font-size: 0.8rem;
    }
    
    .update-time {
        font-size: 0.75rem;
    }
}

@media (max-width: 360px) {
    .val { font-size: 2rem; }
    .currency-card.mode-unified .val { font-size: 2rem; }
    .currency-title { font-size: 1.2rem; }
}