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

html {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow-x: hidden;
}

/* Plexus / AI-style фон */
.auth-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.auth-bg-gradient {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 15% 10%, rgba(59, 130, 246, 0.28) 0%, transparent 55%),
        radial-gradient(ellipse 60% 45% at 88% 15%, rgba(16, 185, 129, 0.2) 0%, transparent 50%),
        radial-gradient(ellipse 50% 40% at 50% 95%, rgba(99, 102, 241, 0.12) 0%, transparent 45%),
        linear-gradient(155deg, #c5d0e0 0%, #b8c8dc 42%, #d0dae8 100%);
}

[data-theme="light"] .auth-bg-gradient {
    background:
        radial-gradient(ellipse 80% 50% at 15% 10%, rgba(59, 130, 246, 0.28) 0%, transparent 55%),
        radial-gradient(ellipse 60% 45% at 88% 15%, rgba(16, 185, 129, 0.2) 0%, transparent 50%),
        radial-gradient(ellipse 50% 40% at 50% 95%, rgba(99, 102, 241, 0.12) 0%, transparent 45%),
        linear-gradient(155deg, #c5d0e0 0%, #b8c8dc 42%, #d0dae8 100%);
}

[data-theme="dark"] .auth-bg-gradient {
    background:
        radial-gradient(ellipse 70% 45% at 10% 8%, rgba(59, 130, 246, 0.22) 0%, transparent 55%),
        radial-gradient(ellipse 55% 40% at 92% 12%, rgba(16, 185, 129, 0.14) 0%, transparent 50%),
        linear-gradient(160deg, #020617 0%, #0f172a 45%, #0c1222 100%);
}

[data-theme="light"] .auth-bg-plexus {
    opacity: 0.82;
}

body.auth-page,
body.landing-page,
body.page-with-bg {
    background: #c8d4e4;
}

[data-theme="dark"] body.auth-page,
[data-theme="dark"] body.landing-page,
[data-theme="dark"] body.page-with-bg {
    color: #e2e8f0;
    background: #01040f;
}

.auth-bg-plexus {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.auth-container {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    width: 100%;
    max-width: 420px;
}

.auth-container.auth-register-active {
    max-width: 480px;
}

.reg-map-group {
    margin-bottom: 20px;
}

.reg-map-hint {
    margin-bottom: 8px;
}

.reg-map-picker-wrap {
    position: relative;
}

.reg-map-picker {
    width: 100%;
    height: 200px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #d1d5db;
    background: #e5e7eb;
}

.reg-map-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-top: 8px;
}

.reg-map-coords {
    font-size: 0.75rem;
    color: #6b7280;
    font-variant-numeric: tabular-nums;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8125rem;
}

[data-theme="dark"] .reg-map-picker {
    border-color: rgba(148, 163, 184, 0.35);
    background: #1e293b;
}

[data-theme="dark"] .reg-map-coords {
    color: #94a3b8;
}

.auth-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    width: 100%;
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    color: white;
}

.auth-header h1 {
    font-size: 1.75rem;
    color: #1f2937;
    margin-bottom: 8px;
}

.auth-subtitle {
    color: #6b7280;
    font-size: 0.875rem;
}

.auth-form {
    display: none;
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.auth-form h2 {
    font-size: 1.25rem;
    color: #374151;
    margin-bottom: 24px;
    text-align: center;
}

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

.form-group-inline {
    margin-bottom: 12px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    color: #4b5563;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 8px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

/* Иконка слева (только прямой потомок, не внутри кнопки) */
.input-wrapper > svg {
    position: absolute;
    left: 14px;
    color: #9ca3af;
    pointer-events: none;
    z-index: 1;
}

.input-wrapper input {
    width: 100%;
    padding: 14px 14px 14px 46px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.2s;
    background: #f9fafb;
}

/* Поля с кнопкой показа пароля */
.input-wrapper.has-toggle input {
    padding-right: 50px;
}

.input-wrapper input:focus {
    outline: none;
    border-color: #3b82f6;
    background: white;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.input-wrapper input::placeholder {
    color: #9ca3af;
}

/* Кнопка показа/скрытия пароля */
.toggle-password {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    z-index: 2;
}

.toggle-password svg {
    width: 18px;
    height: 18px;
}

.toggle-password:hover {
    color: #6b7280;
}

.hint {
    display: block;
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 6px;
}

.btn-primary {
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s;
    margin-top: 8px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.4);
}

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

.btn-secondary {
    padding: 8px 14px;
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.btn-secondary:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

[data-theme="dark"] .btn-secondary {
    background: rgba(30, 41, 59, 0.9);
    color: #e2e8f0;
    border-color: rgba(148, 163, 184, 0.35);
}

[data-theme="dark"] .btn-secondary:hover {
    background: rgba(51, 65, 85, 0.95);
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid #e5e7eb;
}

.auth-footer p {
    color: #6b7280;
    font-size: 0.875rem;
}

.auth-footer a {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 500;
}

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

.auth-license {
    margin-top: 16px;
    font-size: 0.75rem;
    color: #9ca3af;
}

.auth-message {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
    display: none;
}

.auth-message.error {
    display: block;
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.auth-message.success {
    display: block;
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

.auth-info {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 20px 24px;
    color: white;
    width: 100%;
}

.auth-info h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.8;
    margin-bottom: 12px;
}

.auth-info p {
    font-size: 0.875rem;
    opacity: 0.9;
    margin-bottom: 12px;
}

.demo-credentials {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.credential {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 14px;
    border-radius: 8px;
}

.credential .role {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    text-transform: uppercase;
}

.credential .role.admin {
    background: #f59e0b;
    color: #1f2937;
}

.credential .role.user {
    background: #22c55e;
    color: white;
}

.credential code {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.875rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px 10px;
    border-radius: 6px;
}

[data-theme="dark"] .auth-card {
    background: rgba(10, 18, 34, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.22);
    box-shadow: 0 24px 70px rgba(2, 6, 23, 0.75);
}

[data-theme="dark"] .auth-header h1,
[data-theme="dark"] .auth-form h2,
[data-theme="dark"] .form-group label {
    color: #f1f5f9;
}

[data-theme="dark"] .auth-subtitle,
[data-theme="dark"] .checkbox-label,
[data-theme="dark"] .hint,
[data-theme="dark"] .auth-footer p,
[data-theme="dark"] .auth-footer a {
    color: #94a3b8;
}

[data-theme="dark"] .auth-footer {
    border-top-color: #334155;
}

[data-theme="dark"] .input-wrapper > svg,
[data-theme="dark"] .toggle-password {
    color: #64748b;
}

[data-theme="dark"] .input-wrapper input {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

[data-theme="dark"] .input-wrapper input::placeholder {
    color: #64748b;
}

[data-theme="dark"] .input-wrapper input:focus {
    background: #111b31;
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.22);
}

[data-theme="dark"] .auth-message.error {
    color: #fecaca;
    background: rgba(127, 29, 29, 0.3);
    border-color: rgba(248, 113, 113, 0.35);
}

[data-theme="dark"] .auth-message.success {
    color: #bbf7d0;
    background: rgba(20, 83, 45, 0.32);
    border-color: rgba(74, 222, 128, 0.35);
}

/* ==================== Мобильные: auth, pricing, checkout, site-admin ==================== */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

@media (max-width: 640px) {
    body {
        padding: max(12px, env(safe-area-inset-top, 0px)) max(14px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(14px, env(safe-area-inset-left, 0px));
        min-height: 100dvh;
        min-height: 100svh;
    }

    body.auth-page {
        align-items: center;
        align-items: safe center;
        justify-content: center;
    }

    .auth-container {
        gap: 16px;
        max-width: 100%;
        width: 100%;
        margin: 0 auto;
    }

    .auth-card {
        padding: 22px 18px;
        border-radius: 14px;
    }

    .auth-header {
        margin-bottom: 20px;
    }

    .auth-header h1 {
        font-size: 1.45rem;
    }

    .auth-logo {
        width: 68px;
        height: 68px;
    }

    .auth-logo svg {
        width: 38px;
        height: 38px;
    }

    .auth-form h2 {
        font-size: 1.1rem;
        margin-bottom: 18px;
    }

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

    .input-wrapper input {
        font-size: 16px;
        min-height: 48px;
        padding-top: 14px;
        padding-bottom: 14px;
    }

    .toggle-password {
        min-width: 44px;
        min-height: 44px;
        padding: 10px;
    }

    .btn-primary {
        min-height: 50px;
        padding: 16px 20px;
        font-size: 1rem;
        touch-action: manipulation;
    }

    .auth-form-actions .btn-secondary,
    .auth-form-actions .auth-form-back {
        min-height: 48px;
        padding: 14px 20px;
        font-size: 1rem;
        touch-action: manipulation;
    }

    .auth-footer {
        margin-top: 18px;
        padding-top: 18px;
    }

    .auth-info {
        padding: 14px 16px;
    }
}

@media (max-width: 400px) {
    .auth-card {
        padding: 18px 14px;
    }

    .auth-header h1 {
        font-size: 1.3rem;
    }
}

.auth-captcha-wrap {
    display: flex;
    justify-content: center;
    margin: 4px 0 8px;
}

.auth-captcha-widget {
    min-height: 65px;
}

.auth-form-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.auth-form-actions .btn-primary {
    margin-top: 0;
}

.auth-form-actions .btn-secondary,
.auth-form-actions .auth-form-back {
    width: 100%;
    padding: 12px 24px;
    font-size: 0.9375rem;
    font-weight: 500;
    border-radius: 10px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-totp-form .hint {
    margin-bottom: 14px;
    font-size: 0.875rem;
    color: #64748b;
    line-height: 1.45;
}

[data-theme="dark"] .auth-totp-form .hint {
    color: #94a3b8;
}
