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

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --secondary-color: #64748b;
    --bg-color: #f8fafc;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --card-bg: #ffffff;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #334155;
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 12px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 2em;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-muted);
}

.login-form {
    margin-top: 30px;
}

/* Sidebar */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.sidebar-header h1 {
    font-size: 1.5em;
    color: white;
}

.sidebar-close {
    display: none;
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background 0.3s;
}

.sidebar-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 8px 20px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all 0.3s;
}

.nav-item i {
    width: 20px;
    margin-right: 12px;
    text-align: center;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: white;
}

.nav-item.active {
    background: var(--primary-color);
    color: white;
}

.admin-contacts {
    margin-bottom: 40px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.contacts-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.85em;
    font-weight: 600;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.contacts-title i {
    color: #60a5fa;
}

.contact-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 0.9em;
    transition: all 0.3s;
    border: 1px solid transparent;
}

.contact-link:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: white;
    transform: translateX(3px);
}

.contact-link:last-child {
    margin-bottom: 0;
}

.contact-link i {
    font-size: 1.1em;
    width: 18px;
    text-align: center;
}

.contact-link i.fa-envelope {
    color: #60a5fa;
}

.contact-link i.fab.fa-telegram {
    color: #229ed9;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
}

.user-details {
    flex: 1;
}

.user-name {
    font-weight: 600;
    font-size: 0.9em;
}

.user-email {
    font-size: 0.8em;
    color: rgba(255, 255, 255, 0.6);
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 10px;
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border: none;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.3s;
    cursor: pointer;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.2);
    color: white;
}

.btn-logout i {
    margin-right: 8px;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 30px;
    min-height: 100vh;
}

.content-header {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.content-header h2 {
    font-size: 1.8em;
    color: var(--text-color);
    order: 2;
    margin: 0;
}

.header-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    order: 1;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5em;
    margin-right: 20px;
}

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 2em;
    font-weight: bold;
    color: var(--text-color);
    margin-bottom: 4px;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.9em;
}

/* Proxy IP Simple */
.proxy-ip-simple {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.proxy-ip-simple i {
    font-size: 1.5em;
    color: var(--primary-color);
}

.proxy-ip-simple .proxy-ip-label {
    font-weight: 600;
    color: var(--text-color);
}

.proxy-ip-simple .proxy-ip-value {
    font-family: 'Courier New', monospace;
    font-size: 1.1em;
    font-weight: bold;
    color: var(--primary-color);
    margin-left: auto;
}

.proxy-ip-country {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 12px;
    padding: 4px 10px;
    background: var(--bg-color);
    border-radius: 6px;
}

.country-flag {
    width: 20px;
    height: 15px;
    object-fit: cover;
    border-radius: 2px;
    border: 1px solid var(--border-color);
}

.country-code {
    font-size: 0.85em;
    font-weight: 600;
    color: var(--text-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.subscription-status-active {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #d1fae5;
    color: #065f46;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 500;
    margin-left: auto;
    white-space: nowrap;
}

.subscription-status-active i {
    color: #10b981;
    font-size: 0.9em;
}

.subscription-status-expired {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #fee2e2;
    color: #991b1b;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 500;
    margin-left: auto;
    white-space: nowrap;
}

.subscription-status-expired i {
    color: #ef4444;
    font-size: 0.9em;
}

/* Content Grid */
.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.content-card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-size: 1.2em;
    color: var(--text-color);
}

.card-link {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.9em;
}

.card-link:hover {
    text-decoration: underline;
}

.card-body {
    padding: 20px;
}

/* Forms */
.form {
    max-width: 600px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: var(--text-muted);
    font-size: 0.85em;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
    cursor: pointer;
}

/* Proxy IP Checkboxes */
.proxy-ip-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px;
    background: var(--bg-color);
    border-radius: 8px;
    border: 2px solid var(--border-color);
    max-height: 300px;
    overflow-y: auto;
}

.proxy-ip-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: white;
    border-radius: 6px;
    transition: all 0.2s;
    border: 1px solid var(--border-color);
}

.proxy-ip-item:hover:not(.ip-used) {
    background: #f0f9ff;
    border-color: var(--primary-color);
}

.proxy-ip-item.ip-used {
    opacity: 0.6;
    background: #f8fafc;
}

.proxy-ip-item .toggle-switch {
    margin-right: 0;
    flex-shrink: 0;
}

.proxy-ip-text {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
    font-family: 'Courier New', monospace;
    font-weight: 500;
    color: var(--text-color);
}

.ip-used-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    background: #fee2e2;
    color: #991b1b;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: 600;
    margin-left: 10px;
}

.ip-used-badge i {
    font-size: 0.9em;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 30px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s;
    gap: 8px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

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

.btn-info {
    background: #0ea5e9;
    color: white;
}

.btn-info:hover {
    background: #0284c7;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-warning:hover {
    background: #d97706;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.btn-block {
    width: 100%;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: var(--bg-color);
    color: var(--text-color);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s;
}

.btn-icon:hover {
    background: var(--primary-color);
    color: white;
}

.btn-icon.btn-danger:hover {
    background: var(--danger-color);
}

.action-buttons {
    display: flex;
    gap: 8px;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--bg-color);
}

