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

html {
    /* Стабильный скроллбар — предотвращает сдвиг при переключении вкладок */
    overflow-y: scroll;
    scrollbar-gutter: stable;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    /* Фон с изображением */
    background-color: #1e3a5f;
    background-image: url('bg-ornament.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    min-height: 100vh;
    padding: 20px;
    color: #e2e8f0;
    position: relative;
    overflow-x: hidden;
}

/* Переключение: на мобильном — карточки, на десктопе — таблица */
.subscription-nodes-mobile-wrap {
    display: none;
}
.subscription-nodes-table-wrap {
    overflow: visible;
    border: 1px solid #334155;
    border-radius: 10px;
    background: rgba(30, 41, 59, 0.55);
    max-width: 100%;
}

@media (max-width: 640px) {
    .subscription-nodes-mobile-wrap {
        display: block;
    }
    .subscription-nodes-table-wrap {
        display: none;
    }
}

/* Мобильные карточки нод — строгий вариант в цветах проекта */
.free-nodes-mobile-card {
    background: #0f172a;
    border-radius: 12px;
    padding: 14px 14px 16px;
    color: #e2e8f0;
    font-family: inherit;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.65);
    border: 1px solid #1e293b;
    margin: 12px auto;
    max-width: 100%;
}
.free-nodes-mobile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.free-nodes-mobile-card-title-wrap {
    display: flex;
    align-items: center;
}
.free-nodes-mobile-card-title {
    font-size: 15px;
    font-weight: 600;
    color: #f9fafb;
    word-break: break-word;
}
.free-nodes-mobile-card-switch {
    position: relative;
    width: 48px;
    height: 26px;
    cursor: pointer;
    flex-shrink: 0;
}
.free-nodes-mobile-card-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.free-nodes-mobile-card-slider-track {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #334155;
    border-radius: 26px;
    transition: 0.35s;
}
.free-nodes-mobile-card-slider-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: 0.35s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.free-nodes-mobile-card-switch input:checked + .free-nodes-mobile-card-slider-track {
    background-color: #16a34a;
}
.free-nodes-mobile-card-switch input:checked + .free-nodes-mobile-card-slider-track + .free-nodes-mobile-card-slider-thumb {
    transform: translateX(22px);
}
.free-nodes-mobile-card-stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    text-align: center;
}
.free-nodes-mobile-card-stat {
    min-width: 0;
}
.free-nodes-mobile-card-stat-value {
    font-size: 18px;
    font-weight: 700;
}
.free-nodes-mobile-card-stat-total {
    color: #e2e8f0;
}
.free-nodes-mobile-card-stat-paid {
    color: #f97316;
}
.free-nodes-mobile-card-stat-free {
    color: #22c55e;
}
.free-nodes-mobile-card-stat-label {
    font-size: 13px;
    color: #94a3b8;
    margin-top: 2px;
}
.free-nodes-mobile-card-stat-label-paid {
    color: #f97316;
}
.free-nodes-mobile-card-stat-label-free {
    color: #22c55e;
}

.subscription-nodes-table {
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.subscription-nodes-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(6px);
    color: #cbd5e1;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid #334155;
}

.subscription-nodes-table th,
.subscription-nodes-table td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.7);
    vertical-align: middle;
}

.subscription-nodes-table tbody tr:nth-child(odd) td {
    background: rgba(30, 41, 59, 0.25);
}

.subscription-nodes-table tbody tr:hover td {
    background: rgba(59, 130, 246, 0.10);
}

.subscription-activity-log-wrap {
    border: 1px solid #334155;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.4);
}

.subscription-activity-log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.subscription-activity-log-table thead th {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid #334155;
    background: rgba(15, 23, 42, 0.6);
    color: #cbd5e1;
    font-weight: 600;
}

.subscription-activity-log-table td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.7);
}

.subscription-activity-log-table tbody tr:nth-child(odd) td {
    background: rgba(30, 41, 59, 0.25);
}

.subscription-activity-log-table tbody tr:hover td {
    background: rgba(59, 130, 246, 0.10);
}

.subscription-nodes-table .col-toggle {
    width: 12%;
    min-width: 48px;
    max-width: 56px;
    padding-left: 8px;
    padding-right: 8px;
}

.subscription-nodes-table .col-node {
    width: 40%;
    min-width: 0;
}

.subscription-nodes-table .col-num {
    width: 16%;
    min-width: 0;
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-size: 12px;
    color: #94a3b8;
}

.subscription-node-name {
    font-weight: 600;
    font-size: 12px;
    color: #e2e8f0;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    line-height: 1.35;
}

/* Toggle switch for "free traffic" */
.switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
    vertical-align: middle;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #334155;
    transition: 0.15s ease;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.25);
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    top: 50%;
    transform: translateY(-50%);
    background: #e2e8f0;
    transition: 0.15s ease;
    border-radius: 999px;
}
.switch input:checked + .slider {
    background: rgba(34, 197, 94, 0.35);
    border-color: rgba(34, 197, 94, 0.45);
}
.switch input:checked + .slider:before {
    transform: translate(18px, -50%);
    background: #bbf7d0;
}
.switch input:focus-visible + .slider {
    outline: 2px solid rgba(96, 165, 250, 0.9);
    outline-offset: 2px;
}


