:root {
    color-scheme: light;
    --brand-blue-50: #f4f9fe;
    --brand-blue-100: #eaf5ff;
    --brand-blue-200: #d6eafb;
    --brand-blue-300: #add5f5;
    --brand-blue-500: #1188e6;
    --brand-blue-600: #0875d1;
    --brand-blue-700: #075da8;
    --brand-blue-800: #0a477b;
    --brand-blue-900: #082f57;
    --brand-blue-950: #061f3b;
    --neutral-0: #ffffff;
    --neutral-50: #f8fafc;
    --neutral-100: #f1f5f8;
    --neutral-200: #e3ebf1;
    --neutral-300: #cfdae3;
    --neutral-500: #65798c;
    --neutral-700: #31485c;
    --neutral-900: #162c40;
    --success-50: #eefaf4;
    --success-200: #bfe6d3;
    --success-700: #176b45;
    --warning-50: #fff8e8;
    --warning-200: #eed79d;
    --warning-800: #76530a;
    --danger-50: #fff1f1;
    --danger-200: #f3caca;
    --danger-700: #a32d2d;
    --background: var(--brand-blue-50);
    --surface: var(--neutral-0);
    --surface-subtle: var(--neutral-50);
    --text: var(--neutral-900);
    --text-secondary: var(--neutral-500);
    --border: var(--neutral-200);
    --border-strong: var(--neutral-300);
    --focus: var(--brand-blue-600);
    --focus-ring: rgba(8, 117, 209, 0.28);
    --attention: var(--warning-800);
    --error: var(--danger-700);
    --success: var(--success-700);
    --blue: var(--brand-blue-600);
    --blue-dark: var(--brand-blue-800);
    --blue-light: var(--brand-blue-100);
    --blue-600: var(--brand-blue-600);
    --blue-700: var(--brand-blue-700);
    --ink: var(--text);
    --muted: var(--text-secondary);
    --white: var(--neutral-0);
    --danger: var(--danger-700);
    --radius-sm: 0.55rem;
    --radius-md: 0.8rem;
    --radius-lg: 1.1rem;
    --radius-xl: 1.4rem;
    --shadow-sm: 0 1px 2px rgba(8, 47, 87, 0.06);
    --shadow-md: 0 10px 30px rgba(8, 47, 87, 0.08);
    --shadow: 0 20px 55px rgba(8, 47, 87, 0.1);
    --transition-fast: 160ms ease;
}

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

html {
    min-width: 20rem;
    background: var(--background);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
    text-rendering: optimizeLegibility;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--background);
}

.public-body {
    background:
        radial-gradient(circle at 8% 0%, rgba(17, 136, 230, 0.11), transparent 32rem),
        linear-gradient(145deg, var(--neutral-0) 24%, var(--brand-blue-50) 100%);
}

img {
    display: block;
    max-width: 100%;
    height: auto;
}

button,
input,
select,
textarea {
    font: inherit;
}

a {
    color: var(--brand-blue-700);
}

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

.skip-link {
    position: fixed;
    top: -5rem;
    left: 1rem;
    z-index: 100;
    border-radius: var(--radius-sm);
    background: var(--brand-blue-900);
    color: var(--white);
    padding: 0.75rem 1rem;
}

.skip-link:focus {
    top: 1rem;
}

.page-shell {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: clamp(0.9rem, 3vw, 2rem);
}

.auth-card,
.content-card {
    position: relative;
    width: min(100%, 34rem);
    overflow: hidden;
    border: 1px solid rgba(207, 218, 227, 0.88);
    border-radius: var(--radius-xl);
    background: rgba(255, 255, 255, 0.97);
    box-shadow: var(--shadow);
    padding: clamp(1.35rem, 4vw, 2.35rem);
}

.auth-card::before,
.content-card::before {
    position: absolute;
    inset: 0 0 auto;
    height: 0.28rem;
    background: linear-gradient(90deg, var(--brand-blue-900), var(--brand-blue-600), var(--brand-blue-300));
    content: "";
}

.content-card-wide {
    width: min(100%, 68rem);
}

.brand {
    min-width: 0;
}

.brand--lockup {
    width: min(100%, 21rem);
}

