:root {
    --bg: #f5f7fa;
    --panel: #ffffff;
    --border: #cfd9e4;
    --text: #1f2d3d;
    --muted: #62707d;
    /* #0b84d8 only reached 3.96:1 behind white button text; this clears 4.5:1. */
    --primary: #0a78c6;
    --primary-dark: #085b95;
    --danger: #b42318;
}

* {
    box-sizing: border-box;
}

body {
    background: var(--bg);
    color: var(--text);
    display: grid;
    font-family: Roboto, Arial, Helvetica, sans-serif;
    font-size: 14px;
    margin: 0;
    min-height: 100vh;
    padding: 24px;
    place-items: center;
}

main,
.login-shell {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.07);
    width: min(440px, calc(100vw - 32px));
}

main {
    padding: 24px;
}

.login-shell {
    padding: 0;
}

.login-split-shell {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-height: 520px;
    overflow: hidden;
    width: min(920px, calc(100vw - 48px));
}

.login-form-panel {
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    margin: 0;
    min-width: 0;
    padding: 0;
}

.login-form-panel .login-header {
    flex: 0 0 auto;
}

.login-form-panel .login-body {
    align-content: center;
    display: grid;
    flex: 1 1 auto;
}

.login-brand-panel {
    align-items: center;
    background: #f7faf9;
    border-left: 1px solid var(--border);
    color: #1f2d3d;
    display: flex;
    justify-content: center;
    min-width: 0;
    padding: 42px;
    text-align: center;
}

.login-brand-lockup {
    display: grid;
    justify-items: center;
}

.login-brand-mark {
    align-items: center;
    background: #ffffff;
    border: 1px solid #cfd9e4;
    border-radius: 8px;
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.07);
    display: flex;
    height: 140px;
    justify-content: center;
    width: 140px;
}

.login-brand-logo {
    color: #E91C1D;
    height: 88px;
    width: 60px;
}

.login-brand-logo .flame {
    fill: currentColor;
}

.login-brand-powered {
    color: var(--ha-muted);
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0;
    margin: 18px 0 14px;
    text-transform: none;
}

.login-brand-legal {
    /* #8e9aa6 was 2.74:1 on the brand panel. */
    color: var(--muted);
    font-size: 11px;
    letter-spacing: .03em;
    margin: 30px 0 0;
}

.login-brand-panel h1 {
    color: #1f2d3d;
    font-size: 28px;
    font-weight: 800;
    line-height: 1.15;
    margin: 0;
}

header,
.login-header {
    border-bottom: 1px solid var(--border);
    padding: 22px 24px 16px;
}

section,
.login-body {
    padding: 24px;
}

main > header:first-child,
main > section {
    margin-left: -24px;
    margin-right: -24px;
}

main > header:first-child {
    margin-top: -24px;
}

main > section:last-child {
    margin-bottom: -24px;
}

h1 {
    font-size: 24px;
    letter-spacing: 0;
    margin: 0 0 6px;
}

p {
    color: var(--muted);
    margin: 0 0 16px;
}

.login-header p {
    margin: 0;
}

.powered-by {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.muted {
    color: var(--muted);
}

label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
}

input {
    border: 1px solid #cfd9e4;
    border-radius: 6px;
    color: var(--text);
    margin-bottom: 14px;
    min-height: 40px;
    padding: 8px 10px;
    width: 100%;
}

button,
a.button,
.btn {
    align-items: center;
    background: var(--primary);
    border: 1px solid var(--primary);
    border-radius: 6px;
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    font-weight: 700;
    justify-content: center;
    min-height: 40px;
    text-decoration: none;
    width: 100%;
}

button i,
a.button i,
.btn i {
    margin-right: 0;
}

button:hover,
a.button:hover,
.btn:hover {
    background: var(--primary-dark);
}

a {
    color: var(--primary);
    font-weight: 700;
    text-decoration: none;
}

a:not(.button):focus,
button:focus,
a.button:focus,
.btn:focus,
input:focus {
    outline: none;
    box-shadow: var(--ha-focus-ring, 0 0 0 3px rgba(28, 111, 159, 0.18));
}

main > a:not(.button) {
    align-items: center;
    display: inline-flex;
    min-height: 40px;
}

