* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

/* Контейнер - адаптивный */
.container {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* ============ КНОПКА АДМИНКИ ============ */
.btn-admin {
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
    padding: 8px 20px;
    border-radius: 40px;
    color: white;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(255,255,255,0.3);
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
}

.btn-admin:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.02);
}

/* ============ ГЛАВНАЯ СТРАНИЦА ============ */

/* Хедер */
header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
    margin-top: 20px;
}

header h1 {
    font-size: clamp(1.5rem, 5vw, 2rem);
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    word-break: break-word;
}

header p {
    opacity: 0.9;
    font-size: clamp(0.9rem, 4vw, 1.1rem);
}

/* Сетка прокси - адаптивная */
.proxy-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

/* Карточка прокси */
.proxy-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    transition: transform 0.2s, box-shadow 0.2s;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.proxy-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.25);
}

.proxy-name {
    font-size: 1.3rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    word-break: break-word;
}

.proxy-desc {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 12px;
    line-height: 1.4;
    word-break: break-word;
}

.proxy-details {
    margin-bottom: 16px;
}

.server {
    font-family: 'Courier New', monospace;
    background: #f5f5f5;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    color: #666;
    word-break: break-all;
    display: inline-block;
}

/* Группа кнопок - адаптивная */
.button-group {
    display: flex;
    gap: 12px;
    margin: 16px 0;
    flex-wrap: wrap;
}

