/* ===== Стили для таблицы (newindex) ===== */

/* Убираем ограничения ширины контейнера */
.main-container {
    max-width: 100% !important;
    padding: 0 0.5rem !important;
}
.tab-content.active {
    max-width: 100% !important;
    padding: 0 !important;
}
#tableContainer {
    width: 100%;
    max-width: 100%;
    padding: 0;
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
    background: #1e293b;
    border-radius: 16px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    padding: 0.5rem 0;
    margin-top: 1.5rem;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    table-layout: auto;
}
th,
td {
    border: 1px solid #2d3b52;
    padding: 0.5rem 0.6rem;
    text-align: center;
    vertical-align: middle;
}
th {
    color: #94a3b8;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    background: #1a2538;
    border-color: #334155;
}
th:hover {
    color: #e2e8f0;
}
th .sort-icon {
    margin-left: 0.3rem;
    font-size: 0.7rem;
    opacity: 0.5;
}
td {
    cursor: pointer;
    transition: background 0.15s;
}
tr:hover td {
    background: #2d3b52;
}

/* Выделение активных строк */
tr.row-active td {
    background: rgba(74, 222, 128, 0.08);
   
}
tr.row-active:hover td {
    background: rgba(74, 222, 128, 0.15);
}

/* Ширина столбцов (десктоп) */
.col-id {
    width: 60px;
    min-width: 60px;
}
.col-moniker {
    width: auto;
    min-width: 120px;
    white-space: nowrap;
}
.col-identity {
    width: 100px;
    min-width: 90px;
}
.col-country {
    width: 70px;
    min-width: 60px;
}
.col-perf {
    width: 80px;
    min-width: 70px;
}
.col-deleg {
    width: 70px;
    min-width: 60px;
}
.col-saturation {
    width: 80px;
    min-width: 70px;
}
.col-stake {
    width: 100px;
    min-width: 80px;
}
.col-status {
    width: 80px;
    min-width: 70px;
}
.col-dp {
    width: 50px;
    min-width: 40px;
}
.col-as {
    width: 70px;
    min-width: 60px;
}
.col-reliability {
    width: auto;
    min-width: 160px;
}
.col-avg {
    width: 70px;
    min-width: 60px;
}

