:root {
    --primary: #003da5;
    --primary-dark: #002d7a;
    --accent: #ebab21;
    --accent-hover: #f5bc3a;
    --bg: #f5f8fc;
    --text: #11284b;
    --muted: #5f6e82;
    --border: #e4ebf4;
    --border-form: #002d7a;
    --white: #ffffff;
    --white-muted: rgba(255, 255, 255, 0.75);
    --card-bg: rgba(255, 255, 255, 0.1);
    --card-border: rgba(235, 171, 33, 0.35);
    --accent-pattern: rgba(235, 171, 33, 0.18);
}

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

html, body {
    height: 100%;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(145deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    line-height: 1.6;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

body.body--centered {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    overflow: hidden;
}

body.body--role-picker {
    justify-content: flex-end;
    padding-right: clamp(1.5rem, 6vw, 4rem);
}

body.body--role-picker .page {
    width: 100%;
    max-width: 36rem;
    margin-left: auto;
    margin-right: 0;
    flex: 0 1 auto;
}

@media (max-width: 639px) {
    body.body--role-picker {
        justify-content: center;
        padding-right: 1.5rem;
    }
}

body.body--split {
    padding: 0;
    overflow: hidden;
}

body.body--split > .bg-pattern {
    display: none;
}

/* Background patterns */

.bg-pattern {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.bg-pattern::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle, rgba(235, 171, 33, 0.18) 1.5px, transparent 1.5px),
        radial-gradient(circle at 100% 0%, rgba(235, 171, 33, 0.14) 0%, transparent 40%),
        radial-gradient(circle at 0% 100%, rgba(235, 171, 33, 0.1) 0%, transparent 35%);
    background-size: 28px 28px, 100% 100%, 100% 100%;
}

.bg-pattern::after {
    content: "";
    position: absolute;
    width: 140%;
    height: 140%;
    top: -20%;
    left: -20%;
    background-image: repeating-linear-gradient(
        -35deg,
        transparent,
        transparent 48px,
        rgba(235, 171, 33, 0.07) 48px,
        rgba(235, 171, 33, 0.07) 49px
    );
}

.shape {
    position: absolute;
    border: 2px solid rgba(235, 171, 33, 0.25);
    border-radius: 50%;
    pointer-events: none;
}

.shape-1 {
    width: 220px;
    height: 220px;
    top: -60px;
    right: -40px;
}

.shape-2 {
    width: 140px;
    height: 140px;
    bottom: 10%;
    left: -30px;
    border-style: dashed;
}

.shape-3 {
    width: 80px;
    height: 80px;
    top: 35%;
    left: 8%;
    background: rgba(235, 171, 33, 0.08);
}

.shape-4 {
    width: 48px;
    height: 48px;
    bottom: 18%;
    right: 12%;
    background: rgba(235, 171, 33, 0.12);
    transform: rotate(45deg);
    border-radius: 8px;
    border: none;
}

/* Page shell */

.page {
    position: relative;
    z-index: 1;
    width: 100%;
}

.page--narrow {
    max-width: 26rem;
}

.page--medium {
    max-width: 40rem;
}

.page--wide {
    max-width: 64rem;
}

.page--centered {
    text-align: center;
}

.page--full {
    max-width: none;
    height: 100%;
    min-height: 100vh;
}

/* Card */

.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 1.25rem;
    padding: 2.5rem 2rem 2rem;
    box-shadow:
        0 24px 48px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.card--compact {
    padding: 2rem 1.75rem;
}

.card h1,
.card h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--white);
    margin-bottom: 0.625rem;
}

.card p {
    font-size: 0.9375rem;
    color: var(--white-muted);
    margin-bottom: 1.75rem;
}

.card p:last-child {
    margin-bottom: 0;
}

/* Typography */

.display-code {
    font-size: clamp(4.5rem, 16vw, 6.5rem);
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.04em;
    color: var(--white);
    margin-bottom: 0.25rem;
}

.accent-bar {
    width: 3rem;
    height: 4px;
    background: var(--accent);
    border-radius: 2px;
    margin: 1rem auto 1.25rem;
}

.accent-bar--left {
    margin-left: 0;
    margin-right: auto;
}

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

/* Buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--primary-dark);
    background: var(--accent);
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 4px 14px rgba(235, 171, 33, 0.35);
}

.btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(235, 171, 33, 0.45);
}

.btn:focus-visible {
    outline: 2px solid var(--white);
    outline-offset: 2px;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn:disabled:hover {
    background: var(--accent);
    transform: none;
    box-shadow: none;
}

.btn--block {
    width: 100%;
}

/* Brand */

.brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.25rem;
}

.brand__logo {
    width: 3.5rem;
    height: 3.5rem;
}

.brand__title {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--white);
}

.brand__logo--lg {
    width: 4.5rem;
    height: 4.5rem;
}