/* Полная информация — мобильная модалка: всё блоками, текст по краям */
@media (max-width: 640px) {
    #subscription-details-modal .modal-body {
        padding: 16px 14px;
        width: 100%;
        box-sizing: border-box;
    }
    #subscription-details-modal .modal-body > * {
        max-width: 100%;
        box-sizing: border-box;
    }
    /* Блок карточки — каждая строка на всю ширину */
    #subscription-details-modal .card-info {
        display: block;
        width: 100%;
        margin-bottom: 16px;
        padding: 14px;
        background: rgba(30, 41, 59, 0.5);
        border: 1px solid rgba(51, 65, 85, 0.5);
        border-radius: 10px;
    }
    #subscription-details-modal .card-info-item {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
        width: 100%;
        padding: 10px 0;
        border-bottom: 1px solid rgba(51, 65, 85, 0.4);
        flex-wrap: wrap;
    }
    #subscription-details-modal .card-info-item:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }
    #subscription-details-modal .card-info-item:first-child {
        padding-top: 0;
    }
    #subscription-details-modal .card-info-label {
        font-size: 12px;
        color: #94a3b8;
        flex-shrink: 0;
    }
    #subscription-details-modal .card-info-value {
        font-size: 13px;
        text-align: right;
        word-break: break-word;
        min-width: 0;
    }
    #subscription-details-modal .card-info-item-block {
        flex-direction: column;
        align-items: stretch;
    }
    #subscription-details-modal .card-info-item-block .card-info-label {
        margin-bottom: 4px;
    }
    /* Блок трафика (usage-stats) — сетка блоков */
    #subscription-details-modal .usage-stats {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        width: 100%;
        margin-bottom: 16px;
        padding: 14px;
        background: rgba(30, 41, 59, 0.5);
        border: 1px solid rgba(51, 65, 85, 0.5);
        border-radius: 10px;
    }
    #subscription-details-modal .usage-stats-note {
        grid-column: 1 / -1;
        font-size: 11px;
        color: #94a3b8;
        margin: 0 0 4px 0;
    }
    #subscription-details-modal .usage-stat-item {
        padding: 10px;
        background: rgba(15, 23, 42, 0.4);
        border-radius: 8px;
        text-align: center;
    }
    #subscription-details-modal .usage-stat-value {
        font-size: 15px;
        font-weight: 600;
    }
    #subscription-details-modal .usage-stat-label {
        font-size: 11px;
        color: #94a3b8;
        margin-top: 2px;
    }
    /* Заголовки и подписи */
    #subscription-details-modal h3 {
        font-size: 14px;
        margin-top: 18px;
        margin-bottom: 10px;
        padding: 0;
        width: 100%;
    }
    #subscription-details-modal h3:first-child {
        margin-top: 0;
    }
    #subscription-details-modal .text-muted {
        font-size: 12px;
        margin-bottom: 12px;
        padding: 0;
        width: 100%;
    }
    /* VLESS ссылки — каждая блоком */
    #subscription-details-modal .subscription-link-item {
        margin-bottom: 16px;
        padding: 14px;
        background: rgba(30, 41, 59, 0.5);
        border: 1px solid rgba(51, 65, 85, 0.5);
        border-radius: 10px;
        width: 100%;
        box-sizing: border-box;
    }
    #subscription-details-modal .subscription-link-item .text-muted {
        margin-bottom: 8px;
    }
    #subscription-details-modal .config-box {
        font-size: 10px;
        padding: 12px;
        word-break: break-all;
        width: 100%;
        box-sizing: border-box;
    }
    #subscription-details-modal .modal-footer {
        padding: 14px 14px 18px;
    }
    #subscription-details-modal .modal-footer .form-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        justify-content: stretch;
    }
    #subscription-details-modal .modal-footer .btn {
        flex: 1;
        min-width: 120px;
        padding: 12px 14px;
        font-size: 13px;
    }
}

/* До проверки авторизации контент панели скрыт — нет «вспышки» внутренностей */
.auth-check-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #94a3b8;
}
.auth-check-overlay[hidden] {
    display: none;
}
.panel-app-hidden {
    visibility: hidden;
}
.panel-app-hidden .container {
    opacity: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: #1e293b;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    overflow: hidden;
    position: relative;
    z-index: 1;
}

/* Header */
header {
    background: #1e293b;
    border-bottom: 1px solid #334155;
    padding: 24px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 22px;
    font-weight: 600;
    color: #f8fafc;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #94a3b8;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-indicator.online {
    background: #22c55e;
}

.status-indicator.offline {
    background: #ef4444;
}

/* Panel links */
.panel-links {
    background: #0f172a;
    border-bottom: 1px solid #334155;
    padding: 16px 32px;
}

