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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #10b981;
    --accent: #f59e0b;
    --danger: #ef4444;
    --dark: #1e293b;
    --gray: #64748b;
    --light: #f8fafc;
    --white: #ffffff;
    --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 5px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--dark);
    background: var(--gradient);
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 1rem 2rem 2rem;
    padding-top: max(1rem, env(safe-area-inset-top));
    position: relative;
    overflow-y: auto;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg width="60" height="60" viewBox="0 0 60 60" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><g fill="%23ffffff" fill-opacity="0.05"><path d="M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z"/></g></g></svg>');
    animation: float 20s linear infinite;
    pointer-events: none;
}

@keyframes float {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(-100px, -100px) rotate(360deg); }
}

.auth-container {
    max-width: 480px;
    width: 100%;
    position: relative;
    z-index: 1;
    animation: fadeInUp 0.6s ease;
    margin-top: 0.5rem;
}

@keyframes fadeInUp {
    0% { transform: translateY(30px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

.logo-section {
    text-align: center;
    margin-bottom: 1.5rem;
}

.logo {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.logo-text {
    font-size: 2rem;
    font-weight: bold;
    color: white;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.logo-subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.auth-card {
    background: white;
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: var(--shadow-xl);
    max-height: 85vh;
    overflow-y: auto;
}

.auth-card::-webkit-scrollbar {
    width: 8px;
}

.auth-card::-webkit-scrollbar-track {
    background: var(--light);
    border-radius: 10px;
}

.auth-card::-webkit-scrollbar-thumb {
    background: var(--gray);
    border-radius: 10px;
}

.auth-card::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

.tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    background: var(--light);
    padding: 0.5rem;
    border-radius: 12px;
}

.tab {
    flex: 1;
    padding: 0.75rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray);
    border-radius: 8px;
    transition: all 0.3s ease;
}

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

.tab.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.form-content {
    display: none;
}

.form-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--dark);
    font-size: 0.95rem;
}

.form-label .required {
    color: var(--danger);
    margin-left: 0.25rem;
}

.form-input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--light);
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
    font-family: inherit;
    background: var(--light);
}

.form-input:hover {
    border-color: #e2e8f0;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    background: white;
}

.form-input.error {
    border-color: var(--danger);
    background: #fef2f2;
}

.form-input.success {
    border-color: var(--secondary);
    background: #f0fdf4;
}

.form-input::placeholder {
    color: var(--gray);
    opacity: 0.6;
}

.password-wrapper {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--gray);
    padding: 0.5rem;
    transition: all 0.2s ease;
    border-radius: 6px;
}

.password-toggle:hover {
    background: var(--light);
    color: var(--primary);
}

.password-toggle:active {
    transform: translateY(-50%) scale(0.95);
}

.password-strength {
    margin-top: 0.75rem;
    display: none;
}

.password-strength.visible {
    display: block;
}

