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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #0a0e27;
    color: #e0e0e0;
    padding: 20px;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
}

h1 {
    color: #fff;
    margin-bottom: 30px;
    text-align: center;
}

.filters {
    background: #1a1f3a;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label {
    font-size: 12px;
    color: #a0a0a0;
    text-transform: uppercase;
}

.filter-group input,
.filter-group select {
    padding: 8px 12px;
    background: #0f1322;
    border: 1px solid #2a2f4a;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 14px;
    min-width: 150px;
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: #4a90e2;
}

.btn {
    padding: 8px 20px;
    background: #4a90e2;
    border: none;
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.3s;
}

.btn:hover {
    background: #357abd;
}

.btn:disabled {
    background: #2a2f4a;
    cursor: not-allowed;
}

.btn-secondary {
    background: transparent;
    border: 1px solid #4a90e2;
    color: #4a90e2;
}

.btn-secondary:hover {
    background: rgba(74, 144, 226, 0.1);
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #4a90e2;
}

.error {
    background: #d32f2f;
    color: #fff;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.table-wrapper {
    overflow-x: auto;
    background: #1a1f3a;
    border-radius: 8px;
    padding: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1400px;
}

thead {
    background: #0f1322;
}

th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: #a0a0a0;
    border-bottom: 2px solid #2a2f4a;
    cursor: pointer;
    user-select: none;
}

th:hover {
    color: #4a90e2;
}

th.sort-asc::after {
    content: ' ▲';
    color: #4a90e2;
}

th.sort-desc::after {
    content: ' ▼';
    color: #4a90e2;
}

td {
    padding: 12px;
    border-bottom: 1px solid #2a2f4a;
    font-size: 13px;
}

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

tbody tr:hover {
    background: #252a4a;
}

.ticker {
    font-weight: 600;
    color: #fff;
}

.ticker-image {
    width: 35px;
    border-radius: 50%;
    object-fit: cover;
}

.ticker-group-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ticker-group-row td {
    background: #0f1322;
    font-weight: 600;
    color: #fff;
    border: 1px solid #2a2f4a;
}

@media (max-width: 678px) {
    .ticker-group-row {
        display: block;
    }
}

.ticker-group-name {
    font-size: 16px;
}

.ticker-group-meta {
    font-size: 13px;
    color: #a0a0a0;
    margin-left: 10px;
}

.ticker-sub-row td:first-child {
    width: 20px;
}

.ticker-sub-row__deactivated {
    display: none;
}

.exchange {
    display: inline-block;
    padding: 2px 8px;
    background: #2a2f4a;
    border-radius: 3px;
    font-size: 11px;
    margin-right: 5px;
}

.positive {
    color: #4caf50;
}

.negative {
    color: #f44336;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    padding: 20px;
}

.pagination-info {
    color: #a0a0a0;
    font-size: 14px;
}

@media (max-width: 1024px) {
    body {
        padding: 16px;
    }

    .container {
        padding: 0 5px;
    }

    .table-wrapper {
        padding: 12px;
        overflow-x: visible;
    }

    table {
        min-width: 0;
    }

    thead {
        display: none;
    }

    tbody {
        display: block;
    }

    .ticker-group-row td {
        display: flex;
        flex-direction: column;
        gap: 4px;
        font-size: 15px;
        border-radius: 6px;
    }

    .ticker-sub-row {
        display: block;
        margin-bottom: 16px;
        border: 1px solid #2a2f4a;
        border-radius: 10px;
        overflow: hidden;
        background: #0f1322;
    }

    .ticker-sub-row td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        padding: 10px 14px;
        border-bottom: 1px solid #2a2f4a;
        font-size: 14px;
    }

    .ticker-sub-row td:last-child {
        border-bottom: none;
    }

    .ticker-sub-row td.mobile-hidden {
        display: none;
    }

    .ticker-sub-row td[data-label]::before {
        content: attr(data-label);
        font-size: 11px;
        text-transform: uppercase;
        color: #7a7f9e;
        flex: 0 0 auto;
        min-width: 120px;
        letter-spacing: 0.04em;
    }

    .ticker-sub-row td[data-label] {
        flex-direction: row;
        align-items: center;
        gap: 8px;
        flex-wrap: wrap;
    }

    .ticker-sub-row td[data-label] > * {
        flex: 1;
        text-align: right;
        word-break: break-word;
        white-space: nowrap;
    }

    .exchange {
        margin-right: 0;
    }

    .pagination {
        flex-direction: column;
        gap: 12px;
    }

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

.stats {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stat-card {
    background: #1a1f3a;
    padding: 15px 20px;
    border-radius: 8px;
    flex: 1;
    min-width: 200px;
}

.stat-card h3 {
    font-size: 12px;
    color: #a0a0a0;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.stat-card .value {
    font-size: 24px;
    font-weight: 600;
    color: #fff;
}

.last-update {
    margin-top: 10px;
    color: #a0a0a0;
    font-size: 14px;
}

.changes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.change-card {
    background: #1a1f3a;
    border-radius: 8px;
    padding: 12px 15px;
    border: 1px solid #2a2f4a;
}

.change-card.empty {
    grid-column: 1 / -1;
    text-align: center;
    color: #a0a0a0;
}

.change-card h4 {
    font-size: 14px;
    color: #fff;
    margin-bottom: 4px;
}

.change-card .subtitle {
    font-size: 12px;
    color: #7a7f9e;
    margin-bottom: 8px;
}

.delta-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.delta-item {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.delta-label {
    color: #a0a0a0;
}

.delta-value {
    font-weight: 600;
}

.delta-positive {
    color: #4caf50;
}

.delta-negative {
    color: #f44336;
}

.history-panel {
    margin-top: 30px;
    background: #1a1f3a;
    border-radius: 8px;
    padding: 20px;
    border: 1px solid #2a2f4a;
}

.history-empty {
    text-align: center;
    color: #a0a0a0;
    font-size: 14px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    gap: 10px;
}

.history-title {
    font-size: 20px;
    font-weight: 600;
    color: #fff;
}

.history-subtitle {
    color: #a0a0a0;
    font-size: 14px;
}

.history-diff-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.history-diff-card {
    background: #0f1322;
    border-radius: 6px;
    padding: 10px 12px;
    border: 1px solid #2a2f4a;
}

.history-diff-card h5 {
    font-size: 12px;
    text-transform: uppercase;
    color: #a0a0a0;
    margin-bottom: 6px;
}

.history-diff-values {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
}

.history-diff-current {
    color: #fff;
}

.history-diff-delta {
    font-weight: 600;
}

.history-table-wrapper {
    margin-top: 15px;
    overflow-x: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px;
}

.history-table th,
.history-table td {
    padding: 10px;
    border-bottom: 1px solid #2a2f4a;
    font-size: 13px;
    text-align: left;
}

.history-table th {
    color: #a0a0a0;
    text-transform: uppercase;
    font-size: 12px;
}

.history-table tr:hover td {
    background: #252a4a;
}

.history-metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-timestamp {
    color: #a0a0a0;
    font-size: 12px;
}

.row-up {
    animation: highlightUp 0.8s ease-out;
    background: rgba(76, 175, 80, 0.12);
}

.row-down {
    animation: highlightDown 0.8s ease-out;
    background: rgba(244, 67, 54, 0.12);
}

.row-neutral {
    background: transparent;
}

@keyframes highlightUp {
    from { background: rgba(76, 175, 80, 0.5); }
    to { background: rgba(76, 175, 80, 0.12); }
}

@keyframes highlightDown {
    from { background: rgba(244, 67, 54, 0.5); }
    to { background: rgba(244, 67, 54, 0.12); }
}