.panel-links-title {
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.panel-links-list {
    list-style: none;
    font-size: 13px;
    color: #94a3b8;
}

.panel-links-list li { margin-bottom: 2px; }

.panel-links-list a {
    color: #60a5fa;
    text-decoration: none;
}

.panel-links-list a:hover { color: #93c5fd; text-decoration: underline; }

.panel-links-list code {
    background: #334155;
    color: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

/* Tabs */
.tabs {
    display: flex;
    background: #1e293b;
    border-bottom: 1px solid #334155;
    padding: 0 32px;
}

.tab-btn {
    padding: 14px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #94a3b8;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover { color: #e2e8f0; }

.tab-btn.active {
    color: #60a5fa;
    border-bottom-color: #60a5fa;
}

/* Tab content */
.tab-content {
    display: none;
    padding: 24px 32px;
    background: #0f172a;
}

.tab-content.active { display: block; }

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: #1e293b;
    border: 1px solid #334155;
    padding: 20px;
    border-radius: 8px;
}

.stat-card h3 {
    font-size: 12px;
    font-weight: 500;
    color: #94a3b8;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #f8fafc;
}

.stat-detail {
    font-size: 13px;
    color: #64748b;
    margin-top: 4px;
}

/* Скелетоны карточек дашборда */
.stat-value-skeleton,
.stat-detail-skeleton {
    display: inline-block;
    border-radius: 4px;
    background: #334155;
    animation: skeleton-shimmer 1.2s ease-in-out infinite;
    vertical-align: middle;
}
.stat-value-skeleton {
    min-width: 3ch;
    height: 28px;
}
.stat-detail-skeleton {
    min-width: 20ch;
    height: 1.1em;
    margin-top: 4px;
}

/* Общий трафик — выпадающее меню периода */
.traffic-period-dropdown {
    position: relative;
    margin-top: 6px;
}
.traffic-period-trigger {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    font-size: 13px;
    color: #64748b;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.traffic-period-trigger:hover {
    color: #94a3b8;
    background: rgba(255,255,255,0.06);
    border-color: #475569;
}
.traffic-period-arrow {
    font-size: 10px;
    opacity: 0.8;
}
.traffic-period-menu {
    position: absolute;
    left: 0;
    top: 100%;
    margin-top: 4px;
    min-width: 140px;
    padding: 6px 0;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 100;
    display: flex;
    flex-direction: column;
}
.traffic-period-menu[hidden] {
    display: none !important;
}
.traffic-period-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    font-size: 13px;
    color: #e2e8f0;
    background: none;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
}
.traffic-period-menu button:hover {
    background: rgba(255,255,255,0.08);
}

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

.section-header-title-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: #f8fafc;
}

.subscriptions-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.subscriptions-search-wrap {
    position: relative;
    display: inline-block;
}

.subscriptions-search-input {
    min-width: 40ch;
    max-width: 40ch;
    padding: 8px 32px 8px 12px;
    border: 1px solid #475569;
    border-radius: 8px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 14px;
}

.subscriptions-search-input::placeholder {
    color: #64748b;
}

.subscriptions-search-input:focus {
    outline: none;
    border-color: #3b82f6;
}

.subscriptions-search-clear {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #64748b;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.subscriptions-search-clear:hover {
    background: #334155;
    color: #e2e8f0;
}

.header-right-wrap {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}
.panel-interval-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.panel-interval-wrap label {
    font-size: 13px;
    color: #94a3b8;
}

.panel-interval-wrap select {
    padding: 6px 10px;
    border: 1px solid #334155;
    border-radius: 6px;
    font-size: 13px;
    background: #1e293b;
    color: #e2e8f0;
}

.panel-interval-hint {
    display: block;
    margin-top: 8px;
    color: #64748b;
    font-size: 12px;
    max-width: 600px;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: #334155;
}

.select-all-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #94a3b8;
}

.select-all-separator {
    color: #64748b;
    margin: 0 4px;
}

.select-all-count {
    margin-right: 8px;
    color: #86efac;
    font-weight: 500;
}

.select-actions-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-primary {
    background: #3b82f6;
    color: #fff;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-loading {
    opacity: 0.85;
    cursor: wait;
    pointer-events: none;
}

.btn-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 4px;
}
@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

.btn-secondary {
    background: #334155;
    color: #e2e8f0;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-danger {
    background: #dc2626;
    color: #fff;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-success {
    background: #15803d;
    color: #fff;
}
.btn-success:hover {
    background: #166534;
}

.btn-warning {
    background: #ca8a04;
    color: #1c1917;
}
.btn-warning:hover {
    background: #a16207;
}

.btn-small {
    padding: 4px 10px;
    font-size: 12px;
    margin-left: 0;
}

/* Cards */
.cards-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    min-height: 120px;
}

/* Блокировка взаимодействия во время загрузки — без opacity, чтобы не моргал фон */
.content-updating {
    pointer-events: none;
}

.card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
    overflow: hidden;
}

.card:hover {
    border-color: #475569;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Неактивная подписка — матовый оверлей поверх карточки */
.card-subscription-inactive {
    position: relative;
}
.card-subscription-inactive::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    pointer-events: none;
    border-radius: 8px;
}

.card-subscription-inactive .card-header,
.card-subscription-inactive .card-actions {
    position: relative;
    z-index: 1;
}

/* Выбранная карточка подписки — зелёный акцент */
.card-subscription-selected {
    border-color: #15803d;
    box-shadow: 0 0 0 2px rgba(21, 128, 61, 0.4);
    background: linear-gradient(135deg, #1e293b 0%, rgba(21, 128, 61, 0.12) 100%);
}
.card-subscription-selected:hover {
    border-color: #166534;
    box-shadow: 0 0 0 2px rgba(22, 101, 52, 0.5);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 10px;
}

.card-header-with-order {
    align-items: center;
    gap: 10px;
}

.node-order-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #334155;
}

.node-card {
    will-change: transform;
    position: relative;
    overflow: hidden;
}
.node-card-moving {
    z-index: 2;
}
/* Лёгкий акцент после перестановки */
.node-card-flash {
    animation: nodeFlash 420ms ease-out;
}
@keyframes nodeFlash {
    0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.0); }
    40% { box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25); }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.0); }
}

/* Явная подсветка перестановки: "откуда" (синий) и "куда" (зелёный) */
.node-card::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
}

.node-card-swap-from::before {
    opacity: 1;
    background: radial-gradient(900px 240px at 50% 0%, rgba(59,130,246,0.22), rgba(59,130,246,0.05) 45%, rgba(0,0,0,0) 72%);
    animation: nodeSwapFrom 760ms ease-out forwards;
}
.node-card-swap-to::before {
    opacity: 1;
    background: radial-gradient(900px 240px at 50% 0%, rgba(34,197,94,0.24), rgba(34,197,94,0.06) 45%, rgba(0,0,0,0) 72%);
    animation: nodeSwapTo 760ms ease-out forwards;
}

