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

:root {
    --bg-primary: #0b0c0e;
    --bg-secondary: #1e2028;
    --bg-card: #2a2d36;
    --text-primary: #f4f4f4;
    --text-secondary: #a0a0a0;
    --accent: #5794f2;
    --success: #73bf69;
    --danger: #e24d42;
    --warning: #ffcc00;
    --border: #3e424c;
}

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

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Toast уведомления */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 15px 20px;
    border-radius: 6px;
    border-left: 4px solid var(--accent);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.info { border-left-color: var(--accent); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Страницы */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* Авторизация */
.auth-card {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 8px;
    border: 1px solid var(--border);
    max-width: 400px;
    margin: 100px auto;
}

.auth-card h1 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 24px;
    font-weight: 300;
}

.auth-card form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.auth-switch {
    text-align: center;
    margin-top: 20px;
    color: var(--text-secondary);
}

.auth-switch a {
    color: var(--accent);
    text-decoration: none;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* Дашборд */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.header h1 {
    font-size: 24px;
    font-weight: 300;
}

.logout-btn {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
}

.logout-btn:hover {
    background: var(--bg-card);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    margin-right: 8px;
}

.user-name {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 14px;
}

.telegram-btn {
    background: #0088cc;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.telegram-btn:hover {
    background: #006699;
}

.dashboard-content {
    display: grid;
    gap: 20px;
}

/* Карточки */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
}

.card h3 {
    margin-bottom: 20px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Формы */
input, textarea, button {
    font-family: inherit;
    font-size: 14px;
}

textarea{
    min-height: 50px;
    resize: vertical;
}

input, textarea {
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
}

button {
    padding: 12px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

button:hover {
    opacity: 0.9;
}

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

.divider {
    text-align: center;
    margin: 20px 0;
    color: var(--text-secondary);
    position: relative;
}

.divider::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    right: 0;
    height: 1px;
    background: var(--border);
    z-index: 1;
}

.divider::after {
    content: '';
    position: relative;
    z-index: 0;
    background: var(--bg-card);
    padding: 0 10px;
}

/* Список сайтов */
.sites-title {
    margin-bottom: 20px;
    font-weight: 500;
    color: var(--text-primary);
}

.sites-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 20px;
}

.left-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.right-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.bulk-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.bulk-actions.visible {
    opacity: 1;
}

#selected-count {
    color: var(--accent);
    font-weight: 500;
}

.sites-list {
    display: grid;
    gap: 8px;
}

.site-item {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 15px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
}

.site-item:hover {
    background: var(--bg-card);
    border-color: var(--accent);
}

.site-item.selected {
    border-color: var(--accent);
    background: rgba(87, 148, 242, 0.15);
}

.site-item.selected::before {
    content: '✓';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--accent);
    font-weight: bold;
}

.site-checkbox {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.site-info {
    min-width: 0;
    margin-left: 20px; /* Отступ для галочки selection */
}

.site-url {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.site-status {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.site-status.up { color: var(--success); }
.site-status.down { color: var(--danger); }
.site-status.unknown { color: var(--warning); }

.site-actions {
    display: flex;
    gap: 8px;
}

.site-actions button {
    padding: 6px 12px;
    font-size: 12px;
}

/* Адаптивность */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .header-actions {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .user-name {
        font-size: 13px;
    }
    
    .site-item {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
    }
    
    .site-actions {
        grid-column: 1;
        justify-content: flex-end;
    }
    
    .site-info {
        margin-left: 0;
    }
    
    .site-item.selected::before {
        left: 8px;
        top: 12px;
        transform: none;
    }
}

/* Стили для фильтра */

.filter-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    background: var(--bg-card);
    border-color: var(--accent);
}

.filter-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.filter-btn.active:hover {
    background: var(--accent);
    opacity: 0.9;
}

.filter-icon {
    font-size: 16px;
}

/* Стили для кнопки обновления */
.refresh-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.refresh-btn:hover {
    background: var(--bg-card);
    border-color: var(--accent);
}

.refresh-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.refresh-btn:disabled:hover {
    background: var(--bg-secondary);
    border-color: var(--border);
}

.refresh-icon {
    font-size: 16px;
}

/* Анимация вращения для иконки обновления */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.select-all {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 4px;
    border: 1px solid var(--border);

}

.select-all input[type="checkbox"] {
    margin: 0;
    width: 16px;
    height: 16px;
}

.select-all label {
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.select-all:hover {
    background: var(--bg-card);
}

/* Адаптивность для мобильных */
@media (max-width: 768px) {
    .sites-controls {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .left-controls {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .right-controls {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .filter-btn, .refresh-btn {
        flex: 1;
        min-width: 140px;
        justify-content: center;
    }
    
    .select-all {
        justify-content: center;
    }
}

.site-item.selected::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    background: var(--accent);
    border-radius: 5px;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3'%3E%3Cpath d='M5 13l4 4L19 7'/%3E%3C/svg%3E") center/12px no-repeat;
}

/* Анимация при выборе */
.site-item {
    transition: all 0.15s ease;
}

.site-item.selected {
    transform: translateX(2px);
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    max-width: 600px;
    width: 95%;
    max-height: 80vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    margin: 0;
    font-weight: 500;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.telegram-status {
    text-align: center;
    padding: 20px;
}

.telegram-link-section h4,
.telegram-unlink-section h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.telegram-link-section ol {
    margin: 15px 0;
    padding-left: 20px;
}

.telegram-link-section li {
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.telegram-link-section code {
    background: var(--bg-secondary);
    padding: 4px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    color: var(--accent);
    font-weight: bold;
    border: 1px solid var(--border);
}

.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    margin-top: 15px;
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-danger {
    background: var(--danger);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    margin-top: 15px;
}

.btn-danger:hover {
    opacity: 0.9;
}

.link-code-display {
    margin-top: 20px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.code-box {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
    min-width: 100%;
}

.code-box code {
    flex: 1;
    background: var(--bg-primary);
    padding: 12px 15px;
    border-radius: 6px;
    font-size: 18px;
    font-weight: bold;
    color: var(--accent);
    white-space: nowrap;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
    border: 1px solid var(--border);
    min-width: 0;
}

.copy-btn {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.copy-btn:hover {
    background: var(--accent);
    color: white;
}

.code-expires {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 10px 0 0 0;
    text-align: center;
    font-style: italic;
}

/* Адаптивность для модального окна */
@media (max-width: 768px) {
    .modal-content {
        width: 98%;
        margin: 10px;
        max-width: none;
    }
    
    .modal-header,
    .modal-body {
        padding: 15px;
    }
    
    .code-box {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .code-box code {
        font-size: 16px;
        padding: 12px;
        text-align: left;
        white-space: nowrap;
        overflow-x: auto;
    }
    
    .copy-btn {
        margin-top: 0;
        padding: 12px 20px;
        font-size: 16px;
    }
    
    .link-code-display {
        padding: 15px;
    }
}

/* Для больших экранов делаем модальное окно еще шире */
@media (min-width: 900px) {
    .modal-content {
        max-width: 650px;
        width: 90%;
    }
}