:root {
    color-scheme: dark;
    --portal-surface: #1f2937;
    --portal-surface-light: #283548;
    --portal-border: rgba(255, 255, 255, .12);
    --portal-muted: #aeb9c8;
    --portal-accent: #3cc6db;
    --portal-accent-hover: #66d7e8;
    --portal-danger: #f28b82;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    background: radial-gradient(circle at 20% 12%, #173a4a 0, #111827 42%, #0c121d 100%);
    color: #f7fafc;
    font-family: Arial, sans-serif;
}
button, input, select { font: inherit; }

#edge-network-background {
    position: fixed;
    z-index: 0;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: .92;
}
.login-page, .portal-footer { position: relative; z-index: 1; }
.login-page {
    display: flex;
    flex: 1;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    padding: 42px 24px;
}
.login-layout {
    display: grid;
    width: min(920px, 100%);
    grid-template-columns: minmax(260px, .9fr) minmax(320px, 1.1fr);
    overflow: hidden;
    border: 1px solid var(--portal-border);
    border-radius: 18px;
    background: var(--portal-surface);
    box-shadow: 0 22px 60px rgba(0, 0, 0, .3);
}
.login-intro {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 450px;
    padding: 42px;
    overflow: hidden;
    background: linear-gradient(150deg, #173646 0%, #172331 68%);
}
.login-intro::after {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(103, 212, 224, .08) 1px, transparent 1px), linear-gradient(90deg, rgba(103, 212, 224, .08) 1px, transparent 1px);
    background-size: 34px 34px;
    content: '';
    mask-image: linear-gradient(to bottom, black, transparent 72%);
    pointer-events: none;
}
.login-intro > * { position: relative; z-index: 1; }
.login-logo { display: block; width: 186px; height: auto; }
.login-eyebrow {
    margin: 42px 0 10px;
    color: var(--portal-accent);
    font-size: 12px;
    font-weight: bold;
    letter-spacing: .13em;
    text-transform: uppercase;
}
.login-intro h1 { max-width: 310px; margin: 0; font-size: 31px; font-weight: 600; line-height: 1.18; }
.login-intro p { max-width: 330px; margin: 16px 0 0; color: var(--portal-muted); line-height: 1.55; }
.login-intro-note { color: var(--portal-muted); font-size: 13px; }
.login-system-label { margin-top: 18px; color: rgba(138, 229, 241, .72); font-family: Consolas, monospace; font-size: 10px; letter-spacing: .11em; line-height: 1.6; }