.node-card-swap-from {
    animation: nodeSwapFromShadow 760ms ease-out forwards;
}
.node-card-swap-to {
    animation: nodeSwapToShadow 760ms ease-out forwards;
}

@keyframes nodeSwapFrom {
    0% { opacity: 0; filter: saturate(1.15); }
    18% { opacity: 1; }
    55% { opacity: 0.85; }
    100% { opacity: 0; }
}
@keyframes nodeSwapTo {
    0% { opacity: 0; filter: saturate(1.15); }
    18% { opacity: 1; }
    55% { opacity: 0.9; }
    100% { opacity: 0; }
}

@keyframes nodeSwapFromShadow {
    0% { box-shadow: 0 0 0 0 rgba(59,130,246,0.0), 0 0 0 0 rgba(59,130,246,0.0); }
    20% { box-shadow: 0 0 0 4px rgba(59,130,246,0.22), 0 0 18px 0 rgba(59,130,246,0.25); }
    100% { box-shadow: 0 0 0 0 rgba(59,130,246,0.0), 0 0 0 0 rgba(59,130,246,0.0); }
}
@keyframes nodeSwapToShadow {
    0% { box-shadow: 0 0 0 0 rgba(34,197,94,0.0), 0 0 0 0 rgba(34,197,94,0.0); }
    20% { box-shadow: 0 0 0 4px rgba(34,197,94,0.20), 0 0 18px 0 rgba(34,197,94,0.22); }
    100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.0), 0 0 0 0 rgba(34,197,94,0.0); }
}

.node-order-num {
    font-weight: 600;
    color: #94a3b8;
    min-width: 24px;
    text-align: center;
}

.node-order-buttons {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.btn-order {
    min-width: 32px;
    padding: 4px 8px;
    font-size: 14px;
    line-height: 1;
}

.nodes-hint {
    margin: 0 0 16px;
    padding: 10px 14px;
    background: #1e293b;
    border-radius: 8px;
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.45;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: #f8fafc;
}

.card-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
}