.brand--auth .brand__title {
    color: var(--text);
}

.tagline {
    font-size: 0.9375rem;
    color: var(--white-muted);
    margin-bottom: 1.75rem;
    line-height: 1.55;
}

/* Forms */

.form {
    text-align: left;
}

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

.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 0.375rem;
}

.form-label--dark {
    color: var(--text);
}

.form-input {
    width: 100%;
    padding: 0.6875rem 0.875rem;
    font-size: 0.9375rem;
    font-family: inherit;
    color: var(--text);
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--border-form);
    border-radius: 0.5rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(235, 171, 33, 0.25);
}

.input-group {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border-form);
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.92);
    overflow: hidden;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-group:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(235, 171, 33, 0.25);
}

.input-group .form-input {
    border: none;
    border-radius: 0;
    box-shadow: none;
    flex: 1;
    min-width: 0;
}

.input-group .form-input:focus {
    box-shadow: none;
}

.input-group__suffix {
    display: flex;
    align-items: center;
    padding: 0 0.875rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--primary);
    background: var(--bg);
    border-left: 1px solid var(--border-form);
    white-space: nowrap;
}

.input-group--toggle {
    position: relative;
}

.input-group--toggle .form-input {
    width: 100%;
    padding-right: 2.75rem;
}

.input-toggle {
    position: absolute;
    top: 50%;
    right: 0.5rem;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: none;
    border-radius: 0.375rem;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
}

.input-toggle:hover {
    color: var(--text);
    background: var(--bg);
}

.input-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.input-toggle__icon[hidden] {
    display: none;
}

.form-actions {
    margin-top: 1.5rem;
}

/* Alerts */

.alert {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
    text-align: left;
}

.alert--error {
    background: rgba(220, 53, 69, 0.15);
    border: 1px solid rgba(220, 53, 69, 0.4);
    color: #ffc8cd;
}

.alert--success {
    background: rgba(40, 167, 69, 0.15);
    border: 1px solid rgba(40, 167, 69, 0.4);
    color: #b8f0c8;
}

.alert--light.alert--error {
    background: #fde8ea;
    border-color: #f5c2c7;
    color: #842029;
}

.alert--light.alert--success {
    background: #d1e7dd;
    border-color: #badbcc;
    color: #0f5132;
}

.alert--warning {
    background: rgba(235, 171, 33, 0.15);
    border: 1px solid rgba(235, 171, 33, 0.4);
    color: #ffe8a3;
}

.alert--light.alert--warning {
    background: #fff3cd;
    border-color: #ffecb5;
    color: #664d03;
}

.card--light {
    background: var(--bg);
    color: var(--text);
    border-color: var(--border-form);
}

.card--light h1,
.card--light .heading--dark {
    color: var(--text);
}

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

.form-check {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.form-check:last-of-type {
    border-bottom: 0;
}

.form-check__input {
    margin-top: 0.2rem;
    accent-color: var(--primary);
}

.form-check__label {
    font-size: 0.9375rem;
    color: var(--text);
    line-height: 1.4;
}

/* Split layout (landing / login) */

.split {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

.split__intro,
.split__auth {
    flex: 0 0 50%;
    width: 50%;
    min-height: 100vh;
}

.split__intro {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    background: linear-gradient(145deg, var(--primary) 0%, var(--primary-dark) 100%);
    overflow: hidden;
}

.split__intro .bg-pattern {
    display: block;
}

.split__intro-content {
    position: relative;
    z-index: 1;
    max-width: 22rem;
}

.split__intro .brand {
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.split__intro .brand__title {
    font-size: clamp(1.5rem, 2.5vw, 2rem);
    text-align: left;
}

.intro-text {
    font-size: clamp(1.125rem, 2vw, 1.375rem);
    font-weight: 500;
    color: var(--white);
    line-height: 1.55;
    text-align: left;
}

.split__auth {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 2.5rem 4.5rem;
    background: var(--white);
}

.split__auth-actions {
    position: absolute;
    left: 50%;
    bottom: 1.75rem;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    transform: translateX(-50%);
}

.btn--auth-foot {
    padding: 0.375rem 0.625rem;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    box-shadow: none;
}

.btn--auth-foot:hover {
    color: var(--text);
    background: transparent;
    border-color: var(--border);
    transform: none;
    box-shadow: none;
}

.btn--auth-foot:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

a.btn--auth-foot {
    text-decoration: none;
}

.monitoring-back-link {
    margin-top: 1.25rem;
    text-align: center;
    font-size: 0.875rem;
}

.monitoring-back-link a {
    color: var(--muted);
    text-decoration: none;
}

.monitoring-back-link a:hover {
    color: var(--text);
    text-decoration: underline;
}

.monitoring-home__message {
    margin: 0 0 1.5rem;
    font-size: 1.125rem;
    color: var(--text);
}

.monitoring-home__logout {
    margin: 0 auto;
    display: inline-flex;
}

.split__auth-inner {
    width: 100%;
    max-width: 22rem;
}

.split__auth .brand {
    margin-bottom: 2rem;
}

.split__auth .brand__title {
    font-size: 1.5rem;
}

@media (max-width: 767px) {
    body.body--split {
        background: var(--white);
    }

    .split {
        min-height: 100vh;
    }

    .split__intro {
        display: none;
    }

    .split__auth {
        flex: 1 1 100%;
        width: 100%;
        padding: 2rem 1.5rem 3.75rem;
    }
}

/* Login page modal (Manual, etc.) */

body.login-modal-open {
    overflow: hidden;
}

.login-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.login-modal[hidden] {
    display: none;
}

.login-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 45, 122, 0.55);
}

.login-modal__card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 22rem;
    padding: 1.25rem 1.25rem 1rem;
    background: var(--white);
    color: var(--text);
    border-radius: 0.75rem;
    box-shadow: 0 18px 48px rgba(17, 40, 75, 0.22);
}

