/* ===== Стили для таблицы (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-img {
    width: 20px;
    height: auto;
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    vertical-align: middle;
    margin-right: 0.3rem;
}
.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;
}
.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;
}

/* ===== Единый стиль для всех числовых значений в таблице (десктоп) ===== */
.perf-value,
.stake-value,
.saturation-value,
.as-value,
.avg-value {
    font-weight: 500;
    font-size: 1rem;
    color: #e2e8f0;
}

/* ============================================================= */
/* ===== ШИРОКОЕ МОДАЛЬНОЕ ОКНО ===== */
/* ============================================================= */

.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: 2rem;
    cursor: pointer;
    color: #e2e8f0;
    transition: color 0.2s, transform 0.2s, background 0.2s;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    line-height: 1;
    z-index: 1001;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
.modal-close:hover {
    color: #f1f5f9;
    transform: rotate(90deg);
    background: rgba(0, 0, 0, 0.6);
}
.modal-close:active {
    transform: scale(0.9);
}

/* ===== Заголовок ===== */
.modal-header-center {
    text-align: center;
    padding-bottom: 0.8rem;
    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;
}

/* ===== Детали (2 колонки) ===== */
.modal-body-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem 2rem;
    padding: 0.8rem 0 0.5rem 0;
    flex-shrink: 0;
}
.modal-field {
    display: flex;
    align-items: center;
    padding: 0.2rem 0;
    border-bottom: 1px solid rgba(45, 59, 82, 0.3);
}
.modal-field:last-child {
    border-bottom: none;
}
.modal-field .label {
    color: #94a3b8;
    font-weight: 400;
    font-size: 0.75rem;
    min-width: 110px;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.modal-field .value {
    color: #e2e8f0;
    font-weight: 500;
    font-size: 0.85rem;
    word-break: break-all;
    flex: 1;
}
.modal-field .value.identity-full {
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    background: #0f172a;
    padding: 0.1rem 0.5rem;
    border-radius: 6px;
    word-break: break-all;
}
.saturation-bar-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}
.saturation-bar-track {
    flex: 1;
    height: 6px;
    background: #2d3b52;
    border-radius: 10px;
    overflow: hidden;
    min-width: 60px;
}
.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.8rem;
    min-width: 45px;
    text-align: right;
    color: #e2e8f0;
}
.modal-badge {
    display: inline-block;
    padding: 0.05rem 0.6rem;
    border-radius: 20px;
    font-size: 0.7rem;
    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;
}

/* ===== Графики: Reliability + Performance (2 колонки) ===== */
.modal-charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    flex: 0 1 auto;
    min-height: 0;
    margin-top: 0.3rem;
}