.badge-healthy { background: #14532d; color: #86efac; }
.badge-unhealthy { background: #7f1d1d; color: #fca5a5; }
.badge-active { background: #1e3a8a; color: #93c5fd; }
.badge-inactive { background: #334155; color: #94a3b8; }
.badge-neutral { background: #475569; color: #cbd5e1; }
.badge-master { background: #78350f; color: #fcd34d; margin-left: 6px; }

.card-info-badge {
    font-size: 12px;
    padding: 2px 8px;
}

.card-info { margin-bottom: 10px; }

.card-info-item {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid #334155;
    font-size: 13px;
}

.card-info-item:last-child { border-bottom: none; }

.card-info-label { color: #94a3b8; }
.card-info-value { color: #e2e8f0; font-weight: 500; }

.card-info-buttons {
    display: inline-flex;
    gap: 8px;
    flex-shrink: 0;
}

.suspend-expiry-badge { color: #94a3b8; font-size: 0.9em; }
.text-muted { color: #64748b; }
.card-info-hint { color: #64748b; font-size: 0.9em; margin-left: 2px; }

.node-warning-icon {
    display: inline-block;
    color: #eab308;
    margin-right: 2px;
    font-size: 14px;
}

/* Ноды в карточке подписки — каждая в своём «чипе», чтобы подчеркнуть разные ноды */
.card-info-value.card-info-nodes {
    flex: 1;
    min-width: 0;
    justify-content: flex-end;
}
.card-info-nodes {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.node-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    font-size: 12px;
    font-weight: 500;
    color: #e2e8f0;
    background: #334155;
    border: 1px solid #475569;
    border-radius: 6px;
    white-space: nowrap;
}
.node-chip-unavailable {
    background: #422;
    border-color: #644;
    color: #fca5a5;
}

.card-info-item-block {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}
.card-info-link {
    color: #60a5fa;
    text-decoration: none;
    word-break: break-all;
    font-size: 12px;
}
.card-info-link:hover {
    color: #93c5fd;
    text-decoration: underline;
}

.card-info-item .progress-bar {
    flex: 1;
    width: 100%;
}

.card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    align-items: flex-end;
    justify-content: space-between;
}

.card-actions-left {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.card-actions .card-action-delete {
    margin-left: auto;
}

.card-actions .btn {
    padding: 6px 10px;
    font-size: 12px;
}

/* Modals — тёмная тема, скролл только внутри окна */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
    overscroll-behavior: contain;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: rgb(30 41 59 / 70%);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(51, 65, 85, 0.8);
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    max-height: calc(100vh - 40px);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 0;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overscroll-behavior: contain;
    flex-shrink: 0;
    margin: auto;
}

.modal-header {
    flex-shrink: 0;
    padding: 10px 24px 0 24px;
    padding-right: 56px;
    position: relative;
    background: rgb(30 41 59 / 70%);
}

.modal-warning {
    padding: 10px 12px;
    margin-bottom: 16px;
    background: rgba(234, 179, 8, 0.15);
    border: 1px solid rgba(234, 179, 8, 0.4);
    border-radius: 8px;
    font-size: 13px;
    color: #eab308;
}

.modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    padding-right: 20px;
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
}

.modal-body::-webkit-scrollbar {
    width: 12px;
}

.modal-body::-webkit-scrollbar-track {
    background: transparent;
    margin: 12px 0;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 6px;
    border: 3px solid rgb(30 41 59 / 70%);
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

.modal-footer {
    flex-shrink: 0;
    padding: 0px 24px 10px;
    background: rgb(30 41 59);
    border-top: 1px solid rgba(51, 65, 85, 0.8);
    border-radius: 0 0 12px 12px;
}

.modal-footer .form-actions {
    margin-bottom: 0;
}

.modal-content.large {
    max-width: 640px;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: #f8fafc;
    margin: 0 0 20px 0;
    padding-right: 36px;
}

.modal-content h2 {
    font-size: 18px;
    font-weight: 600;
    color: #f8fafc;
    margin-bottom: 20px;
    padding-right: 36px;
}

.modal-header .close {
    position: absolute;
    right: 16px;
    top: 5px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #94a3b8;
    cursor: pointer;
    border-radius: 6px;
    z-index: 2;
}

.modal-header .close:hover {
    background: #334155;
    color: #e2e8f0;
}

/* Form */
.form-group {
    margin-bottom: 20px;
}

.form-group:last-of-type { margin-bottom: 0; }

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #cbd5e1;
}

.form-group small {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #64748b;
    line-height: 1.4;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group input[type="password"],
.form-group input[type="datetime-local"],
.form-group input[type="url"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #334155;
    border-radius: 6px;
    font-size: 14px;
    background: #0f172a;
    color: #e2e8f0;
}

.form-group input::placeholder {
    color: #64748b;
}

.form-group input.input-readonly,
.form-group input:disabled {
    background: #1e293b;
    color: #94a3b8;
    cursor: not-allowed;
}

.form-group input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #334155;
    border-radius: 6px;
    font-size: 14px;
    background: #0f172a;
    color: #e2e8f0;
}

.form-group .input-row {
    display: flex;
    gap: 8px;
}

.form-group .input-row input {
    flex: 1;
}

.form-group textarea {
    width: 100%;
    min-height: 80px;
    padding: 10px 12px;
    border: 1px solid #334155;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    background: #0f172a;
    color: #e2e8f0;
}

.form-group textarea:focus {
    outline: none;
    border-color: #3b82f6;
}

.checkbox-list {
    margin-top: 8px;
}

.checkbox-list .checkbox-label,
.checkbox-list .checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    cursor: pointer;
    font-size: 13px;
    color: #94a3b8;
}

.form-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.form-actions .btn-secondary { order: 1; }
.form-actions .btn-primary,
.form-actions .btn-danger { order: 2; }

/* Settings */
.settings-hint {
    color: #94a3b8;
    font-size: 13px;
    margin-bottom: 20px;
}

.settings-card {
    width: 100%;
}

.settings-card.card {
    background: #1e293b;
}

.sync-hint {
    color: #94a3b8;
    font-size: 13px;
    margin-bottom: 16px;
}

.sync-limits-hint {
    display: block;
    color: #94a3b8;
    font-size: 12px;
    margin-top: 4px;
}

.settings-subsection-title {
    font-size: 14px;
    margin: 16px 0 8px 0;
    font-weight: 600;
}

/* Бэкапы — 2x2 сетка, «Автоматические бэкапы» и «Сброс данных» одной высоты */
#backup .backup-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
#backup .backup-top-left { grid-column: 1; grid-row: 1; }
#backup .backup-top-right { grid-column: 2; grid-row: 1; }
#backup .backup-bottom-left {
    grid-column: 1;
    grid-row: 2;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
#backup .backup-bottom-left form { flex: 1; }
#backup .backup-bottom-right { grid-column: 2; grid-row: 2; min-height: 0; }
#backup .backup-list-card {
    width: 100%;
}
#backup .section-header { margin-bottom: 16px; }
#backup .section-header h2 { font-size: 18px; }
#backup .settings-card {
    padding: 14px 18px;
    margin-bottom: 12px;
}
#backup .backup-cols .settings-card { margin-bottom: 0; }
#backup .backup-list-card { margin-bottom: 0; }
#backup .settings-card h3 {
    font-size: 14px;
    margin-bottom: 10px;
}
#backup .settings-hint {
    margin-bottom: 10px;
    font-size: 12px;
}
#backup .form-group {
    margin-bottom: 12px;
}
#backup .form-group label { margin-bottom: 4px; font-size: 13px; }
#backup .form-group small {
    font-size: 11px;
    margin-top: 4px;
    line-height: 1.4;
}
#backup .form-actions { margin-top: 10px; margin-bottom: 0; }
#backup .backup-download-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
#backup .backup-download-row .settings-hint { margin-bottom: 0; flex: 1; min-width: 200px; }
#backup .backup-settings-form {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 140px;
}
#backup .backup-enabled-row { margin-bottom: 8px; }
#backup .backup-period-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}
#backup .backup-period-row > span { font-size: 13px; color: #94a3b8; }
#backup .backup-save-wrap {
    margin-top: auto;
    display: flex;
    justify-content: flex-end;
    padding-top: 12px;
}
#backup .backup-schedule-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 20px;
    align-items: flex-end;
}
#backup .backup-schedule-row .form-group { margin-bottom: 0; }
#backup .backup-schedule-row .form-group label { display: block; }
#backup .backup-schedule-row input[type="number"] { width: 56px; padding: 6px 8px; }
#backup .backup-schedule-row select { width: auto; min-width: 140px; padding: 6px 10px; }
#backup .backup-list { padding: 8px 0; }
#backup .backup-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #334155;
    font-size: 13px;
}
#backup .backup-item:last-child { border-bottom: none; }
#backup .backup-restore-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
#backup .backup-restore-row input[type="file"] { font-size: 12px; }
#backup .reset-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
}
#backup .reset-options .form-group { margin-bottom: 8px; }
#backup .reset-options .checkbox-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
}
#backup .reset-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 10px;
}
#backup .reset-actions input,
.reset-confirm-input {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 13px;
}
.reset-confirm-input {
    width: 140px;
    padding: 6px 10px;
}

