:root {
    --brand-start: #4A22C7;
    --brand-end: #8B5CF6;
    --brand-solid: #673DE6;
    --bg: #f4f5ff;
    --bg-blob-1: rgba(103, 61, 230, 0.28);
    --bg-blob-2: rgba(139, 92, 246, 0.22);
    --card-bg: rgba(255, 255, 255, 0.72);
    --card-border: rgba(255, 255, 255, 0.6);
    --text-main: #1b1830;
    --text-muted: #6b6980;
    --input-bg: rgba(255, 255, 255, 0.9);
    --input-border: #e0dff0;
    --input-border-focus: var(--brand-solid);
    --error-bg: rgba(220, 53, 69, 0.1);
    --error-fg: #c0392b;
    --shadow-card: 0 24px 60px rgba(38, 22, 90, 0.16), 0 4px 14px rgba(38, 22, 90, 0.08);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f0e1a;
        --bg-blob-1: rgba(139, 92, 246, 0.35);
        --bg-blob-2: rgba(74, 34, 199, 0.35);
        --card-bg: rgba(28, 26, 43, 0.78);
        --card-border: rgba(255, 255, 255, 0.08);
        --text-main: #f2f1fa;
        --text-muted: #a6a3bf;
        --input-bg: rgba(255, 255, 255, 0.06);
        --input-border: rgba(255, 255, 255, 0.12);
        --error-bg: rgba(220, 53, 69, 0.16);
        --error-fg: #ff8a80;
        --shadow-card: 0 24px 60px rgba(0, 0, 0, 0.45), 0 4px 14px rgba(0, 0, 0, 0.3);
    }
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
}

body {
    margin: 0;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    color: var(--text-main);
    font-family: "DM Sans", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    overflow-x: hidden;
    position: relative;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    -webkit-tap-highlight-color: transparent;
}

/* Fondo: blobs difuminados que flotan lentamente */
.bg-blob {
    position: fixed;
    border-radius: 50%;
    filter: blur(70px);
    z-index: 0;
    pointer-events: none;
}

.bg-blob--1 {
    width: 420px;
    height: 420px;
    top: -120px;
    left: -100px;
    background: var(--bg-blob-1);
    animation: float-a 16s ease-in-out infinite;
}

.bg-blob--2 {
    width: 380px;
    height: 380px;
    bottom: -140px;
    right: -110px;
    background: var(--bg-blob-2);
    animation: float-b 18s ease-in-out infinite;
}

@keyframes float-a {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(40px, 30px) scale(1.08); }
}

@keyframes float-b {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-30px, -40px) scale(1.1); }
}

@media (prefers-reduced-motion: reduce) {
    .bg-blob { animation: none; }
}

.login-wrap {
    width: 100%;
    max-width: 420px;
    padding: 24px;
    position: relative;
    z-index: 1;
}

.brand-mark {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 22px;
}

.brand-mark img {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    box-shadow: 0 10px 24px rgba(74, 34, 199, 0.35);
}

.brand-mark span {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.02em;
    color: var(--text-muted);
}

.login-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-radius: 24px;
    padding: 34px 28px;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
}

.login-card h1 {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 4px;
    text-align: center;
    color: var(--text-main);
}

.login-card .subtitle {
    text-align: center;
    font-size: 13.5px;
    color: var(--text-muted);
    margin: 0 0 26px;
}

.field {
    position: relative;
    margin-bottom: 16px;
}

.field label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    padding-left: 2px;
}

.field-control {
    position: relative;
    display: flex;
    align-items: center;
}

.field-control svg {
    position: absolute;
    left: 14px;
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.field input {
    width: 100%;
    padding: 13px 14px 13px 42px;
    border: 1.5px solid var(--input-border);
    border-radius: 12px;
    background: var(--input-bg);
    color: var(--text-main);
    font-size: 15.5px;
    font-family: inherit;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.field input::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.field input:focus {
    outline: none;
    border-color: var(--input-border-focus);
    box-shadow: 0 0 0 4px rgba(103, 61, 230, 0.15);
}

.field input:-webkit-autofill {
    -webkit-text-fill-color: var(--text-main);
    transition: background-color 9999s ease-in-out 0s;
}

.field.password input {
    padding-right: 42px;
}

.toggle-password {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    border-radius: 8px;
}

.toggle-password:hover {
    color: var(--brand-solid);
}

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

.submit-btn {
    position: relative;
    margin-top: 10px;
    padding: 14px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--brand-start), var(--brand-end));
    color: #fff;
    font-size: 15.5px;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 10px 24px rgba(74, 34, 199, 0.35);
    transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

.submit-btn:hover {
    box-shadow: 0 14px 30px rgba(74, 34, 199, 0.42);
}

.submit-btn:active {
    transform: translateY(1px) scale(0.99);
}

.submit-btn:disabled {
    opacity: 0.75;
    cursor: progress;
}

.spinner {
    width: 17px;
    height: 17px;
    border: 2.5px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: none;
}

.submit-btn.loading .spinner {
    display: inline-block;
}

.submit-btn.loading .btn-text {
    opacity: 0.85;
}

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

.mensaje {
    margin: 14px 0 0;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--error-bg);
    color: var(--error-fg);
    font-size: 13.5px;
    text-align: center;
    line-height: 1.4;
    display: none;
}

.mensaje.visible {
    display: block;
}

.mensaje.shake {
    animation: shake 0.4s ease;
}

@keyframes shake {
    10%, 90% { transform: translateX(-1px); }
    20%, 80% { transform: translateX(2px); }
    30%, 50%, 70% { transform: translateX(-4px); }
    40%, 60% { transform: translateX(4px); }
}

.install-banner {
    display: none;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    padding: 11px 14px;
    border-radius: 12px;
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    font-size: 13px;
    color: var(--text-main);
}

.install-banner.visible {
    display: flex;
}

.install-banner svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--brand-solid);
}

.install-banner button {
    margin-left: auto;
    border: none;
    background: var(--brand-solid);
    color: #fff;
    font-size: 12.5px;
    font-weight: 700;
    padding: 7px 12px;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
}

.footer-note {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 22px;
    opacity: 0.8;
}

@media (max-width: 380px) {
    .login-card {
        padding: 28px 20px;
        border-radius: 20px;
    }
}