/* ===== Блок Rewards (отдельная строка) ===== */
.modal-rewards-section {
    flex-shrink: 0;
    margin-top: 0.3rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.modal-rewards-section .modal-chart-box {
    min-height: 100px;
    max-height: 160px;
}

/* ===== Общий контейнер графика ===== */
.modal-chart-box {
    background: #0f172a;
    border-radius: 14px;
    padding: 0.5rem 0.6rem 0.3rem;
    border: 1px solid #2d3b52;
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}
.modal-chart-box h4 {
    color: #94a3b8;
    font-weight: 400;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.15rem;
    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%;
}

/* ===== Rewards: заголовок и статистика ===== */
.rewards-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.rewards-header h4 {
    color: #94a3b8;
    font-weight: 400;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}
.rewards-period-buttons {
    display: flex;
    gap: 0.3rem;
}
.rewards-period-btn {
    background: #1e293b;
    border: 1px solid #334155;
    color: #94a3b8;
    padding: 0.05rem 0.5rem;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.55rem;
    transition: all 0.2s;
}
.rewards-period-btn:hover {
    background: #2d3b52;
    color: #e2e8f0;
}
.rewards-period-btn.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
}
.rewards-stats {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    padding: 0.1rem 0;
}
.rewards-stat-item {
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
}
.rewards-stat-label {
    font-size: 0.5rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.rewards-stat-value {
    font-size: 0.75rem;
    font-weight: 600;
}
.rewards-stat-value.total { color: #e2e8f0; }
.rewards-stat-value.operator { color: #4ade80; }
.rewards-stat-value.delegators { color: #60a5fa; }

/* ===== Кнопки действий ===== */
.modal-actions-row {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 0.6rem 0 0.1rem 0;
    border-top: 1px solid #2d3b52;
    flex-shrink: 0;
    flex-wrap: wrap;
}
.modal-action-btn {
    padding: 0.4rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.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);
}

/* ============================================================= */
/* ===== Глобальный спинер ===== */
/* ============================================================= */
#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) {
    /* ===== Таблица: скрываем второстепенные столбцы ===== */
    .col-identity,
    .col-country,
    .col-deleg,
    .col-status,
    .col-dp,
    .col-as {
        display: none !important;
    }
    .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.6rem !important;
    }
    .col-id { width: 30px; min-width: 30px; }
    .col-moniker { min-width: 60px; max-width: 80px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .col-perf { width: 40px; min-width: 30px; }
    .col-stake { width: 50px; min-width: 40px; }
    .col-saturation { width: 40px; min-width: 30px; }
    .col-reliability { min-width: 50px; }
    .col-avg { width: 40px; min-width: 30px; }

    .country-code { display: none !important; }
    .badge {
        font-size: 0.45rem !important;
        padding: 0.05rem 0.25rem !important;
    }
    .perf-value,
    .stake-value,
    .saturation-value,
    .as-value,
    .avg-value,
    .node-name,
    .node-id,
    .badge {
        font-size: 0.55rem !important;
        font-weight: 500 !important;
    }

    /* ===== Модальное окно на мобильных ===== */
    .modal-box {
        width: 98vw;
        padding: 0.6rem 0.6rem 0.4rem;
        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;
    }
    .modal-rewards-section .modal-chart-box {
        min-height: 80px;
        max-height: 120px;
    }
    .modal-chart-box {
        padding: 0.3rem 0.4rem 0.2rem;
    }
    .modal-chart-box h4 {
        font-size: 0.55rem;
    }
    .modal-close {
        top: 8px;
        right: 8px;
        font-size: 1.4rem;
        width: 34px;
        height: 34px;
        background: rgba(0, 0, 0, 0.6);
        border: 1px solid rgba(255, 255, 255, 0.15);
    }
    .modal-actions-row {
        gap: 0.4rem;
        padding: 0.3rem 0 0.1rem 0;
    }
    .modal-action-btn {
        padding: 0.25rem 0.8rem;
        font-size: 0.65rem;
        flex: 1;
        min-width: 60px;
        justify-content: center;
    }
    .modal-action-btn.btn-delegate-modal {
        display: none !important;
    }
    .modal-moniker {
        font-size: 1.1rem;
    }
    .modal-moniker-id {
        font-size: 0.8rem;
    }
    .modal-field .label {
        min-width: 60px;
        font-size: 0.6rem;
    }
    .modal-field .value {
        font-size: 0.65rem;
    }
    .rewards-header h4 {
        font-size: 0.55rem;
    }
    .rewards-period-btn {
        font-size: 0.5rem;
        padding: 0.05rem 0.4rem;
    }
    .rewards-stat-value {
        font-size: 0.65rem;
    }
    .rewards-stat-label {
        font-size: 0.45rem;
    }
}

/* ===== Адаптив для планшетов (769–1024px) ===== */
@media (max-width: 1024px) and (min-width: 769px) {
    .modal-box {
        width: 96vw;
        padding: 1.2rem 1.2rem 1rem;
        height: 94vh;
    }
    .modal-body-grid {
        gap: 0.5rem 1.5rem;
        padding: 0.5rem 0 0.3rem 0;
    }
    .modal-field .label {
        min-width: 90px;
        font-size: 0.7rem;
    }
    .modal-field .value {
        font-size: 0.8rem;
    }
    .modal-chart-box {
        padding: 0.4rem 0.5rem 0.2rem;
    }
    .modal-rewards-section .modal-chart-box {
        min-height: 100px;
        max-height: 140px;
    }
}

/* ===== Адаптив для широких экранов (≥1600px) ===== */
@media (min-width: 1600px) {
    .modal-box {
        max-width: 1500px;
        padding: 2rem 2.5rem 1.5rem;
    }
    .modal-body-grid {
        gap: 1rem 3rem;
        padding: 1rem 0 0.5rem 0;
    }
    .modal-field .label {
        min-width: 160px;
        font-size: 0.85rem;
    }
    .modal-field .value {
        font-size: 0.95rem;
    }
    .modal-rewards-section .modal-chart-box {
        min-height: 140px;
        max-height: 200px;
    }
}