/* Activity */
.recent-activity { margin-top: 32px; }

.recent-activity h2 {
    color: #f8fafc;
}

.activity-list {
    background: #1e293b;
    border-radius: 8px;
    padding: 16px;
    border: 1px solid #334155;
}

.activity-item {
    padding: 12px;
    border-left: 3px solid #3b82f6;
    background: #0f172a;
    margin-bottom: 8px;
    border-radius: 4px;
    font-size: 13px;
    color: #e2e8f0;
}

/* Скелетоны «Последние действия» — тот же размер, без дергания */
.activity-item-skeleton {
    padding: 12px;
    border-left: 3px solid #334155;
    background: #0f172a;
    margin-bottom: 8px;
    border-radius: 4px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.activity-item-skeleton .activity-time-skeleton {
    flex-shrink: 0;
    width: 140px;
    height: 14px;
    border-radius: 4px;
    background: #334155;
    animation: skeleton-shimmer 1.2s ease-in-out infinite;
}
.activity-item-skeleton .activity-text-skeleton {
    flex: 1;
    min-width: 0;
    max-width: 320px;
    height: 14px;
    border-radius: 4px;
    background: #334155;
    animation: skeleton-shimmer 1.2s ease-in-out infinite;
}

.activity-time {
    display: inline-block;
    margin-right: 8px;
    font-size: 12px;
    color: #64748b;
    min-width: 140px;
}

.activity-sub-link {
    color: #60a5fa;
    text-decoration: none;
    cursor: pointer;
}
.activity-sub-link:hover {
    color: #93c5fd;
    text-decoration: underline;
}

.activity-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #334155;
}

.pagination-info {
    font-size: 13px;
    color: #94a3b8;
}