/* Стили содержимого ячеек */
.node-name {
    font-weight: 600;
    color: #b9d0f0;
}
.node-id {
    color: #64748b;
    font-size: 0.85rem;
}
.identity-short {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: #94a3b8;
}
.country-flag {
    font-size: 1.2rem;
    margin-right: 0.2rem;
}
.country-code {
    color: #94a3b8;
    font-size: 0.75rem;
}
.badge {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-active {
    background: #0f3b2a;
    color: #4ade80;
}
.badge-inactive {
    background: #3b1f1f;
    color: #f87171;
}
.badge-dp {
    background: #1e3a5f;
    color: #60a5fa;
}
.badge-nodp {
    background: #2d2d2d;
    color: #64748b;
}
.perf-value {
    font-weight: 500;
}
.stake-value {
    font-weight: 400;
    color: #e2e8f0;
}
.saturation-value {
    font-weight: 500;
}
.saturation-high {
    color: #f87171;
}
.saturation-medium {
    color: #fbbf24;
}
.saturation-low {
    color: #4ade80;
}
.as-value {
    font-weight: 500;
}
.as-high {
    color: #4ade80;
}
.as-medium {
    color: #fbbf24;
}
.as-low {
    color: #f87171;
}
.avg-value {
    font-weight: 500;
    font-size: 0.9rem;
    color: #e2e8f0;
}
.reliability-bars {
    display: flex;
    gap: 2px;
    align-items: flex-end;
    justify-content: center;
    height: 34px;
    padding: 0 4px;
}
.bar {
    width: 5px;
    border-radius: 2px 2px 0 0;
    flex-shrink: 0;
    transition: background 0.2s, height 0.3s ease;
    min-height: 2px;
}
.no-data {
    color: #64748b;
    font-size: 0.9rem;
}
.error-msg {
    color: #f87171;
    text-align: center;
    padding: 2rem;
}

/* ===== ШИРОКОЕ МОДАЛЬНОЕ ОКНО ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.25s ease;
}
.modal-overlay.active {
    display: flex;
}
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.97);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-box {
    background: #1e293b;
    border-radius: 24px;
    padding: 1.8rem 2.2rem 1.5rem;
    width: 94vw;
    max-width: 1400px;
    height: 92vh;
    max-height: 92vh;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #334155;
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 20px;
    font-size: 1.8rem;
    cursor: pointer;
    color: #94a3b8;
    transition: color 0.2s, transform 0.2s;
    background: none;
    border: none;
    line-height: 1;
    z-index: 10;
}
.modal-close:hover {
    color: #f1f5f9;
    transform: rotate(90deg);
}

.modal-header-center {
    text-align: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid #2d3b52;
    flex-shrink: 0;
}
.modal-moniker {
    font-size: 1.8rem;
    font-weight: 600;
    color: #b9d0f0;
    letter-spacing: 0.5px;
}
.modal-moniker-id {
    font-size: 1.2rem;
    color: #64748b;
    font-weight: 400;
    margin-left: 0.8rem;
}

.modal-body-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem 3rem;
    padding: 1.2rem 0 0.8rem 0;
    flex-shrink: 0;
    flex-grow: 0;
}

.modal-field {
    display: flex;
    align-items: center;
    padding: 0.3rem 0;
    border-bottom: 1px solid rgba(45, 59, 82, 0.4);
}
.modal-field:last-child {
    border-bottom: none;
}
.modal-field .label {
    color: #94a3b8;
    font-weight: 400;
    font-size: 0.85rem;
    min-width: 140px;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.modal-field .value {
    color: #e2e8f0;
    font-weight: 500;
    font-size: 0.95rem;
    word-break: break-all;
    flex: 1;
}
.modal-field .value.identity-full {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    background: #0f172a;
    padding: 0.15rem 0.6rem;
    border-radius: 6px;
    word-break: break-all;
}
.modal-field .value .flag-icon {
    font-size: 1.4rem;
    margin-right: 0.4rem;
    vertical-align: middle;
}
.modal-field .value .country-name {
    vertical-align: middle;
}

.saturation-bar-wrapper {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex: 1;
}
.saturation-bar-track {
    flex: 1;
    height: 8px;
    background: #2d3b52;
    border-radius: 10px;
    overflow: hidden;
    min-width: 80px;
}
.saturation-bar-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.6s ease;
    background: linear-gradient(90deg, #4ade80, #fbbf24, #f87171);
}
.saturation-label {
    font-weight: 600;
    font-size: 0.95rem;
    min-width: 55px;
    text-align: right;
    color: #e2e8f0;
}

.modal-badge {
    display: inline-block;
    padding: 0.1rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}
.modal-badge.active {
    background: #0f3b2a;
    color: #4ade80;
}
.modal-badge.inactive {
    background: #3b1f1f;
    color: #f87171;
}
.modal-badge.dp-yes {
    background: #1e3a5f;
    color: #60a5fa;
}
.modal-badge.dp-no {
    background: #2d2d2d;
    color: #64748b;
}

.modal-charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    padding: 0.6rem 0 0.6rem 0;
    flex: 1;
    min-height: 0;
}
.modal-chart-box {
    background: #0f172a;
    border-radius: 14px;
    padding: 0.8rem 1rem 0.6rem;
    border: 1px solid #2d3b52;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.modal-chart-box h4 {
    color: #94a3b8;
    font-weight: 400;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.3rem;
    flex-shrink: 0;
    text-align: center;
}
.modal-chart-box .chart-container {
    flex: 1;
    min-height: 0;
    position: relative;
}
.modal-chart-box .chart-container canvas {
    width: 100% !important;
    height: 100% !important;
    max-height: 100%;
}
.chart-placeholder-text {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #64748b;
    font-size: 0.9rem;
    font-style: italic;
    flex-direction: column;
    gap: 0.3rem;
}
.chart-placeholder-text i {
    font-size: 2rem;
    color: #334155;
}

.modal-actions-row {
    display: flex;
    justify-content: center;
    gap: 1.2rem;
    padding: 0.8rem 0 0.2rem 0;
    border-top: 1px solid #2d3b52;
    flex-shrink: 0;
    flex-wrap: wrap;
}
.modal-action-btn {
    padding: 0.6rem 2rem;
    border: none;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.modal-action-btn.btn-explorer {
    background: #3b82f6;
}
.modal-action-btn.btn-explorer:hover {
    background: #2563eb;
    transform: translateY(-2px);
}
.modal-action-btn.btn-spectre {
    background: #8b5cf6;
}
.modal-action-btn.btn-spectre:hover {
    background: #7c3aed;
    transform: translateY(-2px);
}
.modal-action-btn.btn-delegate-modal {
    background: #22c55e;
}
.modal-action-btn.btn-delegate-modal:hover {
    background: #16a34a;
    transform: translateY(-2px);
}
.modal-action-btn i {
    font-size: 1rem;
}

/* ===== Глобальный спинер ===== */
#global-spinner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 17, 32, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.4s ease;
}
#global-spinner.hidden {
    opacity: 0;
    pointer-events: none;
}
.global-spinner-circle {
    width: 60px;
    height: 60px;
    border: 4px solid #2d3b52;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
.global-spinner-text {
    margin-top: 1.5rem;
    color: #94a3b8;
    font-size: 1.1rem;
    letter-spacing: 0.5px;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== Контролы (фильтры, поиск) ===== */
.content-header {
    margin-bottom: 1.5rem;
}
.content-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    margin: 1rem 0;
}
.quick-filters {
    display: flex;
    gap: 0.5rem;
}
.filter-btn {
    background: #1e293b;
    border: 1px solid #334155;
    color: #94a3b8;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}
.filter-btn.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
}
.filter-btn:hover {
    background: #2d3b52;
}
.search-container {
    flex: 1;
    min-width: 200px;
}
.search-box {
    display: flex;
    align-items: center;
    background: #1e293b;
    border-radius: 20px;
    padding: 0.2rem 0.8rem;
    border: 1px solid #334155;
}
.search-icon {
    color: #64748b;
    margin-right: 0.5rem;
}
.search-input {
    background: transparent;
    border: none;
    color: #e2e8f0;
    padding: 0.4rem 0;
    width: 100%;
    outline: none;
}
.search-input::placeholder {
    color: #64748b;
}
.search-clear {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    font-size: 1.2rem;
    display: none;
}
.search-clear:hover {
    color: #e2e8f0;
}
.results-counter {
    color: #94a3b8;
    font-size: 0.9rem;
    white-space: nowrap;
}

/* ===== Toast поверх модалки ===== */
.toast-container {
    z-index: 99999 !important;
}

/* ===== Мобильная версия таблицы (ширина ≤ 768px) ===== */
@media (max-width: 768px) {
    /* Скрываем столбцы: Identity, Country, Deleg, Status, DP, Active Set */
    .col-identity,
    .col-country,
    .col-deleg,
    .col-status,
    .col-dp,
    .col-as {
        display: none !important;
    }
    
    /* Оставляем: #, Moniker, Perf, Stake, Saturation, Reliability, AVG-REL */
    .col-id,
    .col-moniker,
    .col-perf,
    .col-stake,
    .col-saturation,
    .col-reliability,
    .col-avg {
        display: table-cell !important;
    }
    
    /* Уменьшаем отступы и размер шрифта */
    th, td {
        padding: 0.2rem 0.2rem !important;
        font-size: 0.65rem !important;
    }
    
    /* Уменьшаем ширину столбцов */
    .col-id { width: 30px; min-width: 30px; }
    .col-moniker { 
        min-width: 60px; 
        max-width: 90px; 
        white-space: nowrap; 
        overflow: hidden; 
        text-overflow: ellipsis; 
    }
    .col-perf { width: 45px; min-width: 35px; }
    .col-stake { width: 55px; min-width: 45px; }
    .col-saturation { width: 45px; min-width: 35px; }
    .col-reliability { min-width: 55px; }
    .col-avg { width: 45px; min-width: 35px; }
    
    /* Скрываем флаг и код страны (они уже не отображаются, но на всякий случай) */
    .country-flag, .country-code { display: none !important; }
    
    /* Уменьшаем бейджи */
    .badge {
        font-size: 0.5rem !important;
        padding: 0.05rem 0.3rem !important;
    }
    
    /* Скрываем кнопку Delegate в модалке */
    .modal-action-btn.btn-delegate-modal {
        display: none !important;
    }
    
    /* Модальное окно на мобильных */
    .modal-box {
        width: 98vw;
        padding: 0.8rem 0.8rem 0.6rem;
        height: 96vh;
        border-radius: 12px;
    }
    .modal-body-grid {
        grid-template-columns: 1fr;
        gap: 0.2rem;
        padding: 0.3rem 0 0.2rem 0;
    }
    .modal-charts-row {
        grid-template-columns: 1fr;
        gap: 0.4rem;
        flex: 1;
    }
    .modal-actions-row {
        gap: 0.4rem;
        padding: 0.3rem 0 0.1rem 0;
        flex-wrap: wrap;
    }
    .modal-action-btn {
        padding: 0.3rem 0.8rem;
        font-size: 0.7rem;
        flex: 1;
        min-width: 80px;
        justify-content: center;
    }
    .modal-moniker {
        font-size: 1.1rem;
    }
    .modal-moniker-id {
        font-size: 0.9rem;
    }
    .modal-field .label {
        min-width: 70px;
        font-size: 0.65rem;
    }
    .modal-field .value {
        font-size: 0.7rem;
    }
    .modal-close {
        font-size: 1.2rem;
        top: 6px;
        right: 10px;
    }
}

/* ===== Адаптив для планшетов (ширина ≤ 1024px) ===== */
@media (max-width: 1024px) and (min-width: 769px) {
    .modal-box {
        width: 96vw;
        padding: 1.5rem 1.5rem 1.2rem;
        height: 94vh;
    }
    .modal-body-grid {
        gap: 0.8rem 1.5rem;
        padding: 0.8rem 0 0.5rem 0;
    }
    .modal-field .label {
        min-width: 100px;
        font-size: 0.75rem;
    }
    .modal-field .value {
        font-size: 0.85rem;
    }
    .modal-charts-row {
        gap: 1rem;
    }
}

/* ===== Адаптив для очень широких экранов (≥ 1600px) ===== */
@media (min-width: 1600px) {
    .modal-box {
        max-width: 1500px;
        padding: 2.2rem 3rem 1.8rem;
    }
    .modal-body-grid {
        gap: 1.8rem 4rem;
    }
    .modal-field .label {
        min-width: 180px;
        font-size: 0.95rem;
    }
    .modal-field .value {
        font-size: 1.05rem;
    }
}
.country-flag {
    font-family: 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', 'Twemoji Mozilla', sans-serif;
    font-size: 1.4rem;
    line-height: 1.2;
}