.login-card { padding: 42px; }
.login-card-heading { margin: 0 0 7px; font-size: 24px; font-weight: 600; }
.login-card-copy { margin: 0 0 29px; color: var(--portal-muted); line-height: 1.5; }
.form-label { display: block; margin-bottom: 8px; color: #dce4ee; font-size: 14px; font-weight: 600; }
.form-input, .form-select {
    width: 100%;
    padding: 12px 13px;
    border: 1px solid var(--portal-border);
    border-radius: 8px;
    outline: none;
    background: rgba(0, 0, 0, .2);
    color: #fff;
}
.form-input:focus, .form-select:focus { border-color: var(--portal-accent); box-shadow: 0 0 0 3px rgba(60, 198, 219, .15); }
.form-group { margin-bottom: 19px; }
.portal-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 11px 14px; border: 1px solid transparent; border-radius: 8px; background: var(--portal-accent); color: #10202a; cursor: pointer; font-weight: bold; text-decoration: none; }
.portal-button:hover { background: var(--portal-accent-hover); }
.portal-button-secondary { background: transparent; border-color: var(--portal-border); color: #fff; }
.portal-button-secondary:hover { background: rgba(255, 255, 255, .08); }
.login-oauth-buttons { display: flex; flex-direction: column; gap: 10px; }
.login-error { margin: 0 0 19px; padding: 11px 13px; border: 1px solid rgba(242, 139, 130, .35); border-radius: 8px; background: rgba(242, 139, 130, .1); color: var(--portal-danger); line-height: 1.4; }
.login-error[hidden] { display: none; }
.login-options { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 3px 0 21px; color: var(--portal-muted); font-size: 14px; }
.remember-me { display: inline-flex; align-items: center; gap: 8px; }
.remember-me input, .checkbox-row input { accent-color: var(--portal-accent); }
.login-options a, .login-signup a, .text-link { color: var(--portal-accent); text-decoration: none; }
.login-options a:hover, .login-signup a:hover, .text-link:hover { color: #8ae5f1; text-decoration: underline; }
.login-divider { display: flex; align-items: center; gap: 12px; margin: 24px 0; color: var(--portal-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }
.login-divider::before, .login-divider::after { flex: 1; height: 1px; background: var(--portal-border); content: ''; }
.login-signup { margin: 24px 0 0; color: var(--portal-muted); font-size: 14px; text-align: center; }

.signup-card { max-height: calc(100vh - 84px); overflow-y: auto; }
.signup-card .login-card-copy { margin-bottom: 22px; }
.signup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.signup-grid .form-group:first-child { grid-column: 1 / -1; }
.checkbox-row { display: flex; align-items: flex-start; gap: 9px; margin: 8px 0 14px; color: var(--portal-muted); font-size: 13px; line-height: 1.45; }
.checkbox-row input { flex: 0 0 auto; margin-top: 3px; }
.checkbox-row a { color: var(--portal-accent); }
.recaptcha-actions { display: grid; grid-template-columns: minmax(0, 1fr) 150px; align-items: center; gap: 16px; margin-top: 20px; }
.recaptcha-actions #recaptcha { min-height: 78px; overflow: hidden; }
.auth-back-link { display: block; margin-top: 20px; color: var(--portal-accent); font-size: 14px; text-align: center; text-decoration: none; }
.auth-back-link:hover { color: #8ae5f1; text-decoration: underline; }
.locale-select { position: fixed; z-index: 2; top: 18px; right: 18px; padding: 7px 10px; border: 1px solid var(--portal-border); border-radius: 7px; background: rgba(31, 41, 55, .85); color: #fff; }

.portal-footer {
    position: absolute;
    z-index: 1;
    bottom: 0;
    left: 50%;
    display: flex;
    justify-content: space-between;
    gap: 24px;
    width: min(1060px, 100%);
    margin: 0 auto;
    padding: 24px;
    border-top: 1px solid var(--portal-border);
    color: var(--portal-muted);
    font-size: 13px;
    transform: translateX(-50%);
}
.portal-footer a { color: var(--portal-muted); text-decoration: none; }
.portal-footer a:hover { color: #fff; text-decoration: underline; }
.portal-footer-links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 14px; }

/* Outcome pages - payment finished, OAuth refused. One card, no form: the visitor arrived here
   from somewhere else and only needs to read the result and get back to the portal. */
.status-layout { width: min(560px, 100%); grid-template-columns: minmax(0, 1fr); }
.status-card { display: flex; flex-direction: column; align-items: center; text-align: center; }
.status-logo { display: block; width: 168px; height: auto; margin-bottom: 26px; }
.status-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 62px;
    height: 62px;
    margin-bottom: 20px;
    border: 1px solid var(--portal-border);
    border-radius: 50%;
    font-size: 26px;
}
.status-icon-ok { border-color: rgba(60, 198, 219, .4); background: rgba(60, 198, 219, .12); color: var(--portal-accent); }
.status-icon-warn { border-color: rgba(242, 139, 130, .4); background: rgba(242, 139, 130, .1); color: var(--portal-danger); }
.status-card h1 { margin: 0 0 12px; font-size: 23px; font-weight: 600; line-height: 1.3; }
.status-message { max-width: 400px; margin: 0 0 27px; color: var(--portal-muted); line-height: 1.55; }
.status-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; width: 100%; }
.status-actions .portal-button { width: auto; min-width: 190px; }

/* Dialogs raised by common.js (alertDialog / confirmDialog / promptDialog). The console styles
   these in components.css, which the public pages do not load - without this they fall back to
   the bare w3.css modal and read as a different product. */
.w3-modal { background-color: rgba(5, 10, 18, .68); backdrop-filter: blur(5px); }
.alert-dlg, .confirm-dlg, .prompt-dlg, .password-prompt-dlg {
    overflow: hidden;
    width: min(480px, calc(100vw - 32px));
    border: 1px solid var(--portal-border);
    border-radius: 14px;
    background: var(--portal-surface);
    box-shadow: 0 24px 70px rgba(0, 0, 0, .45);
    color: #f7fafc;
    font-family: Arial, sans-serif;
}
.alert-dlg > .w3-container:first-child,
.confirm-dlg > .w3-container:first-child,
.prompt-dlg > .w3-container:first-child {
    padding: 18px 22px !important;
    background: linear-gradient(135deg, #173646, #172331) !important;
    color: #f7fafc !important;
    font-size: 1.1rem !important;
    font-weight: 600;
}
.alert-dlg > p, .confirm-dlg > .w3-container, .prompt-dlg > .w3-container { color: #f7fafc !important; }
.alert-dlg > p *, .confirm-dlg > .w3-container *, .prompt-dlg > .w3-container * { color: inherit; }
.alert-dlg .w3-container, .confirm-dlg .w3-container, .prompt-dlg .w3-container { padding: 16px 22px !important; }
.alert-dlg code { display: block; overflow: auto; width: 100%; max-height: 200px; user-select: all; }
.alert-dlg .details { color: var(--portal-accent); text-decoration: underline; }
.confirm-dlg input, .prompt-dlg input, .password-prompt-dlg input {
    padding: 10px 12px;
    border: 1px solid var(--portal-border);
    border-radius: 7px;
    outline: none;
    background: rgba(0, 0, 0, .2);
    color: #f7fafc;
}
.confirm-dlg input:focus, .prompt-dlg input:focus, .password-prompt-dlg input:focus {
    border-color: var(--portal-accent);
    box-shadow: 0 0 0 3px rgba(60, 198, 219, .15);
}
.alert-dlg .w3-button, .confirm-dlg .w3-button, .prompt-dlg .w3-button, .password-prompt-dlg .w3-button {
    border: 1px solid transparent;
    border-radius: 7px;
    background: var(--portal-accent) !important;
    box-shadow: none !important;
    color: #10202a !important;
    font-weight: 700;
}
.alert-dlg .w3-button:hover, .confirm-dlg .w3-button:hover,
.prompt-dlg .w3-button:hover, .password-prompt-dlg .w3-button:hover {
    background: var(--portal-accent-hover) !important;
}
.confirm-dlg .w3-button.w3-grey, .prompt-dlg .w3-button.w3-grey {
    border-color: var(--portal-border);
    background: transparent !important;
    color: #f7fafc !important;
}
.alert-dlg .w3-button:focus-visible, .confirm-dlg .w3-button:focus-visible,
.prompt-dlg .w3-button:focus-visible, .password-prompt-dlg .w3-button:focus-visible {
    outline: 3px solid rgba(60, 198, 219, .35);
    outline-offset: 2px;
}

@media (max-width: 700px), (max-height: 700px) {
    .login-page { align-items: flex-start; min-height: auto; padding: 22px 16px 110px; }
    .login-layout { grid-template-columns: 1fr; }
    .login-intro { min-height: auto; padding: 30px; }
    .login-eyebrow { margin-top: 28px; }
    .login-intro-note { display: none; }
    .login-card { padding: 30px; }
    .signup-card { max-height: none; overflow: visible; }
    .signup-grid { grid-template-columns: 1fr; }
    .signup-grid .form-group:first-child { grid-column: auto; }
    .recaptcha-actions { grid-template-columns: 1fr; }
    .portal-footer { position: relative; left: auto; flex-direction: column; padding: 20px 16px; transform: none; }
    .portal-footer-links { justify-content: flex-start; }
}
