:root {
    --mw-panel: rgba(255, 255, 255, 0.88);
    --mw-border: #c9d5e6;
    --mw-title: #1c3560;
    --mw-text: #2a3f63;
    --mw-muted: #5b6f91;
    --mw-primary: #355fa5;
    --mw-primary-hover: #2a4e87;
    --mw-focus: rgba(53, 95, 165, 0.25);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: "Segoe UI", "Open Sans", Arial, sans-serif;
    color: var(--mw-text);
}

.mw-body {
    min-height: 100vh;
    background-color: #cfdced;
    background-image:
        linear-gradient(rgba(240, 246, 255, 0.38), rgba(240, 246, 255, 0.38)),
        var(--mw-bg-image);
    background-position: center top;
    background-size: 118%;
    background-repeat: no-repeat;
}

.mw-root {
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 48px 12px 24px;
}

#kc-card {
    width: 100%;
    max-width: 420px;
    background: var(--mw-panel);
    border: 1px solid var(--mw-border);
    border-radius: 14px;
    box-shadow: 0 22px 52px rgba(17, 35, 62, 0.25);
    padding: 18px;
    backdrop-filter: blur(1px);
}

/* Force single-column layout even if upstream Keycloak/base styles add floats */
#kc-content,
#kc-content-wrapper,
#kc-form,
#kc-form-wrapper {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    float: none !important;
}

.mw-brand {
    text-align: center;
    margin-bottom: 10px;
}

.mw-brand img {
    width: min(290px, 88%);
    height: auto;
}

.mw-locale {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.mw-locale-dropdown {
    position: relative;
}

#kc-current-locale-link {
    color: var(--mw-muted);
    font-size: 14px;
    text-decoration: none;
}

#kc-locale-dropdown ul {
    list-style: none;
    margin: 6px 0 0;
    padding: 6px 0;
    display: none;
    position: absolute;
    right: 0;
    min-width: 120px;
    background: #fff;
    border: 1px solid var(--mw-border);
    border-radius: 8px;
    z-index: 10;
}

#kc-locale-dropdown:hover ul {
    display: block;
}

#kc-locale-dropdown li {
    margin: 0;
    padding: 0;
}

#kc-locale-dropdown li a {
    display: block;
    padding: 6px 10px;
    text-decoration: none;
    color: var(--mw-text);
}

#kc-locale-dropdown li a:hover {
    background: #eef4ff;
}

.mw-header {
    margin-bottom: 12px;
}

#kc-page-title {
    margin: 0;
    font-size: 30px;
    line-height: 1.15;
    text-align: center;
    color: var(--mw-title);
}

.mw-required {
    margin: 0 0 8px;
    font-size: 13px;
    color: var(--mw-muted);
}

.mw-user-banner {
    margin: 0 0 10px;
    padding: 10px 12px;
    border: 1px solid var(--mw-border);
    background: #edf3fb;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.mw-content {
    width: 100%;
}

.mw-alert {
    margin: 0 0 12px;
    border: 1px solid;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
}

.mw-alert-error {
    border-color: #d34f4f;
    background: #fff2f2;
    color: #8f2424;
}

.mw-alert-warning {
    border-color: #d8b14a;
    background: #fff8e8;
    color: #7c5710;
}

.mw-alert-success {
    border-color: #4da26a;
    background: #eefaf0;
    color: #235f37;
}

.mw-alert-info {
    border-color: #5d89cc;
    background: #eef4ff;
    color: #234f92;
}

.mw-form {
    display: grid;
    gap: 12px;
}

.mw-section-title {
    margin: 0;
    padding: 0 0 8px;
    border-bottom: 1px solid var(--mw-border);
    font-size: 17px;
    color: #2f4a74;
}

.mw-form-row {
    display: grid;
    gap: 6px;
}

.mw-form-row label {
    font-size: 15px;
    color: #4e6387;
}

#kc-form-login input[type="text"],
#kc-form-login input[type="password"],
#kc-sms-code-login-form input[type="text"] {
    width: 100%;
    height: 38px;
    padding: 6px 9px;
    border: 1px solid #9fb4d5;
    border-radius: 8px;
    background: #fff;
    color: var(--mw-text);
    font-size: 14px;
}

#kc-form-login input[type="text"]:focus,
#kc-form-login input[type="password"]:focus,
#kc-sms-code-login-form input[type="text"]:focus {
    border-color: var(--mw-primary);
    outline: none;
    box-shadow: 0 0 0 3px var(--mw-focus);
}

.mw-form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.mw-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--mw-muted);
    font-size: 14px;
}

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

.mw-forgot {
    color: var(--mw-primary);
    text-decoration: none;
    font-size: 14px;
}

.mw-forgot:hover {
    text-decoration: underline;
}

.mw-btn {
    width: 100%;
    border: 0;
    border-radius: 999px;
    height: 38px;
    padding: 0 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.mw-btn-primary {
    background: var(--mw-primary);
    color: #fff;
}

.mw-btn-primary:hover {
    background: var(--mw-primary-hover);
}

.mw-social {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--mw-border);
}

#kc-social-providers {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    float: none !important;
}

#kc-social-providers ul {
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 8px;
}

#kc-social-providers li {
    margin: 0;
    padding: 0;
    list-style: none !important;
}

.mw-social-btn,
a.zocial.mw-social-btn {
    display: block;
    width: 100%;
    border-radius: 8px;
    border: 0;
    background: var(--mw-primary);
    color: #fff;
    text-decoration: none;
    padding: 11px 12px;
    line-height: 1.2;
}

.mw-social-btn:hover,
a.zocial.mw-social-btn:hover {
    background: var(--mw-primary-hover);
    color: #fff;
}

.mw-try-another-way {
    margin-top: 12px;
}

.mw-link-button {
    border: 0;
    background: none;
    color: var(--mw-primary);
    cursor: pointer;
    padding: 0;
    font-size: 14px;
}

.mw-link-button:hover {
    text-decoration: underline;
}

.mw-help {
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid #dfe8f5;
}

.mw-help summary {
    cursor: pointer;
    color: var(--mw-title);
    font-weight: 600;
}

.mw-help p {
    margin: 8px 0 0;
    color: #4b607f;
    font-size: 14px;
}

.mw-registration,
.mw-info {
    margin-top: 12px;
    font-size: 14px;
    color: var(--mw-muted);
}

.mw-registration a {
    color: var(--mw-primary);
    text-decoration: none;
}

.mw-registration a:hover {
    text-decoration: underline;
}

@media (max-width: 560px) {
    #kc-card {
        border-radius: 12px;
        padding: 18px 14px;
    }

    #kc-page-title {
        font-size: 30px;
    }

    .mw-body {
        background-size: cover;
    }
}

/* Hard overrides to win against Keycloak/base CSS */
body.mw-body {
    min-height: 100vh !important;
}

#kc-root.mw-root {
    min-height: 100vh !important;
    display: block !important;
    width: 100% !important;
    padding: 52px 12px 24px !important;
}

#kc-card.mw-card {
    width: min(420px, 100%) !important;
    max-width: 420px !important;
    margin: 0 auto !important;
    display: block !important;
}

#kc-form-login,
#kc-social-providers,
#kc-content,
#kc-content-wrapper,
#kc-form,
#kc-form-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    float: none !important;
    display: block !important;
}

#kc-social-providers ul,
#kc-social-providers li {
    list-style: none !important;
    margin-left: 0 !important;
    padding-left: 0 !important;
}