.strength-bar {
    height: 4px;
    background: var(--light);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.strength-fill {
    height: 100%;
    width: 0;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.strength-weak {
    background: var(--danger);
    width: 33%;
}

.strength-medium {
    background: var(--accent);
    width: 66%;
}

.strength-strong {
    background: var(--secondary);
    width: 100%;
}

.strength-text {
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.strength-requirements {
    font-size: 0.8rem;
    color: var(--gray);
    margin-top: 0.5rem;
    line-height: 1.5;
}

.strength-requirements li {
    margin-left: 1.25rem;
    margin-bottom: 0.25rem;
}

.strength-requirements li.met {
    color: var(--secondary);
}

.checkbox-group {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 0.2rem;
    accent-color: var(--primary);
}

.checkbox-label {
    font-size: 0.9rem;
    color: var(--gray);
    cursor: pointer;
    line-height: 1.5;
}

.checkbox-label a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.checkbox-label a:hover {
    text-decoration: underline;
}

.btn {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    font-family: inherit;
}

.btn-primary {
    background: var(--gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

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

.btn-loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.divider {
    display: flex;
    align-items: center;
    margin: 1.5rem 0;
    color: var(--gray);
    font-size: 0.9rem;
    font-weight: 500;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, #e2e8f0, transparent);
}

.divider span {
    padding: 0 1rem;
    white-space: nowrap;
}

.social-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.btn-social {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-social:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-social:active {
    transform: translateY(0);
}

.btn-social:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-telegram {
    background: linear-gradient(135deg, #2AABEE 0%, #229ED9 100%);
    position: relative;
    overflow: hidden;
}

.btn-telegram::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.btn-telegram:hover::before {
    left: 100%;
}

.btn-telegram:hover {
    background: linear-gradient(135deg, #229ED9 0%, #1A8CC9 100%);
}

.btn-vk {
    background: linear-gradient(135deg, #5181B8 0%, #4272A6 100%);
    position: relative;
    overflow: hidden;
}

.btn-vk::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.btn-vk:hover::before {
    left: 100%;
}

.btn-vk:hover {
    background: linear-gradient(135deg, #4272A6 0%, #3A6594 100%);
}

.social-icon {
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.social-icon svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.forgot-password {
    text-align: right;
    margin-top: 0.5rem;
}

.forgot-password a {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}

.forgot-password a:hover {
    text-decoration: underline;
}

.remember-me {
    margin-top: 1rem;
    margin-bottom: 1.5rem;
}

.back-to-home {
    text-align: center;
    margin-top: 1.5rem;
}

.back-to-home a {
    color: white;
    text-decoration: none;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.back-to-home a:hover {
    background: rgba(255, 255, 255, 0.1);
}

.success-message {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    display: none;
    animation: slideDown 0.3s ease;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

.success-message::before {
    content: '✓';
    margin-right: 0.5rem;
    font-weight: bold;
}

@keyframes slideDown {
    0% { transform: translateY(-10px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

.error-message {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    display: none;
    animation: slideDown 0.3s ease;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

.error-message:not(:empty) {
    display: block;
}

.field-error {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 0.5rem;
    display: none;
    font-weight: 500;
}

.field-error:not(:empty) {
    display: block;
}

.field-success {
    color: var(--secondary);
    font-size: 0.85rem;
    margin-top: 0.5rem;
    display: none;
    font-weight: 500;
}

.field-success::before {
    content: '✓ ';
}

.client-link {
    text-align: center;
    margin-top: 1.75rem;
    padding-top: 1.75rem;
    border-top: 1px solid var(--light);
}

.client-link a {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition-normal);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
}

.client-link a:hover {
    background: rgba(102, 126, 234, 0.1);
    color: var(--primary-dark);
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    max-width: 400px;
    width: 100%;
    box-shadow: var(--shadow-xl);
    animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
    0% { transform: scale(0.9); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray);
    padding: 0.5rem;
    line-height: 1;
    transition: all 0.2s ease;
    border-radius: 6px;
}

.modal-close:hover {
    background: var(--light);
    color: var(--dark);
}

.modal-body {
    margin-bottom: 1.5rem;
}

.modal-text {
    color: var(--gray);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.social-info {
    text-align: center;
    font-size: 0.85rem;
    color: var(--gray);
    margin-top: 1rem;
    line-height: 1.5;
    padding-bottom: 0.5rem;
}

.social-info::before {
    content: 'ℹ️ ';
    margin-right: 0.25rem;
}

.info-box {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af;
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

.info-box::before {
    content: 'ℹ️ ';
    margin-right: 0.5rem;
}

#vk-auth-container {
    display: none;
}

@media (max-width: 768px) {
    body {
        padding: 0.5rem 1rem 1rem;
    }

    .auth-card {
        padding: 1.5rem;
        max-height: 90vh;
    }

    .auth-container {
        margin-top: 0.5rem;
    }

    .logo {
        font-size: 2.5rem;
    }

    .logo-text {
        font-size: 1.5rem;
    }

    .logo-section {
        margin-bottom: 1rem;
    }

    .tabs {
        gap: 0.5rem;
    }

    .tab {
        padding: 0.625rem;
        font-size: 0.9rem;
    }

    .modal-content {
        padding: 1.5rem;
    }

    .social-info {
        font-size: 0.8rem;
    }
}

@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
}

@media (max-width: 480px) {
    body {
        padding: 0.25rem 0.5rem 0.5rem;
    }

    .auth-container {
        margin-top: 0.25rem;
    }

    .logo {
        font-size: 2rem;
    }

    .logo-section {
        margin-bottom: 0.75rem;
    }

    .auth-card {
        padding: 1.25rem;
        border-radius: 16px;
    }

    .social-buttons {
        grid-template-columns: 1fr;
    }
}

@supports (-webkit-touch-callout: none) {
    body {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
        overflow-y: auto;
    }

    .modal {
        padding-bottom: max(2rem, env(safe-area-inset-bottom));
    }
}

@media print {
    body {
        background: white;
    }

    body::before {
        display: none;
    }

    .back-to-home,
    .social-buttons,
    .divider {
        display: none;
    }
}