.pagination-btns {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pagination-page {
    font-size: 13px;
    color: #94a3b8;
}

.pagination-btns button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.subscriptions-pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.subscriptions-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.subscriptions-bar-right .select-actions-wrap {
    margin-left: 0;
}

.pagination-limit-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.pagination-limit-wrap label {
    font-size: 13px;
    color: #94a3b8;
}

.pagination-limit-wrap select {
    padding: 6px 10px;
    border: 1px solid #334155;
    border-radius: 6px;
    font-size: 13px;
    background: #1e293b;
    color: #e2e8f0;
}

.subscriptions-pagination {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pagination-pages {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.pagination-pages .pagination-num {
    min-width: 32px;
    padding: 6px 8px;
}

.pagination-pages .pagination-num-active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
    cursor: default;
}

.pagination-pages .pagination-num-active:hover {
    background: #3b82f6;
    border-color: #3b82f6;
}

.pagination-ellipsis {
    padding: 0 4px;
    color: #94a3b8;
    font-size: 13px;
}

/* Config box */
.config-box {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 12px;
    font-family: 'SF Mono', 'Monaco', monospace;
    font-size: 12px;
    word-break: break-all;
    color: #94a3b8;
    margin-bottom: 12px;
}

.modal-content .config-box + .btn,
.modal-content .config-box + button {
    margin-top: 12px;
}

.usage-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.usage-stat-item {
    text-align: center;
    padding: 16px;
    background: #1e293b;
    border-radius: 6px;
    border: 1px solid #334155;
}

.usage-stat-value { font-size: 20px; font-weight: 700; color: #f8fafc; }
.usage-stat-label { font-size: 11px; color: #64748b; margin-top: 4px; }

.progress-bar {
    height: 6px;
    background: #334155;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    min-width: 4px;
    background: #3b82f6;
    border-radius: 3px;
    transition: width 0.2s;
}

/* Скелетоны карточек подписок — фиксированная ширина без дергания при загрузке */
@keyframes skeleton-shimmer {
    0%, 100% { opacity: 0.45; }
    50% { opacity: 0.75; }
}
.card-info-value-skeleton {
    display: inline-block;
    vertical-align: middle;
    border-radius: 4px;
    background: #334155;
    animation: skeleton-shimmer 1.2s ease-in-out infinite;
}
.card-info-value-skeleton-traffic {
    min-width: 17ch;
    height: 1.1em;
}
.card-info-value-skeleton-short {
    min-width: 8ch;
    height: 1.1em;
}
.card-info-value-skeleton-nodes {
    min-width: 14ch;
    height: 1.1em;
}
.progress-bar .progress-fill-skeleton {
    width: 100%;
    height: 100%;
    min-width: 0;
    background: #475569;
    border-radius: 3px;
    animation: skeleton-shimmer 1.2s ease-in-out infinite;
}

/* Скелетон всей страницы подписок при загрузке */
.subscriptions-total-skeleton {
    display: inline-block;
    min-width: 8ch;
    height: 1.2em;
    border-radius: 4px;
    background: #334155;
    animation: skeleton-shimmer 1.2s ease-in-out infinite;
    vertical-align: middle;
}

.card-skeleton {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 14px;
}
.card-skeleton .card-skeleton-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.card-skeleton .card-skeleton-title {
    width: 180px;
    height: 18px;
    border-radius: 4px;
    background: #334155;
    animation: skeleton-shimmer 1.2s ease-in-out infinite;
}
.card-skeleton .card-skeleton-badge {
    width: 56px;
    height: 20px;
    border-radius: 4px;
    background: #334155;
    animation: skeleton-shimmer 1.2s ease-in-out infinite;
}
.card-skeleton .card-skeleton-info {
    border-top: 1px solid #334155;
}
.card-skeleton .card-skeleton-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #334155;
}
.card-skeleton .card-skeleton-row:last-child {
    border-bottom: none;
}
.card-skeleton .card-skeleton-label {
    width: 80px;
    height: 12px;
    border-radius: 4px;
    background: #334155;
    animation: skeleton-shimmer 1.2s ease-in-out infinite;
}
.card-skeleton .card-skeleton-value {
    width: 140px;
    height: 14px;
    border-radius: 4px;
    background: #334155;
    animation: skeleton-shimmer 1.2s ease-in-out infinite;
}
.card-skeleton .card-skeleton-bar-wrap {
    padding: 10px 0;
    border-bottom: 1px solid #334155;
}
.card-skeleton .card-skeleton-bar {
    height: 6px;
    border-radius: 3px;
    background: #334155;
    animation: skeleton-shimmer 1.2s ease-in-out infinite;
}
.card-skeleton .card-skeleton-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    gap: 6px;
}
.card-skeleton .card-skeleton-btn {
    width: 90px;
    height: 32px;
    border-radius: 6px;
    background: #334155;
    animation: skeleton-shimmer 1.2s ease-in-out infinite;
}
.card-skeleton .card-skeleton-btn-delete {
    width: 70px;
    margin-left: auto;
}

.loading {
    text-align: center;
    padding: 48px;
    color: #64748b;
}

.error {
    background: #450a0a;
    color: #fca5a5;
    padding: 12px;
    border-radius: 6px;
    font-size: 13px;
}

.success {
    background: #052e16;
    color: #86efac;
    padding: 12px;
    border-radius: 6px;
    font-size: 13px;
}

/* Import progress and results */
.import-progress {
    margin: 20px 0;
}
.import-progress-bar {
    height: 8px;
    background: #334155;
    border-radius: 4px;
    overflow: hidden;
}
.import-progress-fill {
    height: 100%;
    background: #3b82f6;
    width: 30%;
    animation: import-progress-pulse 1.2s ease-in-out infinite;
}
@keyframes import-progress-pulse {
    0%, 100% { transform: translateX(-50%); }
    50% { transform: translateX(200%); }
}
.import-progress-text {
    margin-top: 12px;
    font-size: 14px;
    color: #94a3b8;
}
.import-results-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
    font-size: 14px;
}
.import-results-summary .summary-item {
    padding: 8px 14px;
    border-radius: 8px;
}
.import-results-summary .summary-created { background: #14532d; color: #86efac; }
.import-results-summary .summary-updated { background: #1e3a8a; color: #93c5fd; }
.import-results-summary .summary-skipped { background: #78350f; color: #fcd34d; }
.import-results-details {
    max-height: 240px;
    overflow-y: auto;
    font-size: 13px;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 12px;
}
.import-results-details .detail-group { margin-bottom: 16px; }
.import-results-details .detail-group:last-child { margin-bottom: 0; }
.import-results-details .detail-group-title { font-weight: 600; color: #94a3b8; margin-bottom: 6px; }
.import-results-details .detail-item {
    padding: 4px 0;
    font-size: 12px;
    color: #e2e8f0;
}
.import-results-details .detail-item + .detail-item { border-top: 1px solid #1e293b; }

/* Закрытие по клику на оверлей */
.modal.active .modal-content {
    pointer-events: auto;
}

.modal.active {
    overflow: hidden;
}

/* Шторка перезапуска сервиса */
.restart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(6px);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.restart-overlay .restart-box {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 32px;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}
.restart-overlay .restart-title {
    font-size: 18px;
    font-weight: 600;
    color: #f8fafc;
    margin-bottom: 16px;
}
.restart-overlay .restart-status {
    font-size: 14px;
    color: #94a3b8;
    margin-bottom: 8px;
}
.restart-overlay .restart-countdown {
    font-size: 24px;
    font-weight: 700;
    color: #38bdf8;
    margin: 16px 0 8px;
}
.restart-overlay .restart-hint {
    font-size: 12px;
    color: #64748b;
    margin-top: 16px;
}

/* ========== Адаптация под планшеты и мобильные ========== */

@media (max-width: 768px) {
    body {
        padding: 12px;
    }
    .container {
        border-radius: 10px;
    }
    header {
        padding: 16px 16px;
        flex-wrap: wrap;
        gap: 12px;
    }
    header h1 {
        font-size: 18px;
        width: 100%;
        order: 1;
    }
    .header-right-wrap {
        order: 2;
        width: 100%;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: flex-start;
    }
    .panel-interval-wrap {
        flex-wrap: wrap;
    }
    .panel-interval-wrap label {
        width: 100%;
    }
    .tabs {
        padding: 0 8px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
    .tabs::-webkit-scrollbar {
        height: 4px;
    }
    .tab-btn {
        padding: 12px 14px;
        font-size: 13px;
        white-space: nowrap;
        flex-shrink: 0;
    }
    .tab-content {
        padding: 16px 12px;
    }
    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 16px;
    }
    .section-header h2 {
        font-size: 16px;
    }
    .section-header .btn {
        width: 100%;
        max-width: 100%;
    }
    /* Подписки: тулбар и поиск */
    .section-header-title-wrap {
        flex-wrap: wrap;
        gap: 8px;
    }
    .subscriptions-toolbar {
        flex-direction: column;
        width: 100%;
    }
    .subscriptions-toolbar .btn {
        width: 100%;
    }
    .subscriptions-search-wrap {
        width: 100%;
    }
    .subscriptions-search-input {
        min-width: 0;
        max-width: 100%;
        width: 100%;
    }
    /* Пагинация подписок */
    .subscriptions-pagination-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .subscriptions-bar-right {
        margin-left: 0;
        flex-wrap: wrap;
        justify-content: space-between;
    }
    .pagination-limit-wrap {
        order: 1;
    }
    .subscriptions-pagination {
        order: 2;
        justify-content: center;
    }
    #select-actions-wrap {
        order: 3;
        width: 100%;
    }
    .select-all-label {
        order: 4;
    }
    /* Карточки — одна колонка на узких экранах */
    .cards-list {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 24px;
    }
    .stat-card {
        padding: 16px;
    }
    .stat-value {
        font-size: 24px;
    }
    /* Карточка: заголовок и действия */
    .card-header {
        flex-wrap: wrap;
        gap: 8px;
    }
    .card-header-with-order {
        flex-wrap: wrap;
    }
    .card-title {
        font-size: 14px;
        word-break: break-word;
    }
    .card-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .card-actions-left {
        width: 100%;
    }
    .card-actions .card-action-delete {
        margin-left: 0;
    }
    .card-info-item {
        flex-wrap: wrap;
        gap: 4px;
    }
    .card-info-value {
        word-break: break-all;
    }
    .node-order-row {
        flex-wrap: wrap;
        justify-content: center;
    }
    .nodes-hint {
        padding: 10px 12px;
        font-size: 12px;
    }
    /* Бэкапы */
    #backup .backup-cols {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }
    #backup .backup-top-left,
    #backup .backup-top-right,
    #backup .backup-bottom-left,
    #backup .backup-bottom-right {
        grid-column: 1;
        grid-row: auto;
    }
    #backup .backup-download-row {
        flex-direction: column;
        align-items: flex-start;
    }
    #backup .backup-download-row .settings-hint {
        min-width: 0;
    }
    #backup .backup-restore-row {
        flex-direction: column;
        align-items: flex-start;
    }
    #backup .backup-period-row {
        flex-wrap: wrap;
    }
    #backup .reset-options {
        flex-direction: column;
    }
    #backup .reset-actions {
        flex-wrap: wrap;
    }
    #backup .reset-actions input,
    .reset-confirm-input {
        width: 100%;
        max-width: 100%;
    }
    /* Модальные окна */
    .modal {
        padding: 12px;
        align-items: flex-end;
    }
    .modal-content {
        max-height: calc(100vh - 24px);
        margin: auto 0 0 0;
        border-radius: 12px 12px 0 0;
    }
    .modal-content.large {
        max-width: 100%;
    }
    .modal-header {
        padding: 12px 48px 0 16px;
    }
    .modal-header h2,
    .modal-content h2 {
        font-size: 16px;
        margin-bottom: 16px;
    }
    .modal-body {
        padding: 16px;
    }
    .modal-footer {
        padding: 12px 16px 16px;
    }
    .modal-header .close {
        right: 12px;
        top: 8px;
        width: 36px;
        height: 36px;
    }
    .form-actions {
        flex-wrap: wrap;
    }
    .form-actions .btn {
        flex: 1;
        min-width: 0;
    }
    /* Activity */
    .activity-pagination {
        flex-direction: column;
        align-items: stretch;
    }
    .activity-time {
        min-width: 100px;
    }
    .activity-item {
        font-size: 12px;
        padding: 10px;
    }
    .usage-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .config-box {
        font-size: 11px;
        padding: 10px;
    }
    /* Страница входа */
    .login-page {
        padding: 12px;
    }
    .login-box {
        padding: 24px 20px;
    }
}