.brand--login {
    width: min(100%, 25rem);
    margin-inline: auto;
}

.brand-lockup-image {
    width: 100%;
}

.brand--compact {
    display: inline-flex;
    align-items: center;
    gap: 0.72rem;
    color: var(--brand-blue-900);
}

.brand-symbol-image {
    width: 2.85rem;
    height: 2.85rem;
    flex: 0 0 auto;
    border-radius: 0.75rem;
}

.brand-copy {
    min-width: 0;
}

.brand-copy strong,
.brand-copy small {
    display: block;
}

.brand-copy strong {
    color: var(--brand-blue-900);
    font-size: 1rem;
    line-height: 1.1;
    white-space: nowrap;
}

.brand-copy small {
    margin-top: 0.15rem;
    color: var(--text-secondary);
    font-size: 0.73rem;
    white-space: nowrap;
}

.card-heading {
    margin: 1.85rem 0 1.35rem;
}

.card-heading h1,
.welcome-panel h1 {
    margin: 0.25rem 0 0.7rem;
    color: var(--brand-blue-900);
    font-size: clamp(1.7rem, 5vw, 2.3rem);
    letter-spacing: -0.025em;
    line-height: 1.12;
}

.card-heading p,
.welcome-panel p,
.auth-note,
.company-option p,
.phase-note p {
    margin: 0.3rem 0;
    color: var(--text-secondary);
    line-height: 1.6;
}

.eyebrow {
    color: var(--brand-blue-700) !important;
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.field {
    margin: 0 0 1.1rem;
}

.field label {
    display: block;
    margin-bottom: 0.45rem;
    color: var(--neutral-700);
    font-weight: 700;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    min-height: 3.15rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--white);
    color: var(--text);
    padding: 0.75rem 0.9rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.field textarea {
    min-height: 7rem;
    resize: vertical;
}

.field small {
    display: block;
    margin-top: 0.35rem;
    color: var(--text-secondary);
}

.field input:hover,
.field select:hover,
.field textarea:hover {
    border-color: var(--brand-blue-300);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--focus);
    box-shadow: 0 0 0 4px var(--focus-ring);
    outline: 0;
}

.button {
    display: inline-flex;
    min-height: 3rem;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    padding: 0.7rem 1.05rem;
    cursor: pointer;
    font-weight: 750;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.button-primary {
    background: var(--brand-blue-700);
    color: var(--white);
}

.auth-card form .button-primary {
    width: 100%;
}

.button-primary:hover {
    background: var(--brand-blue-900);
}

.button-secondary {
    border-color: var(--border-strong);
    background: var(--white);
    color: var(--brand-blue-800);
}

.button-secondary:hover {
    border-color: var(--brand-blue-300);
    background: var(--brand-blue-50);
}

.button[disabled] {
    cursor: wait;
    opacity: 0.65;
}

.text-link {
    display: inline-block;
    margin-top: 1.25rem;
    color: var(--brand-blue-700);
    font-weight: 700;
    text-underline-offset: 0.18em;
}

.auth-note {
    margin-top: 1.5rem;
    border-top: 1px solid var(--border);
    padding-top: 1.2rem;
    font-size: 0.9rem;
}

.alert {
    margin: 1rem 0;
    border: 1px solid;
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    line-height: 1.5;
}

.alert p {
    margin: 0.25rem 0;
}

.alert ul {
    margin: 0.35rem 0 0;
    padding-left: 1.2rem;
}

.alert-error {
    border-color: var(--danger-200);
    background: var(--danger-50);
    color: var(--danger-700);
}

.alert-success {
    border-color: var(--success-200);
    background: var(--success-50);
    color: var(--success-700);
}

.alert-warning {
    border-color: var(--warning-200);
    background: var(--warning-50);
    color: var(--warning-800);
}

.topbar,
.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.topbar-actions {
    justify-content: flex-end;
}

.topbar form {
    margin: 0;
}

.welcome-panel {
    margin: 3rem 0 1.5rem;
}

.context-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: 1rem;
    margin: 0;
}

.context-summary div,
.phase-note {
    border: 1px solid var(--brand-blue-200);
    border-radius: var(--radius-md);
    background: var(--brand-blue-50);
    padding: 1rem;
}