/* Кнопки - адаптивные */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 40px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1;
    min-width: 140px;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, #0088cc, #006699);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0099dd, #0077aa);
    transform: scale(1.02);
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-info {
    background: linear-gradient(135deg, #34a853, #1e7e34);
    color: white;
}

.btn-info:hover {
    background: linear-gradient(135deg, #3bb85e, #228b3a);
}

.btn-danger {
    background: #dc2626;
    color: white;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-large {
    padding: 14px 28px;
    font-size: 1.1rem;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
    background: #e0e0e0;
    border: none;
    border-radius: 20px;
    cursor: pointer;
}

.page-link {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #eee;
    font-size: 0.8rem;
    color: #666;
    word-break: break-all;
}

.page-link code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    word-break: break-all;
}

/* ============ СТРАНИЦА ОТДЕЛЬНОГО ПРОКСИ ============ */

.proxy-detail-card {
    background: white;
    border-radius: 24px;
    padding: clamp(20px, 5vw, 32px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.back-link {
    display: inline-block;
    margin-bottom: 24px;
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

.back-link:hover {
    text-decoration: underline;
}

.proxy-detail-header {
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.proxy-detail-header h1 {
    font-size: clamp(1.5rem, 6vw, 2rem);
    color: #333;
    margin-bottom: 8px;
    word-break: break-word;
}

.proxy-detail-desc {
    color: #666;
    font-size: 1rem;
    line-height: 1.5;
}

.proxy-detail-info {
    background: #f8f9fa;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 28px;
}

.info-row {
    display: flex;
    padding: 10px 0;
    border-bottom: 1px solid #e9ecef;
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    width: 100px;
    font-weight: 600;
    color: #555;
    flex-shrink: 0;
}

.info-value {
    flex: 1;
    font-family: monospace;
    word-break: break-all;
    color: #333;
}

.secret-value {
    font-size: clamp(0.7rem, 3vw, 0.85rem);
}

.proxy-detail-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 32px;
}

.qr-section {
    text-align: center;
    padding-top: 24px;
    border-top: 2px solid #f0f0f0;
}

.qr-section h3 {
    margin-bottom: 12px;
    color: #333;
}

.qrcode-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.qrcode-container canvas,
.qrcode-container img {
    max-width: 100%;
    height: auto;
}

.share-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.share-link code {
    background: #f5f5f5;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: clamp(0.7rem, 3vw, 0.8rem);
    word-break: break-all;
    max-width: 100%;
    overflow-x: auto;
}

.error-page {
    text-align: center;
    background: white;
    padding: clamp(30px, 8vw, 48px);
    border-radius: 24px;
}

.error-page h1 {
    font-size: clamp(2rem, 8vw, 3rem);
    color: #dc2626;
    margin-bottom: 16px;
}

.error-page p {
    color: #666;
    margin-bottom: 24px;
    word-break: break-word;
}

/* ============ АДМИНКА ============ */

/* Хедер админки */
.admin-header {
    background: white;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.admin-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
}

.admin-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Статистика */
.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    text-align: center;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: #667eea;
}

.stat-label {
    color: #666;
    margin-top: 5px;
    font-size: 0.85rem;
}

/* Таблица для десктопа */
.desktop-table {
    background: white;
    border-radius: 16px;
    overflow-x: auto;
    display: none;
}

.desktop-table table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

.desktop-table th,
.desktop-table td {
    padding: 15px 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.desktop-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #555;
    font-size: 0.85rem;
}

/* Карточки для мобильных */
.mobile-cards {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.proxy-card-admin {
    background: white;
    border-radius: 16px;
    padding: 16px;
    transition: transform 0.2s;
}

.proxy-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.proxy-card-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    flex: 1;
}

.proxy-card-status {
    margin-left: 12px;
}

/* Переключатель статуса в карточке */
.status-toggle-card {
    width: 50px;
    height: 26px;
    background: #ddd;
    border-radius: 30px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
}

.status-toggle-card.active {
    background: #10b981;
}

.status-toggle-card::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 4px;
    transition: transform 0.2s;
}

.status-toggle-card.active::after {
    transform: translateX(24px);
}

/* Переключатель статуса в таблице */
.status-toggle {
    width: 50px;
    height: 26px;
    background: #ddd;
    border-radius: 30px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
}

.status-toggle.active {
    background: #10b981;
}

.status-toggle::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 4px;
    transition: transform 0.2s;
}

.status-toggle.active::after {
    transform: translateX(24px);
}

.proxy-card-desc {
    color: #666;
    font-size: 0.85rem;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.proxy-card-info {
    margin-bottom: 12px;
}

.proxy-card-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

/* Кнопки действий */
.action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.icon-btn {
    padding: 8px 16px;
    font-size: 0.8rem;
    background: #f0f0f0;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s;
    flex: 1;
}

.icon-btn:hover {
    background: #e0e0e0;
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 24px;
    padding: 24px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 1.2rem;
}

.close-modal {
    cursor: pointer;
    font-size: 1.5rem;
    color: #999;
}

.form-row {
    margin-bottom: 15px;
}

.form-row label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
    font-size: 0.85rem;
}

.form-row input,
.form-row textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.9rem;
}

.form-row textarea {
    resize: vertical;
    min-height: 60px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.loading-row {
    text-align: center;
    padding: 40px;
    color: #666;
    background: white;
    border-radius: 16px;
}

/* ============ ОБЩИЕ ЭЛЕМЕНТЫ ============ */

/* Футер */
footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    color: rgba(255,255,255,0.8);
    font-size: clamp(0.75rem, 3vw, 0.85rem);
}

footer code {
    background: rgba(0,0,0,0.2);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Загрузка и ошибки */
.loading, .error, .empty {
    background: white;
    padding: clamp(30px, 8vw, 40px);
    text-align: center;
    border-radius: 16px;
    color: #666;
    grid-column: 1 / -1;
}

.error {
    color: #dc2626;
}

/* Тосты */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 12px 24px;
    border-radius: 40px;
    font-size: 0.9rem;
    z-index: 1000;
    white-space: nowrap;
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ============ АДАПТАЦИЯ ПОД ТЕЛЕФОН ============ */
@media (max-width: 768px) {
    body {
        padding: 12px;
    }
    
    .container {
        padding: 0;
    }
    
    /* Кнопка админки */
    .btn-admin {
        padding: 6px 14px;
        font-size: 0.75rem;
        top: 12px;
        right: 12px;
    }
    
    /* Хедер */
    header {
        margin-top: 40px;
        margin-bottom: 24px;
    }
    
    /* Главная страница */
    .proxy-list {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .proxy-card {
        padding: 18px;
    }
    
    .proxy-name {
        font-size: 1.1rem;
    }
    
    .proxy-desc {
        font-size: 0.8rem;
    }
    
    .server {
        font-size: 0.75rem;
        padding: 3px 8px;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        padding: 12px 16px;
        min-width: unset;
        font-size: 0.85rem;
    }
    
    .page-link {
        font-size: 0.65rem;
    }
    
    .page-link code {
        font-size: 0.6rem;
    }
    
    /* Детальная страница */
    .info-row {
        flex-direction: column;
    }
    
    .info-label {
        width: auto;
        margin-bottom: 4px;
    }
    
    .share-link {
        flex-direction: column;
    }
    
    .share-link code {
        max-width: 100%;
        overflow-x: auto;
        white-space: pre-wrap;
    }
    
    /* Админка */
    .admin-header {
        flex-direction: column;
        text-align: center;
    }
    
    .admin-actions {
        width: 100%;
        flex-direction: column;
    }
    
    .admin-actions .btn {
        width: 100%;
        justify-content: center;
    }
    
    .stats {
        gap: 8px;
    }
    
    .stat-card {
        padding: 12px;
    }
    
    .stat-number {
        font-size: 1.3rem;
    }
    
    .stat-label {
        font-size: 0.7rem;
    }
    
    /* Тосты */
    .toast {
        white-space: normal;
        text-align: center;
        max-width: 90%;
        font-size: 0.8rem;
        padding: 10px 16px;
    }
    
    /* Модальное окно */
    .modal-content {
        padding: 20px;
        width: 95%;
        margin: 10px;
    }
    
    .modal-header h3 {
        font-size: 1.1rem;
    }
    
    .back-link {
        font-size: 0.9rem;
    }
    
    footer {
        margin-top: 30px;
        padding: 15px;
        font-size: 0.7rem;
    }
}

/* ============ ПЛАНШЕТЫ ============ */
@media (min-width: 769px) and (max-width: 1024px) {
    .proxy-list {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
    
    .btn {
        min-width: 120px;
    }
    
    .stats {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .mobile-cards {
        display: none;
    }
    .desktop-table {
        display: block;
    }
}

/* ============ ДЕСКТОП ============ */
@media (min-width: 769px) {
    .mobile-cards {
        display: none;
    }
    .desktop-table {
        display: block;
    }
}

/* ============ ДЕСКТОП (большие экраны) ============ */
@media (min-width: 1400px) {
    .container {
        max-width: 1400px;
    }
    
    .proxy-list {
        grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    }
}

/* ============ ОЧЕНЬ МАЛЕНЬКИЕ ЭКРАНЫ ============ */
@media (max-width: 480px) {
    .btn-admin {
        padding: 5px 12px;
        font-size: 0.7rem;
        top: 10px;
        right: 10px;
    }
    
    header {
        margin-top: 35px;
    }
    
    .proxy-name {
        font-size: 1rem;
    }
    
    .server {
        font-size: 0.7rem;
        padding: 2px 8px;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 0.75rem;
    }
    
    .proxy-detail-info {
        padding: 12px;
    }
    
    .info-value {
        font-size: 0.75rem;
    }
    
    .qr-section h3 {
        font-size: 1rem;
    }
    
    footer {
        font-size: 0.65rem;
    }
}

/* ============ АЛЬБОМНАЯ ОРИЕНТАЦИЯ НА ТЕЛЕФОНЕ ============ */
@media (max-width: 768px) and (orientation: landscape) {
    body {
        padding: 10px;
    }
    
    .btn-admin {
        top: 8px;
        right: 8px;
    }
    
    header {
        margin-top: 35px;
        margin-bottom: 15px;
    }
    
    .proxy-card {
        padding: 12px;
    }
    
    .button-group {
        flex-direction: row;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
    
    .stats {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============ ДОПОЛНИТЕЛЬНЫЕ УЛУЧШЕНИЯ ============ */

/* Для touch-устройств увеличиваем область нажатия */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .icon-btn,
    .status-toggle,
    .status-toggle-card,
    button,
    a {
        min-height: 44px;
    }
    
    .icon-btn {
        min-height: 36px;
    }
    
    .status-toggle,
    .status-toggle-card {
        min-height: 26px;
    }
}

/* Сглаживание скролла на iOS */
* {
    -webkit-tap-highlight-color: transparent;
}

/* Плавная прокрутка */
html {
    scroll-behavior: smooth;
}

/* Убираем скроллбар на телефонах где не нужно */
@media (max-width: 768px) {
    ::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }
    
    ::-webkit-scrollbar-track {
        background: #f1f1f1;
    }
    
    ::-webkit-scrollbar-thumb {
        background: #888;
        border-radius: 4px;
    }
}