/* Телефоны (узкие экраны) */
@media (max-width: 480px) {
    body {
        padding: 8px;
    }
    header {
        padding: 12px 12px;
    }
    header h1 {
        font-size: 16px;
    }
    .header-right-wrap .btn {
        padding: 6px 10px;
        font-size: 12px;
    }
    .tabs {
        padding: 0 4px;
    }
    .tab-btn {
        padding: 10px 12px;
        font-size: 12px;
    }
    .tab-content {
        padding: 12px 8px;
    }
    .section-header h2 {
        font-size: 15px;
    }
    .stat-value {
        font-size: 22px;
    }
    .stat-card {
        padding: 14px;
    }
    .card {
        padding: 12px;
    }
    .card-title {
        font-size: 13px;
    }
    .card-actions .btn {
        padding: 6px 8px;
        font-size: 11px;
    }
    .pagination-pages .pagination-num {
        min-width: 28px;
        padding: 5px 6px;
        font-size: 12px;
    }
    .modal {
        padding: 8px;
    }
    .modal-content {
        max-height: calc(100vh - 16px);
    }
    .modal-body {
        padding: 12px;
    }
    #subscription-details-modal .modal-body {
        padding: 12px 12px;
    }
    #subscription-details-modal .card-info,
    #subscription-details-modal .usage-stats,
    #subscription-details-modal .subscription-link-item {
        padding: 12px;
    }
    .subscription-nodes-table td {
        padding: 8px 12px;
    }
    .subscription-nodes-table tbody tr {
        margin-bottom: 10px;
    }
    .form-group .input-row {
        flex-direction: column;
    }
    .form-group .input-row .btn {
        width: 100%;
    }
    .traffic-period-trigger {
        font-size: 12px;
    }
    .login-page {
        padding: 8px;
    }
    .login-box {
        padding: 20px 16px;
    }
    .login-box h1 {
        font-size: 18px;
    }
}