.context-summary dt {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.context-summary dd {
    margin: 0.25rem 0 0;
    font-weight: 750;
}

.phase-note {
    margin-top: 1rem;
}

.company-grid {
    display: grid;
    gap: 1rem;
}

.company-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}

.company-option h2 {
    margin: 0;
    color: var(--brand-blue-900);
    font-size: 1.1rem;
}

.company-option .button {
    width: auto;
    min-width: 7rem;
}

.badge {
    display: inline-block !important;
    border: 1px solid var(--brand-blue-200);
    border-radius: 99px;
    background: var(--brand-blue-50);
    color: var(--brand-blue-800) !important;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
}

.state-icon {
    display: grid;
    width: 3rem;
    height: 3rem;
    margin: 2rem 0 0;
    place-items: center;
    border-radius: 50%;
    background: var(--brand-blue-100);
    color: var(--brand-blue-700);
    font-size: 1.5rem;
    font-weight: 800;
}

.error-code {
    margin: 1.75rem 0 0.15rem;
    color: var(--brand-blue-700);
    font-size: clamp(2.8rem, 10vw, 4rem);
    font-weight: 850;
    letter-spacing: -0.04em;
}

.pwa-controls {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 45;
    display: grid;
    max-width: min(22rem, calc(100vw - 2rem));
    gap: 0.5rem;
}

.pwa-controls [hidden],
.connection-notice[hidden] {
    display: none;
}

.pwa-install-button,
.pwa-installed,
.pwa-ios-help,
.connection-notice {
    border: 1px solid var(--brand-blue-200);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--brand-blue-900);
    box-shadow: var(--shadow-md);
}

.pwa-install-button {
    min-height: 2.75rem;
    cursor: pointer;
    padding: 0.7rem 1rem;
    font-weight: 750;
}

.pwa-install-button:hover {
    border-color: var(--brand-blue-500);
    background: var(--brand-blue-50);
}

.pwa-install-button:disabled {
    cursor: wait;
    opacity: 0.68;
}

.pwa-installed,
.pwa-ios-help {
    margin: 0;
    padding: 0.7rem 0.85rem;
    font-size: 0.85rem;
}

.connection-notice {
    position: fixed;
    left: 50%;
    bottom: 1rem;
    z-index: 50;
    width: min(42rem, calc(100vw - 2rem));
    transform: translateX(-50%);
    padding: 0.8rem 1rem;
    text-align: center;
    font-weight: 700;
}

.connection-notice--offline {
    border-color: var(--warning-200);
    background: var(--warning-50);
    color: var(--warning-800);
}

.offline-card {
    text-align: center;
}

.offline-brand {
    width: min(100%, 20rem);
    margin-inline: auto;
}

.offline-card .state-icon {
    margin-inline: auto;
}

.offline-card h1 {
    margin-bottom: 0.5rem;
    color: var(--brand-blue-900);
}

.offline-card .button {
    margin-top: 0.75rem;
}

.auth-card > h1 {
    margin-top: 0.2rem;
    color: var(--brand-blue-900);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
}

@media (max-width: 600px) {
    .page-shell {
        align-items: start;
        padding: 0.75rem;
    }

    .auth-card,
    .content-card {
        border-radius: var(--radius-lg);
        padding: 1.2rem;
    }

    .brand--lockup {
        width: min(100%, 18rem);
    }

    .brand--login {
        width: min(100%, 20rem);
    }

    .topbar,
    .company-option {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar-actions {
        width: 100%;
        justify-content: stretch;
    }

    .topbar-actions > * {
        flex: 1;
    }

    .topbar-actions .button,
    .company-option .button {
        width: 100%;
    }

    .pwa-controls {
        right: 0.75rem;
        bottom: 0.75rem;
        max-width: calc(100vw - 1.5rem);
    }

    .connection-notice {
        bottom: 0.75rem;
        width: calc(100vw - 1.5rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition: none !important;
    }
}

@media (forced-colors: active) {
    .button,
    .auth-card,
    .content-card,
    .company-option {
        border-color: CanvasText;
    }
}