.errors {
    background: #fff0ef;
    border: 1px solid #f5c2c7;
    border-radius: 6px;
    color: var(--danger);
    margin-bottom: 14px;
    padding: 10px 12px;
}

body:not(.house-account-shell):not(.settlement-shell) .login-shell.login-split-shell {
    border-color: #cfd9e4;
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.07);
    min-height: 548px;
    width: min(960px, calc(100vw - 48px));
}

body:not(.house-account-shell):not(.settlement-shell) .login-form-panel {
    background: #ffffff;
    border-right-color: #d9e1ea;
}

body:not(.house-account-shell):not(.settlement-shell) .login-form-panel .login-body {
    align-content: center;
    display: grid;
    min-width: 0;
    padding: 44px;
}

body:not(.house-account-shell):not(.settlement-shell) .login-form-card {
    display: grid;
    gap: 18px;
    margin: 0 auto;
    max-width: 368px;
    width: 100%;
}

body:not(.house-account-shell):not(.settlement-shell) .login-form-header {
    display: grid;
    gap: 7px;
    margin-bottom: 2px;
}

body:not(.house-account-shell):not(.settlement-shell) .login-kicker {
    color: var(--ha-muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0;
    line-height: 1.2;
    text-transform: uppercase;
}

body:not(.house-account-shell):not(.settlement-shell) .login-form-header h1 {
    color: #1f2d3d;
    font-size: 28px;
    font-weight: 800;
    line-height: 1.18;
    margin: 0;
}

body:not(.house-account-shell):not(.settlement-shell) .login-form-header p {
    color: var(--ha-muted);
    line-height: 1.45;
    margin: 0;
}

body:not(.house-account-shell):not(.settlement-shell) .login-form {
    display: grid;
    gap: 14px;
}

body:not(.house-account-shell):not(.settlement-shell) .login-field {
    display: grid;
    gap: 7px;
}

body:not(.house-account-shell):not(.settlement-shell) .login-field label {
    color: #1f2d3d;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.2;
    margin: 0;
}

/* Label and reset link share the top row, input spans beneath, while the link stays
   after the input in the DOM so it does not interrupt the tab sequence. */
body:not(.house-account-shell):not(.settlement-shell) .login-field-password {
    align-items: center;
    column-gap: 12px;
    grid-template-areas:
        "label link"
        "input input";
    grid-template-columns: 1fr auto;
}

body:not(.house-account-shell):not(.settlement-shell) .login-field-password label {
    grid-area: label;
    min-height: 18px;
}

body:not(.house-account-shell):not(.settlement-shell) .login-field-password input {
    grid-area: input;
}

body:not(.house-account-shell):not(.settlement-shell) .login-password-reset {
    align-items: center;
    border-radius: 5px;
    color: #1c6f9f;
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    grid-area: link;
    justify-self: end;
    line-height: 1.2;
    min-height: 24px;
    text-decoration: none;
    white-space: nowrap;
}

body:not(.house-account-shell):not(.settlement-shell) .login-field input {
    border-color: #cfd9e4;
    margin: 0;
    min-height: 44px;
    padding: 10px 12px;
}

body:not(.house-account-shell):not(.settlement-shell) .login-form-card .errors {
    line-height: 1.45;
    margin: 0;
}

body:not(.house-account-shell):not(.settlement-shell) .login-submit.btn {
    gap: 8px;
    margin-top: 2px;
    min-height: 44px;
}

body:not(.house-account-shell):not(.settlement-shell) .login-submit i {
    align-items: center;
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 13px;
    height: 1em;
    justify-content: center;
    line-height: 1;
    margin: 0;
    width: 1em;
}

body:not(.house-account-shell):not(.settlement-shell) .login-split-shell .login-brand-panel {
    background: #f8fafc;
    border-left-color: #d9e1ea;
    padding: 48px;
}

body:not(.house-account-shell):not(.settlement-shell) .login-brand-lockup {
    gap: 0;
    max-width: 300px;
}

body:not(.house-account-shell):not(.settlement-shell) .login-brand-mark {
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.07);
    height: 120px;
    width: 120px;
}

body:not(.house-account-shell):not(.settlement-shell) .login-brand-logo {
    height: 76px;
    width: 52px;
}

