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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 28px;
    margin-bottom: 20px;
}

.auth-section {
    margin-top: 20px;
}

.auth-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

@media (max-width: 900px) {
    .auth-container {
        grid-template-columns: 1fr;
    }
}

.auth-block {
    background: rgba(255, 255, 255, 0.15);
    padding: 25px;
    border-radius: 12px;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.auth-block h2 {
    margin-bottom: 20px;
    font-size: 18px;
    text-align: center;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    padding-bottom: 10px;
}

.phone-auth-block {
    border-left: 4px solid #4CAF50;
}

.qr-auth-block {
    border-left: 4px solid #2196F3;
}

.auth-form {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

.auth-form h2 {
    margin-bottom: 20px;
    font-size: 20px;
}

main {
    padding: 30px;
}

.form-section {
    margin-bottom: 30px;
    padding-bottom: 30px;
    border-bottom: 1px solid #e0e0e0;
}

.form-section:last-child {
    border-bottom: none;
}

.form-section h2 {
    font-size: 22px;
    margin-bottom: 20px;
    color: #667eea;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
    font-family: inherit;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.keyword-input-group textarea {
    width: 100%;
    font-size: 16px;
    resize: none;
    overflow-y: auto;
    min-height: auto;
    height: auto;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.slider-container input[type="range"] {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: #e0e0e0;
    outline: none;
    -webkit-appearance: none;
}

.slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
}

.slider-container input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
}

.slider-container span {
    min-width: 50px;
    font-weight: 600;
    color: #667eea;
}

.keywords-container {
    margin-top: 15px;
}

.keywords-hint {
    margin-top: 10px;
    padding: 10px 15px;
    background: #e8f4f8;
    border-left: 4px solid #2196F3;
    border-radius: 4px;
    font-size: 13px;
    color: #333;
    line-height: 1.5;
}

.keywords-hint strong {
    color: #2196F3;
}

.keywords-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 0;
    min-height: 0;
}

.keywords-list:not(:empty) {
    margin-bottom: 15px;
}

.keyword-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #667eea;
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 14px;
}

.keyword-tag button {
    background: rgba(255, 255, 255, 0.3);
    border: none;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    transition: background 0.3s;
}

.keyword-tag button:hover {
    background: rgba(255, 255, 255, 0.5);
}

.keyword-input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.keyword-input-group textarea {
    width: 100%;
    flex: none;
}

.keyword-input-group .btn {
    width: 100%;
    align-self: stretch;
}

.form-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 30px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
    transform: translateY(-2px);
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
    transform: translateY(-2px);
}

/* Состояние загрузки кнопки */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn.loading {
    position: relative;
    color: transparent;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid currentColor;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spinner 0.6s linear infinite;
    color: inherit;
}

/* Для кнопок с белым текстом используем белый спиннер */
.btn-primary.loading::after,
.btn-secondary.loading::after,
.btn-danger.loading::after,
.btn-success.loading::after {
    border-color: #ffffff;
    border-top-color: transparent;
}

@keyframes spinner {
    to {
        transform: rotate(360deg);
    }
}

.logout-section {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 1px solid #e0e0e0;
    text-align: center;
}

.message {
    margin-top: 20px;
    padding: 15px;
    border-radius: 8px;
    display: none;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

.message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
    display: block;
}

.loading {
    opacity: 0.6;
    pointer-events: none;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        border-radius: 12px;
    }

    header {
        padding: 20px;
    }

    header h1 {
        font-size: 24px;
    }

    main {
        padding: 20px;
    }

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

    .btn {
        width: 100%;
    }
}

/* Стили для радиобаттонов */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    transition: background-color 0.3s;
}

.radio-label:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.radio-label input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #667eea;
}

.radio-label span {
    flex: 1;
    user-select: none;
}

/* Стили для QR-кода */
#qrCodeContainer {
    padding: 20px;
    background: white;
    border-radius: 8px;
    margin: 15px 0;
}

#qrCodeContainer img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#qrCodeContainer p {
    margin: 10px 0;
    color: #666;
    font-size: 14px;
}

.qr-code-container {
    text-align: center;
    margin: 20px 0;
    padding: 20px;
    background: white;
    border-radius: 12px;
    border: 2px dashed #d0d4ff;
}

.qr-countdown {
    font-size: 16px;
    font-weight: 600;
    color: #4c53c6;
    text-align: center;
    margin-bottom: 15px;
}

.qr-instructions {
    font-size: 14px;
    color: #555;
    margin-bottom: 10px;
    text-align: center;
}

.qr-warning {
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 152, 0, 0.15);
    border: 2px solid rgba(255, 152, 0, 0.4);
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.6;
}

.qr-warning p {
    margin: 5px 0;
    color: #fff;
}

.qr-warning strong {
    font-weight: 600;
}

.qr-help {
    font-size: 12px;
    opacity: 0.9;
    margin-top: 10px;
    font-style: italic;
}

#qrDisplayArea {
    margin-top: 15px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #999 !important;
}