.login-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.login-modal__title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text);
}

.login-modal__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--muted);
    background: transparent;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
}

.login-modal__close:hover {
    color: var(--text);
    background: var(--bg);
}

.login-modal__body {
    margin: 0 0 1rem;
    font-size: 0.9375rem;
    color: var(--muted);
    line-height: 1.5;
}

.login-modal__footer {
    margin-top: 0.25rem;
}

/* Utilities */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Role picker (multi-role sign-in) */

.role-picker-page {
    width: 100%;
    text-align: left;
    padding: 1.75rem 1.5rem 1.5rem;
}

.role-picker-page__header {
    margin-bottom: 1rem;
}

.role-picker-page__header h1 {
    margin: 0 0 0.25rem;
    font-size: 1.15rem;
}

.role-picker-page__header p {
    margin: 0;
    font-size: 0.875rem;
}

.role-picker {
    display: grid;
    gap: 0.5rem;
    grid-template-columns: 1fr;
    margin: 0 0 1.25rem;
    padding: 0;
    border: 0;
}

.role-card {
    position: relative;
    display: block;
    cursor: pointer;
    margin: 0;
}

.role-card__input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.role-card__body {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6875rem 0.875rem;
    border: 2px solid var(--border-form);
    border-radius: 0.65rem;
    background: var(--white);
    box-shadow: 0 2px 10px rgba(17, 40, 75, 0.05);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.role-card:hover .role-card__body {
    border-color: rgba(0, 61, 165, 0.45);
    box-shadow: 0 4px 14px rgba(17, 40, 75, 0.08);
}

.role-card__input:focus-visible + .role-card__body {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.role-card__input:checked + .role-card__body {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 61, 165, 0.12);
    background: linear-gradient(180deg, rgba(0, 61, 165, 0.04) 0%, var(--white) 100%);
}

.role-card__radio {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 999px;
    border: 2px solid var(--border-form);
    background: var(--white);
    flex-shrink: 0;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.role-card__input:checked + .role-card__body .role-card__radio {
    border-color: var(--primary);
    background: var(--primary);
    box-shadow: inset 0 0 0 3px var(--white);
}

.role-card__label {
    display: block;
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
    text-align: left;
}

.role-card__main {
    flex: 1;
    min-width: 0;
    text-align: left;
}

.role-card__aside {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-shrink: 0;
    margin-left: auto;
    text-align: right;
}

.role-card__meta {
    font-size: 0.8125rem;
    color: var(--muted);
    line-height: 1.3;
    white-space: nowrap;
}

.role-card__branch {
    display: inline-flex;
    align-items: center;
    padding: 0.28rem 0.55rem;
    border-radius: 999px;
    background: rgba(235, 171, 33, 0.16);
    color: #7a5a08;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
}

.role-card--current .role-card__body {
    border-style: dashed;
}

.role-card__current {
    display: inline-block;
    padding: 0.12rem 0.45rem;
    border-radius: 999px;
    background: rgba(0, 61, 165, 0.1);
    color: var(--primary);
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.role-card--blocked {
    opacity: 0.55;
    cursor: not-allowed;
}

.role-card--blocked .role-card__input {
    pointer-events: none;
}

.role-card__blocked {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #b42318;
    line-height: 1.4;
    text-align: right;
    white-space: nowrap;
}

.role-card--blocked .role-card__body {
    border-color: rgba(180, 35, 24, 0.35);
    background: #fffafa;
}

.role-card--blocked:hover .role-card__body {
    border-color: rgba(180, 35, 24, 0.45);
    box-shadow: none;
}

.form-actions--split {
    display: grid;
    gap: 0.65rem;
}

@media (min-width: 480px) {
    .form-actions--split {
        grid-template-columns: 1fr 1fr;
    }
}
