:root {
    color-scheme: light;
    --bg-start: #dff0ee;
    --bg-mid-1: #eef1f5;
    --bg-mid-2: #f5f6f8;
    --bg-end: #f0f2f5;
    --card-bg: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --accent: #52b4a8;
    --accent-dark: #47a89c;
    --focus: #52b4a8;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    overflow-y: scroll;
    scrollbar-gutter: stable;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: radial-gradient(ellipse at top left, var(--bg-start) 0%, var(--bg-mid-1) 40%, var(--bg-mid-2) 70%, var(--bg-end) 100%);
    color: var(--text-primary);
}

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.auth-shell {
    width: 100%;
    max-width: 460px;
    display: grid;
    justify-items: center;
    gap: 1.25rem;
}

.auth-logo {
    width: 210px;
    max-width: 70%;
    height: auto;
    display: block;
    user-select: none;
}

.login-card {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid #f3f4f6;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 20px 35px rgba(209, 213, 219, 0.5);
}

    .login-card h1 {
        margin: 0;
        text-align: center;
        font-size: 1.5rem;
        font-weight: 700;
        color: #111827;
    }

.page-subtitle {
    margin: 0.5rem 0 1.5rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.tenant-banner {
    margin: 0 0 1.25rem;
    padding: 0.625rem 1rem;
    text-align: center;
    background: var(--bg-end);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 600;
}

.primary-button,
.btn,
button {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 12px;
    background: var(--accent);
    color: #ffffff;
    text-decoration: none;
    font-weight: 500;
    padding: 0.86rem 1rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 1rem;
}

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

    .primary-button:focus-visible,
    .btn:focus-visible,
    button:focus-visible,
    summary:focus-visible,
    input:focus-visible,
    .provider-link:focus-visible {
        outline: 2px solid rgba(82, 180, 168, 0.3);
        outline-offset: 1px;
    }

.divider {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0.75rem;
    align-items: center;
    margin: 1.6rem 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

    .divider::before,
    .divider::after {
        content: "";
        height: 1px;
        background: var(--border);
    }

.provider-list {
    display: grid;
    gap: 0.625rem;
}

.provider-item {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
}

    .provider-item summary {
        list-style: none;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        padding: 0.875rem 1rem;
        font-weight: 600;
        color: #374151;
        transition: background-color 0.2s ease;
    }

        .provider-item summary:hover {
            background: #f9fafb;
        }

        .provider-item summary::-webkit-details-marker {
            display: none;
        }

    .provider-item[open] summary {
        border-bottom: 1px solid var(--border);
        background: rgba(249, 250, 251, 0.6);
    }

.provider-chevron {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    flex: 0 0 auto;
}

    .provider-chevron svg {
        width: 18px;
        height: 18px;
        display: block;
    }

    .provider-chevron .chevron-up {
        display: none;
    }

.provider-item[open] .provider-chevron .chevron-down {
    display: none;
}

.provider-item[open] .provider-chevron .chevron-up {
    display: block;
}

.provider-content {
    padding: 0.85rem 1rem 1rem;
    overflow: hidden;
    opacity: 1;
}

    .provider-content.is-animating {
        transition: height 0.22s ease, opacity 0.22s ease;
    }

.provider-link {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    color: #374151;
    text-decoration: none;
    font-weight: 600;
    padding: 0.875rem 1rem;
    transition: background-color 0.2s ease;
}

    .provider-link:hover {
        background: #f9fafb;
    }

.provider-title {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
}

.provider-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    flex: 0 0 auto;
}

.provider-logo {
    width: 20px;
    height: 20px;
    display: block;
}

    .provider-logo.sykehuspartner {
        border-radius: 3px;
    }

.field {
    margin-bottom: 0.82rem;
}

    .field label {
        display: block;
        margin-bottom: 0.45rem;
        font-size: 0.875rem;
        color: #374151;
        font-weight: 500;
    }

.field-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
}

.text-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
}

input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem 0.85rem;
    font-size: 0.95rem;
    color: #111827;
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

    input:focus-visible {
        border-color: var(--accent);
        box-shadow: 0 0 0 3px rgba(82, 180, 168, 0.18);
    }

    input::placeholder {
        color: #9ca3af;
    }

.center-text {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.spinner-wrapper {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
}

.spinner {
    width: 38px;
    height: 38px;
    border: 4px solid #d6e4f5;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.selection-container {
    margin-top: 1.35rem;
}

.user-buttons {
    display: grid;
    gap: 1.25rem;
}

.user-group {
    display: grid;
    gap: 0.5rem;
}

.user-group-heading {
    margin: 0 0 0.25rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.selection-form {
    margin: 0;
}

.tenant-row,
.role-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #ffffff;
    color: var(--text-primary);
    text-align: left;
    padding: 0.75rem 0.875rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

    .tenant-row:hover,
    .role-row:hover {
        background: #f9fafb;
        border-color: var(--border-strong);
    }

    .tenant-row:active,
    .role-row:active {
        background: #f3f4f6;
    }

.tenant-row-text {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    flex: 1 1 auto;
    min-width: 0;
}

.tenant-row-primary {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tenant-row-secondary {
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--text-secondary);
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tenant-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #ffffff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

    .tenant-card[open] {
        border-color: var(--border-strong);
        box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
    }

.tenant-card-summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.875rem;
    user-select: none;
    border-radius: 12px;
    transition: background-color 0.15s ease;
}

    .tenant-card-summary:hover {
        background: #f9fafb;
    }

    .tenant-card-summary::-webkit-details-marker {
        display: none;
    }

.tenant-card[open] .tenant-card-summary {
    border-radius: 12px 12px 0 0;
}

.tenant-card-text {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1 1 auto;
    min-width: 0;
}

.tenant-card-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tenant-card-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    padding: 0 0.4rem;
    height: 1.25rem;
    border-radius: 999px;
    background: #f3f4f6;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    flex: 0 0 auto;
}

.tenant-card-chevron {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    flex: 0 0 auto;
    transition: transform 0.2s ease;
}

    .tenant-card-chevron svg {
        width: 18px;
        height: 18px;
        display: block;
    }

.tenant-card[open] .tenant-card-chevron {
    transform: rotate(180deg);
}

.role-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem 0.625rem;
    border-top: 1px solid var(--border);
}

.role-row {
    padding: 0.625rem 0.75rem;
    background: #fbfbfc;
}

    .role-row:hover {
        background: #f3f4f6;
    }

.role-row-text {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tenant-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: #ffffff;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.role-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: rgba(82, 180, 168, 0.12);
    color: var(--accent-dark);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
    flex: 0 0 auto;
    max-width: 45%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row-chevron {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    flex: 0 0 auto;
}

    .row-chevron svg {
        width: 16px;
        height: 16px;
        display: block;
    }

.error-actions {
    margin-top: 1.25rem;
}

.auth-footer {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-align: center;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 600px) {
    .auth-page {
        padding: 0.85rem;
    }

    .auth-logo {
        width: 180px;
    }

    .login-card {
        padding: 1.4rem;
    }

        .login-card h1 {
            font-size: 1.4rem;
        }
}