body:not(.house-account-shell):not(.settlement-shell) .login-brand-title {
    color: #1f2d3d;
    font-size: 26px;
    font-weight: 800;
    line-height: 1.16;
    margin: 0;
}

html[data-house-account-theme="dark"] .login-brand-panel {
    background: var(--ha-dark-surface-muted);
    border-color: var(--ha-dark-border);
    color: var(--ha-dark-text);
}

html[data-house-account-theme="dark"] .login-brand-panel h1 {
    color: var(--ha-dark-text);
}

html[data-house-account-theme="dark"] .login-brand-mark {
    background: var(--ha-dark-surface);
    border-color: var(--ha-dark-border-strong);
    box-shadow: var(--ha-dark-shadow);
}

html[data-house-account-theme="dark"] .login-brand-powered,
html[data-house-account-theme="dark"] .login-brand-legal {
    color: var(--ha-dark-muted);
}

html[data-house-account-theme="dark"] body:not(.house-account-shell):not(.settlement-shell) .login-form-panel,
html[data-house-account-theme="dark"] body:not(.house-account-shell):not(.settlement-shell) .login-split-shell .login-brand-panel {
    background: var(--ha-dark-surface);
    border-color: var(--ha-dark-border);
}

html[data-house-account-theme="dark"] body:not(.house-account-shell):not(.settlement-shell) .login-split-shell .login-brand-panel {
    background: var(--ha-dark-surface-muted);
}

html[data-house-account-theme="dark"] body:not(.house-account-shell):not(.settlement-shell) .login-kicker,
html[data-house-account-theme="dark"] body:not(.house-account-shell):not(.settlement-shell) .login-form-header p,
html[data-house-account-theme="dark"] body:not(.house-account-shell):not(.settlement-shell) .login-brand-powered {
    color: var(--ha-dark-muted);
}

html[data-house-account-theme="dark"] body:not(.house-account-shell):not(.settlement-shell) .login-form-header h1,
html[data-house-account-theme="dark"] body:not(.house-account-shell):not(.settlement-shell) .login-field label,
html[data-house-account-theme="dark"] body:not(.house-account-shell):not(.settlement-shell) .login-brand-title {
    color: var(--ha-dark-text);
}

html[data-house-account-theme="dark"] body:not(.house-account-shell):not(.settlement-shell) .login-field input {
    background: var(--ha-dark-surface-muted);
    border-color: var(--ha-dark-border-strong);
    color: var(--ha-dark-text);
}

html[data-house-account-theme="dark"] body:not(.house-account-shell):not(.settlement-shell) .login-password-reset {
    color: var(--ha-dark-primary);
}

@media (max-width: 760px) {
    body {
        padding: 16px;
    }

    .login-split-shell {
        grid-template-columns: 1fr;
        min-height: 0;
        width: min(440px, calc(100vw - 32px));
    }

    .login-form-panel {
        border-right: 0;
    }

    .login-brand-panel {
        order: -1;
        padding: 28px 24px;
    }

    .login-brand-mark {
        border-radius: 8px;
        height: 96px;
        width: 96px;
    }

    .login-brand-logo {
        height: 62px;
        width: 42px;
    }

    .login-brand-powered {
        margin: 14px 0 10px;
    }

    .login-brand-panel h1 {
        font-size: 22px;
    }

    body:not(.house-account-shell):not(.settlement-shell) .login-shell.login-split-shell {
        min-height: 0;
        width: min(440px, calc(100vw - 32px));
    }

    body:not(.house-account-shell):not(.settlement-shell) .login-form-panel .login-body {
        padding: 28px 22px 26px;
    }

    body:not(.house-account-shell):not(.settlement-shell) .login-form-card {
        max-width: none;
    }

    body:not(.house-account-shell):not(.settlement-shell) .login-form-header h1 {
        font-size: 24px;
    }

    body:not(.house-account-shell):not(.settlement-shell) .login-split-shell .login-brand-panel {
        padding: 28px 24px;
    }

    body:not(.house-account-shell):not(.settlement-shell) .login-brand-mark {
        height: 88px;
        width: 88px;
    }

    body:not(.house-account-shell):not(.settlement-shell) .login-brand-logo {
        height: 58px;
        width: 40px;
    }

    body:not(.house-account-shell):not(.settlement-shell) .login-brand-title {
        font-size: 21px;
    }
}