.data-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-color);
    border-bottom: 2px solid var(--border-color);
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.data-table tbody tr:hover {
    background: var(--bg-color);
}

/* User info cell (name + email combined) */
.user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-info strong {
    color: var(--text-color);
    font-weight: 600;
}

.user-info small {
    color: var(--text-muted);
    font-size: 0.85em;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 500;
    gap: 4px;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-primary {
    background: #dbeafe;
    color: #1e40af;
}

.badge-secondary {
    background: #e2e8f0;
    color: #475569;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

/* Status badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
}

.status-badge i {
    font-size: 0.9em;
}

.status-badge .response-time {
    font-weight: 400;
    opacity: 0.8;
    font-size: 0.85em;
}

.status-badge.status-online {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.status-warning {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.status-error {
    background: #fee2e2;
    color: #991b1b;
}

.status-badge.status-offline {
    background: #f1f5f9;
    color: #64748b;
}

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-error {
    background: #fef2f2;
    border-left: 4px solid var(--danger-color);
    color: #991b1b;
}

.alert-success {
    background: #f0fdf4;
    border-left: 4px solid var(--success-color);
    color: #065f46;
}

.alert-warning {
    background: #fffbeb;
    border-left: 4px solid var(--warning-color);
    color: #92400e;
}

.alert-info {
    background: #eff6ff;
    border-left: 4px solid #0ea5e9;
    color: #1e40af;
}

.text-muted {
    color: var(--text-muted);
    text-align: center;
    padding: 40px 20px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.3s;
    font-weight: 500;
}

.tab:hover {
    color: var(--primary-color);
}

.tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* System Metrics */
.system-metrics {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.metrics-title {
    font-size: 1.2em;
    color: var(--text-color);
    margin-bottom: 20px;
    font-weight: 600;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.metric-card {
    background: var(--bg-color);
    border-radius: 8px;
    padding: 20px;
}

.metric-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    color: var(--text-color);
    font-weight: 500;
}

.metric-header i {
    font-size: 1.2em;
    color: var(--primary-color);
}

.metric-value {
    margin-bottom: 10px;
}

.metric-number {
    font-size: 2em;
    font-weight: bold;
    color: var(--text-color);
    display: block;
}

.metric-detail {
    font-size: 0.85em;
    color: var(--text-muted);
    display: block;
    margin-top: 4px;
}

.metric-bar {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.metric-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Кнопка меню (скрыта по умолчанию) */
.menu-toggle {
    display: none;
}

/* Responsive */
@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 280px;
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 1002;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close {
        display: block;
    }

    /* Затемнение фона при открытом меню */
    body.sidebar-open::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1000;
        animation: fadeIn 0.3s ease;
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
        }

        to {
            opacity: 1;
        }
    }

    .main-content {
        margin-left: 0;
        padding: 15px;
        width: 100%;
    }

    /* Кнопка меню */
    .menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        padding: 0;
        background: var(--primary-color);
        color: white;
        border: none;
        border-radius: 8px;
        cursor: pointer;
        font-size: 1.2em;
        transition: all 0.3s;
        z-index: 1001;
        position: relative;
    }

    .menu-toggle:hover {
        background: var(--primary-hover);
        transform: scale(1.05);
    }

    .menu-toggle:active {
        transform: scale(0.95);
    }

    .content-header {
        flex-direction: column;
        gap: 12px;
        position: relative;
    }

    .content-header h2 {
        font-size: 1.4em;
        order: 2;
        width: 100%;
    }

    .header-actions {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        order: 1;
        width: 100%;
    }

    .header-actions .menu-toggle {
        flex-shrink: 0;
    }

    .header-actions .btn {
        flex: 1;
        justify-content: center;
        min-width: 0;
    }

    .header-actions .btn-primary {
        flex: 1;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .stat-card {
        padding: 15px;
    }

    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 1.3em;
        margin-right: 15px;
    }

    .stat-value {
        font-size: 1.6em;
    }

    .system-metrics {
        padding: 20px 15px;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .data-table {
        font-size: 0.85em;
    }

    .data-table th,
    .data-table td {
        padding: 8px 6px;
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 30px 20px;
    }

    .main-content {
        padding: 12px;
    }

    .content-header h2 {
        font-size: 1.2em;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 12px;
    }

    .stat-icon {
        width: 45px;
        height: 45px;
        font-size: 1.2em;
        margin-right: 12px;
    }

    .stat-value {
        font-size: 1.4em;
    }

    .stat-label {
        font-size: 0.85em;
    }

    .proxy-ip-simple {
        flex-wrap: wrap;
        padding: 15px;
        gap: 10px;
    }

    .proxy-ip-simple .proxy-ip-value {
        margin-left: 0;
        width: 100%;
        text-align: left;
        padding-left: 32px;
    }

    .system-metrics {
        padding: 15px 12px;
    }

    .metrics-title {
        font-size: 1.1em;
        margin-bottom: 15px;
    }

    .metric-card {
        padding: 15px;
    }

    .metric-number {
        font-size: 1.6em;
    }

    .form-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .menu-toggle {
        width: 40px;
        height: 40px;
        font-size: 1.1em;
    }
}

/* Уведомления панели (тост) вместо браузерного alert */
@keyframes panelToastIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes panelToastOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

.panel-toast {
    font-family: inherit;
}