:root {
    --bg-color: #0d1117;
    --card-bg: #161b22;
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --accent: #58a6ff;
    --accent-hover: #1f6feb;
    --border: #30363d;
    --buy-color: #3fb950;
    --sell-color: #da3633;
    --glass-bg: rgba(22, 27, 34, 0.7);
    --glass-border: 1px solid rgba(240, 246, 252, 0.1);
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
header {
    padding: 24px 0;
    margin-bottom: 24px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(90deg, #fff, #8b949e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-links a {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}

.header-links a:hover {
    color: var(--accent-hover);
}

.divider {
    color: var(--border);
    margin: 0 12px;
}

/* Glass Panel */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: var(--glass-border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

/* Controls */
.controls-section {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: center;
    justify-content: space-between;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.control-group label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

.range-buttons button {
    background: var(--bg-color);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.range-buttons button:first-child {
    border-radius: 6px 0 0 6px;
}

.range-buttons button:last-child {
    border-radius: 0 6px 6px 0;
}

.range-buttons button:hover {
    background: var(--border);
    color: var(--text-primary);
}

.range-buttons button.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.filter-options,
.exchange-toggles {
    display: flex;
    gap: 12px;
}

.radio-label,
.exchange-toggles label {
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

/* Chart */
.chart-section {
    position: relative;
    height: 400px;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(13, 17, 23, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
    transition: opacity 0.3s;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--accent);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Rates Table */
.rates-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}

.rates-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.rate-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.input-group label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.input-group input {
    background: var(--bg-color);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    width: 160px;
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent);
}

#getRateBtn {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 9px 16px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s;
}

#getRateBtn:active {
    transform: scale(0.98);
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tr:last-child td {
    border-bottom: none;
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

.text-buy {
    color: var(--buy-color);
}

.text-sell {
    color: var(--sell-color);
}

.font-bold {
    font-weight: 700;
}

.action-btn {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
}

.action-btn:hover {
    text-decoration: underline;
}

.legend-hint {
    margin-top: 16px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    gap: 16px;
}

.hint-buy::before {
    content: '●';
    color: var(--buy-color);
    margin-right: 4px;
}

.hint-sell::before {
    content: '●';
    color: var(--sell-color);
    margin-right: 4px;
}

footer {
    text-align: center;
    padding: 24px 0;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: auto;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .controls-section {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }

    .control-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .range-buttons {
        width: 100%;
        display: flex;
    }

    .range-buttons button {
        flex: 1;
    }

    .rates-header {
        flex-direction: column;
        align-items: stretch;
    }

    .rate-form {
        flex-direction: column;
        align-items: stretch;
    }

    .input-group input {
        width: 100%;
    }

    .chart-section {
        height: 50vh;
        min-height: 400px;
    }
}

/* Floating Bubbles */
.floating-bubbles {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 16px;
}

.bubbles-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-end;
    transition: opacity 0.3s, transform 0.3s, visibility 0.3s;
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
}

.floating-bubbles.closed .bubbles-list {
    opacity: 0;
    transform: translateY(20px);
    visibility: hidden;
    pointer-events: none;
}

.bubble-btn {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
    max-width: 320px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.bubble-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
    background-color: #1c2128;
    border-color: var(--accent);
}

.bubble-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    margin-right: 12px;
    flex-shrink: 0;
}

.bubble-icon svg {
    width: 24px;
    height: 24px;
    color: var(--accent);
}

.bubble-telegram .bubble-icon svg {
    color: #229ED9;
}

.bubble-email .bubble-icon svg {
    color: #f1c40f;
}

.bubble-text {
    display: flex;
    flex-direction: column;
}

.bubble-title {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.2;
}

.bubble-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.2;
    margin-top: 2px;
}

/* Toggle Button */
.bubble-toggle-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background-color 0.2s;
}

.bubble-toggle-btn:hover {
    transform: scale(1.05);
    background-color: var(--accent-hover);
}

.bubble-toggle-btn svg {
    width: 28px;
    height: 28px;
}

/* State changes for Toggle Button */
.floating-bubbles.closed .icon-close {
    display: none;
}

.floating-bubbles:not(.closed) .icon-open {
    display: none;
}

.floating-bubbles:not(.closed) .icon-close {
    display: block !important;
}

@media (max-width: 600px) {
    .floating-bubbles {
        right: 16px;
        bottom: 16px;
        align-items: flex-end;
    }

    .bubbles-list {
        align-items: flex-end;
    }

    .bubble-btn {
        width: 100%;
        max-width: 280px;
    }
}