/* Login v3 + account administration. Design tokens match the v2 login page. */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --accent: #00d377;
    --accent-dark: #00a85e;
    --accent-soft: rgba(0, 211, 119, 0.12);
    --text-primary: #1a1a2e;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --border: #e2e8f0;
    --error-bg: #fff1f2;
    --error-border: #fecdd3;
    --error-text: #be123c;
    --success-bg: #f0fdf9;
    --success-border: #a7f3d0;
    --success-text: #065f46;
    --warning-bg: #fffbeb;
    --warning-border: #fde68a;
    --warning-text: #92400e;
    --radius: 0.625rem;
    --shadow-pop: 0 10px 30px rgba(15, 23, 42, 0.14);
}

body {
    min-height: 100vh;
    font-family: 'DM Sans', sans-serif;
    background: var(--surface);
    color: var(--text-primary);
}

button {
    font-family: inherit;
}

/* ---------- split layout (login) ---------- */

.auth-split {
    display: flex;
    min-height: 100vh;
}

.panel-left {
    width: 52%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 3rem 4rem;
    position: relative;
}

.panel-right {
    width: 48%;
    background: var(--surface-alt);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-left: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

    .panel-right::before {
        content: '';
        position: absolute;
        inset: 0;
        background: radial-gradient(ellipse at 20% 80%, rgba(0,211,119,0.06) 0%, transparent 60%), radial-gradient(ellipse at 80% 20%, rgba(0,211,119,0.04) 0%, transparent 60%);
        pointer-events: none;
    }

.logo-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

    .logo-wrap img.logo {
        max-width: 30rem;
        width: 80%;
        opacity: 0.92;
    }

.login-box {
    width: 100%;
    max-width: 28rem;
    animation: slideUp 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
}

.heading {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.subheading {
    margin-top: 0.4rem;
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 1rem;
    padding: 0.35rem 0.85rem;
    background: var(--success-bg);
    border: 1px solid var(--success-border);
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--success-text);
}

    .badge svg {
        width: 15px;
        height: 15px;
    }

.steps-list {
    margin-top: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

    .steps-list a {
        color: var(--accent-dark);
        font-weight: 600;
    }

/* ---------- language switcher ---------- */

.lang-switcher {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 20;
}

.lang-switcher-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.75rem;
    background: var(--surface-alt);
    border: 1.5px solid var(--border);
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
}

    .lang-switcher-toggle:hover {
        border-color: var(--accent);
        color: var(--text-primary);
    }

.lang-switcher-menu {
    display: none;
    position: absolute;
    top: calc(100% + 0.4rem);
    right: 0;
    min-width: 9rem;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-pop);
    overflow: hidden;
}

    .lang-switcher-menu.open {
        display: block;
    }

.lang-option {
    display: block;
    width: 100%;
    padding: 0.6rem 0.9rem;
    border: none;
    background: none;
    font-size: 0.9375rem;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
}

    .lang-option:hover,
    .lang-option.active {
        background: var(--surface-alt);
    }

    .lang-option.active {
        font-weight: 600;
        color: var(--accent-dark);
    }

/* ---------- alerts ---------- */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    border-radius: var(--radius);
    margin-top: 1.25rem;
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.45;
}

.alert-error { background: var(--error-bg); border: 1px solid var(--error-border); color: var(--error-text); }
.alert-success { background: var(--success-bg); border: 1px solid var(--success-border); color: var(--success-text); }
.alert-warning { background: var(--warning-bg); border: 1px solid var(--warning-border); color: var(--warning-text); }

.alert ul {
    margin: 0.25rem 0 0 1rem;
}

.alert[hidden] {
    display: none;
}

/* ---------- forms ---------- */

.form-group {
    margin-top: 1.35rem;
    position: relative;
}

label {
    display: block;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.45rem;
}

.field-hint {
    margin-top: 0.35rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select {
    width: 100%;
    padding: 0.95rem 1.1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1.0625rem;
    color: var(--text-primary);
    background: var(--surface);
    transition: border-color 0.18s, box-shadow 0.18s;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1.1rem center;
    padding-right: 2.5rem;
    cursor: pointer;
}

input[type="number"],
input.code-input {
    font-family: 'DM Mono', monospace;
    letter-spacing: 0.3em;
    font-size: 1.25rem;
    text-align: center;
}

input:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

input::placeholder {
    color: var(--text-muted);
}

input.is-valid {
    border-color: var(--accent);
}

input.is-invalid {
    border-color: var(--error-text);
}

    input.is-invalid:focus {
        box-shadow: 0 0 0 3px rgba(190, 18, 60, 0.12);
    }

.password-wrap {
    position: relative;
}

    .password-wrap input {
        padding-right: 3.25rem;
    }

.password-toggle {
    position: absolute;
    top: 50%;
    right: 0.6rem;
    transform: translateY(-50%);
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    border-radius: 0.4rem;
    color: var(--text-muted);
    cursor: pointer;
}

    .password-toggle:hover {
        color: var(--text-primary);
        background: var(--surface-alt);
    }

    .password-toggle svg {
        width: 20px;
        height: 20px;
    }

.btn-primary {
    margin-top: 1.6rem;
    width: 100%;
    padding: 0.95rem 1.25rem;
    background: var(--accent);
    color: #fff;
    font-size: 1.0625rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.18s, transform 0.12s, box-shadow 0.18s, opacity 0.18s;
    box-shadow: 0 2px 8px rgba(0, 211, 119, 0.25);
}

    .btn-primary:hover:not(:disabled) {
        background: var(--accent-dark);
        box-shadow: 0 4px 16px rgba(0, 211, 119, 0.3);
    }

    .btn-primary:active:not(:disabled) {
        transform: scale(0.985);
    }

    .btn-primary:disabled {
        opacity: 0.55;
        cursor: not-allowed;
        box-shadow: none;
    }

.btn-secondary {
    padding: 0.45rem 0.85rem;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
}

    .btn-secondary:hover:not(:disabled) {
        border-color: var(--accent);
        color: var(--text-primary);
    }

    .btn-secondary:disabled {
        opacity: 0.45;
        cursor: not-allowed;
    }

.link-back {
    display: inline-block;
    margin-top: 1.25rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
}

    .link-back:hover {
        color: var(--accent-dark);
    }

.code-hint {
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    text-align: center;
}

/* ---------- live checklist (password rules, availability popup) ---------- */

.checklist {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.875rem;
}

    .checklist li {
        display: flex;
        align-items: center;
        gap: 0.55rem;
        color: var(--text-secondary);
        transition: color 0.15s;
    }

        .checklist li::before {
            content: '';
            flex-shrink: 0;
            width: 1.1rem;
            height: 1.1rem;
            border-radius: 50%;
            border: 1.5px solid var(--border);
            background: var(--surface) center / 0.65rem no-repeat;
            transition: background-color 0.15s, border-color 0.15s;
        }

        .checklist li.ok {
            color: var(--success-text);
        }

            .checklist li.ok::before {
                border-color: var(--accent);
                background-color: var(--accent);
                background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 10'%3E%3Cpath d='M1 5l3.5 3.5L11 1.5' stroke='white' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
            }

        .checklist li.bad {
            color: var(--error-text);
        }

            .checklist li.bad::before {
                border-color: var(--error-text);
                background-color: var(--error-text);
                background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M2 2l6 6M8 2l-6 6' stroke='white' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
            }

        .checklist li.pending::before {
            border-color: var(--accent);
            border-top-color: transparent;
            animation: spin 0.7s linear infinite;
        }

@keyframes spin {
    to { transform: rotate(360deg); }
}

.password-rules {
    margin-top: 0.9rem;
    padding: 0.9rem 1rem;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.input-anchor {
    position: relative;
}

/* Availability popup for the email input. It opens upwards, over the field label, so it never
   covers the username field below or pushes the page down; it is only shown while the email
   field has focus. */
.check-popover {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 0.6rem);
    z-index: 30;
    padding: 0.9rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-pop);
}

    /* Arrow on the bottom edge, pointing down at the input. */
    .check-popover::before {
        content: '';
        position: absolute;
        bottom: -6px;
        left: 1.5rem;
        width: 10px;
        height: 10px;
        background: var(--surface);
        border-right: 1px solid var(--border);
        border-bottom: 1px solid var(--border);
        transform: rotate(45deg);
    }

    .check-popover.open {
        display: block;
        animation: popUp 0.15s ease-out;
    }

@keyframes popUp {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes popIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- QR (MFA setup) ---------- */

.qr-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

    .qr-wrap img {
        width: 210px;
        height: 210px;
        border-radius: 0.75rem;
        border: 4px solid #fff;
        box-shadow: 0 4px 24px rgba(0,0,0,0.10);
    }

.qr-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.manual-code {
    padding: 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: 'DM Mono', monospace;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
    word-break: break-all;
    letter-spacing: 0.05em;
    user-select: all;
}

/* ---------- admin page ---------- */

.admin-shell {
    min-height: 100vh;
    background: var(--surface-alt);
}

.admin-topbar {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 2rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

    .admin-topbar .lang-switcher {
        position: relative;
        top: auto;
        right: auto;
    }

    .admin-topbar .link-back {
        margin-top: 0;
    }

.admin-main {
    max-width: 100rem;
    margin: 0 auto;
    padding: 2.25rem 2rem 4rem;
}

/* Inside the application (/AccountsAdmin): the frame is already below the application menus. */
.admin-shell.admin-embedded {
    min-height: 0;
}

    .admin-embedded .admin-main {
        position: relative;
        padding: 1.5rem 1.75rem 2.5rem;
    }

    .admin-embedded .admin-embedded-lang .lang-switcher {
        top: 1.25rem;
        right: 1.75rem;
    }

.admin-grid {
    margin-top: 1.75rem;
    display: grid;
    grid-template-columns: minmax(0, 26rem) minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.875rem;
    padding: 1.6rem;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 700;
}

.card .form-group:first-of-type {
    margin-top: 1rem;
}

.card input,
.card select {
    font-size: 1rem;
    padding: 0.8rem 1rem;
}

.table-wrap {
    position: relative; /* keeps absolutely positioned cells (e.g. .visually-hidden labels) inside the scroll, not widening the page */
    margin-top: 1rem;
    overflow-x: auto;
}

table.invitations {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

    table.invitations th {
        padding: 0.6rem 0.75rem;
        text-align: left;
        font-size: 0.75rem;
        font-weight: 700;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        color: var(--text-muted);
        border-bottom: 1px solid var(--border);
        white-space: nowrap;
    }

    table.invitations td {
        padding: 0.85rem 0.75rem;
        border-bottom: 1px solid var(--border);
        vertical-align: middle;
    }

    table.invitations tr:last-child td {
        border-bottom: none;
    }

    table.invitations tr.flash td {
        animation: flash 1.6s ease-out;
    }

@keyframes flash {
    from { background: var(--success-bg); }
    to { background: transparent; }
}

.user-cell strong {
    display: block;
    font-weight: 600;
}

.user-cell span,
.muted {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.status-pill {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-pending { background: var(--warning-bg); color: var(--warning-text); border: 1px solid var(--warning-border); }
.status-expired { background: var(--error-bg); color: var(--error-text); border: 1px solid var(--error-border); }
.status-active { background: var(--success-bg); color: var(--success-text); border: 1px solid var(--success-border); }

.status-neutral { background: var(--surface-alt); color: var(--text-secondary); border: 1px solid var(--border); }

/* ---------- existing users (reconfirmation) ---------- */

.existing-card {
    margin-top: 1.5rem;
}

.card-subtitle {
    margin-top: 0.35rem;
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.toolbar {
    margin-top: 1rem;
    max-width: 26rem;
}

    .toolbar input {
        font-size: 1rem;
        padding: 0.75rem 1rem;
        width: 100%;
        border: 1.5px solid var(--border);
        border-radius: var(--radius);
        font-family: inherit;
        outline: none;
    }

        .toolbar input:focus {
            border-color: var(--accent);
            box-shadow: 0 0 0 3px var(--accent-soft);
        }

.col-check {
    width: 2.5rem;
}

    .col-check input {
        width: 1.05rem;
        height: 1.05rem;
        accent-color: var(--accent);
        cursor: pointer;
    }

table.invitations tr.is-selected td {
    background: var(--success-bg);
}

table.existing-users td.email-cell {
    min-width: 15rem; /* an address on one line; the table scrolls inside its card when the page is narrow */
}

.email-line {
    display: flex;
    flex-wrap: wrap; /* in a narrow column the badge goes below, instead of squeezing the email to one letter per line */
    align-items: center;
    gap: 0.25rem 0.4rem;
    word-break: break-all;
}

.email-edit-wrap {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 15rem;
}

input.email-edit {
    font-size: 0.9375rem;
    padding: 0.5rem 0.7rem;
    border-radius: 0.5rem;
}

.icon-btn {
    flex-shrink: 0;
    width: 1.9rem;
    height: 1.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 0.4rem;
    background: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
}

    .icon-btn:hover:not(:disabled) {
        border-color: var(--border);
        background: var(--surface-alt);
        color: var(--text-primary);
    }

    .icon-btn:disabled {
        opacity: 0.35;
        cursor: not-allowed;
    }

    .icon-btn.save-email:not(:disabled) {
        color: #fff;
        background: var(--accent);
        font-weight: 700;
    }

        .icon-btn.save-email:not(:disabled):hover {
            background: var(--accent-dark);
            color: #fff;
        }

    .icon-btn.is-busy {
        cursor: progress;
    }

.tag-muted {
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

table.existing-users tbody {
    transition: opacity 0.15s;
}

table.existing-users.is-loading tbody {
    opacity: 0.5;
    pointer-events: none;
}

.field-error {
    margin-top: 0.25rem;
    font-size: 0.8125rem;
    color: var(--error-text);
}

    .field-error:empty {
        display: none;
    }

.pager {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.btn-link {
    border: none;
    background: none;
    padding: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--accent-dark);
    cursor: pointer;
}

    .btn-link:hover {
        text-decoration: underline;
    }

/* Stays in view while the admin scrolls through pages of users. */
.bulk-bar {
    position: sticky;
    bottom: 1rem;
    z-index: 10;
    margin-top: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem 1.5rem;
    padding: 0.9rem 1.1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.875rem;
    box-shadow: var(--shadow-pop);
}

    .bulk-bar[hidden] {
        display: none;
    }

.bulk-count {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.bulk-language {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0;
    font-size: 0.875rem;
}

    .bulk-language select {
        width: auto;
        font-size: 0.9375rem;
        padding: 0.55rem 2.4rem 0.55rem 0.8rem;
    }

.btn-primary.btn-inline {
    width: auto;
    margin: 0 0 0 auto;
    padding: 0.7rem 1.25rem;
    font-size: 0.9375rem;
}

.empty-state {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--text-muted);
}

/* ---------- searchable select (PrimeNG p-select look) ---------- */

.v3-select {
    position: relative;
}

.v3-select-native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    border: 0 !important;
}

.v3-select-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.8rem 1rem;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font: inherit;
    font-size: 1rem;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    transition: border-color 0.18s, box-shadow 0.18s;
}

    .v3-select-trigger:hover:not(:disabled) {
        border-color: #cbd5e1;
    }

    .v3-select-trigger:focus-visible,
    .v3-select.is-open .v3-select-trigger {
        outline: none;
        border-color: var(--accent);
        box-shadow: 0 0 0 3px var(--accent-soft);
    }

    .v3-select-trigger.is-placeholder .v3-select-label {
        color: var(--text-muted);
    }

    .v3-select-trigger:disabled {
        background: var(--surface-alt);
        color: var(--text-muted);
        cursor: not-allowed;
    }

.v3-select-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.v3-select-chevron {
    flex-shrink: 0;
    width: 12px;
    height: 8px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
    transition: transform 0.15s;
}

.v3-select.is-open .v3-select-chevron {
    transform: rotate(180deg);
}

.v3-select-panel {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 0.35rem);
    z-index: 40;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-pop);
    overflow: hidden;
    animation: popIn 0.12s ease-out;
}

.v3-select.opens-up .v3-select-panel {
    top: auto;
    bottom: calc(100% + 0.35rem);
}

.v3-select-filter-wrap {
    padding: 0.6rem;
    border-bottom: 1px solid var(--border);
}

input.v3-select-filter {
    padding: 0.6rem 0.8rem 0.6rem 2.2rem;
    font-size: 0.9375rem;
    border-radius: 0.5rem;
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") 0.7rem center no-repeat;
}

.v3-select-list {
    list-style: none;
    max-height: 15rem;
    overflow-y: auto;
    padding: 0.35rem;
    outline: none;
}

.v3-select-option {
    position: relative;
    padding: 0.6rem 2rem 0.6rem 0.75rem;
    border-radius: 0.4rem;
    font-size: 0.9375rem;
    color: var(--text-primary);
    cursor: pointer;
}

    .v3-select-option.is-active {
        background: var(--surface-alt);
    }

    .v3-select-option.is-placeholder {
        color: var(--text-muted);
    }

    .v3-select-option.is-selected {
        background: var(--success-bg);
        color: var(--success-text);
        font-weight: 600;
    }

        .v3-select-option.is-selected::after {
            content: '';
            position: absolute;
            right: 0.75rem;
            top: 50%;
            width: 12px;
            height: 10px;
            transform: translateY(-50%);
            background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 10'%3E%3Cpath d='M1 5l3.5 3.5L11 1.5' stroke='%2300a85e' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
        }

    .v3-select-option[aria-disabled="true"] {
        opacity: 0.45;
        cursor: not-allowed;
    }

.v3-select-empty {
    padding: 0.75rem;
    font-size: 0.9375rem;
    color: var(--text-muted);
    text-align: center;
}

/* ---------- edit user dialog ---------- */

.v3-dialog {
    width: min(30rem, calc(100vw - 2rem));
    margin: auto;
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 0.875rem;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
    color: var(--text-primary);
    font-family: inherit;
    overflow: visible;
}

    .v3-dialog::backdrop {
        background: rgba(15, 23, 42, 0.45);
    }

    .v3-dialog[open] {
        animation: popIn 0.15s ease-out;
    }

.v3-dialog-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.v3-dialog-footer {
    margin-top: 1.5rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

    .v3-dialog-footer .btn-secondary {
        padding: 0.7rem 1.1rem;
        font-size: 0.9375rem;
    }

    .v3-dialog-footer .btn-primary.btn-inline {
        margin: 0;
    }

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 0;
    cursor: pointer;
}

.switch-title {
    display: block;
    color: var(--text-primary);
}

.switch {
    position: relative;
    flex-shrink: 0;
    width: 2.75rem;
    height: 1.55rem;
}

    .switch input {
        position: absolute;
        inset: 0;
        opacity: 0;
        margin: 0;
        cursor: pointer;
    }

.switch-slider {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: #cbd5e1;
    transition: background 0.18s;
    pointer-events: none;
}

    .switch-slider::before {
        content: '';
        position: absolute;
        top: 3px;
        left: 3px;
        width: calc(1.55rem - 6px);
        height: calc(1.55rem - 6px);
        border-radius: 50%;
        background: #fff;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
        transition: transform 0.18s;
    }

.switch input:checked + .switch-slider {
    background: var(--accent);
}

    .switch input:checked + .switch-slider::before {
        transform: translateX(1.2rem);
    }

.switch input:focus-visible + .switch-slider {
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.switch input:disabled + .switch-slider {
    opacity: 0.5;
}

/* ---------- multi-select chips ---------- */

.v3-select.is-multiple .v3-select-label {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.35rem;
    min-width: 0;
}

.v3-chip {
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    background: var(--success-bg);
    border: 1px solid var(--success-border);
    color: var(--success-text);
    font-size: 0.875rem;
    font-weight: 600;
}

.v3-chip-more {
    flex-shrink: 0;
    background: var(--surface-alt);
    border-color: var(--border);
    color: var(--text-secondary);
}

/* Checkbox options in multi mode (no trailing check mark). */
.v3-select-option.is-multi {
    padding-left: 2.35rem;
    padding-right: 0.75rem;
}

    .v3-select-option.is-multi::before {
        content: '';
        position: absolute;
        left: 0.75rem;
        top: 50%;
        width: 1rem;
        height: 1rem;
        transform: translateY(-50%);
        border: 1.5px solid #cbd5e1;
        border-radius: 0.3rem;
        background: var(--surface) center / 0.65rem no-repeat;
    }

    .v3-select-option.is-multi.is-selected {
        background: transparent;
        color: var(--text-primary);
        font-weight: 600;
    }

        .v3-select-option.is-multi.is-selected.is-active {
            background: var(--surface-alt);
        }

        .v3-select-option.is-multi.is-selected::after {
            content: none;
        }

        .v3-select-option.is-multi.is-selected::before {
            border-color: var(--accent);
            background-color: var(--accent);
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 10'%3E%3Cpath d='M1 5l3.5 3.5L11 1.5' stroke='white' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
        }

/* ---------- invitations card: same height as the "new account" card ---------- */

/* The list shows at most 10 invitations and the rows are compact enough to fit next to the
   form, so it is never scrolled: both cards stretch to the taller of the two. */
.admin-grid {
    align-items: stretch;
}

/* ---------- compact email popup: covers only the username field ---------- */

.check-popover {
    padding: 0.65rem 0.85rem;
}

    .check-popover .checklist {
        gap: 0.3rem;
        font-size: 0.8125rem;
    }

        .check-popover .checklist li::before {
            width: 0.95rem;
            height: 0.95rem;
        }

/* ---------- compact "recent invitations" table: fits without horizontal scroll ---------- */

table.invitations-compact {
    table-layout: fixed;
    font-size: 0.875rem;
}

    table.invitations-compact th {
        padding: 0.5rem 0.5rem;
        font-size: 0.6875rem;
    }

    table.invitations-compact td {
        padding: 0.45rem 0.5rem;
        line-height: 1.35;
    }

    table.invitations-compact .status-pill + .muted {
        margin-top: 0.1rem;
    }

    /* Column widths: user | roles | status | last sent | action */
    table.invitations-compact th:nth-child(1) { width: 28%; }
    table.invitations-compact th:nth-child(2) { width: 24%; }
    table.invitations-compact th:nth-child(3) { width: 16%; }
    table.invitations-compact th:nth-child(4) { width: 18%; }
    table.invitations-compact th:nth-child(5) { width: 14%; }

    table.invitations-compact td:nth-child(5) {
        text-align: right;
    }

    table.invitations-compact .user-cell strong,
    table.invitations-compact .user-cell span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    table.invitations-compact .user-cell span {
        display: block;
    }

    table.invitations-compact .role-cell span {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    table.invitations-compact .status-pill {
        padding: 0.15rem 0.55rem;
        font-size: 0.75rem;
        white-space: normal;
    }

    table.invitations-compact .muted {
        font-size: 0.75rem;
    }

    table.invitations-compact td:nth-child(4) {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    table.invitations-compact .btn-secondary {
        padding: 0.35rem 0.6rem;
        font-size: 0.8125rem;
    }

/* ---------- grid extras ---------- */

.col-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

table.invitations tr.is-inactive td:not(.col-actions):not(.col-check) {
    opacity: 0.55;
}

/* While typing, the popup shows the details; the one-line hint takes no space until the
   field loses focus. */
#emailGroup.is-focused > .field-error {
    display: none;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

/* ---------- responsive ---------- */

@media (max-width: 960px) {
    .admin-grid {
        grid-template-columns: minmax(0, 1fr);
    }

}

@media (max-width: 768px) {
    .auth-split {
        flex-direction: column;
    }

    .panel-left {
        width: 100%;
        padding: 4.5rem 1rem 2rem;
    }

    .panel-right {
        display: none;
    }

    /* The QR code must stay reachable on phones during MFA setup. */
    .panel-right.keep-on-mobile {
        display: flex;
        width: 100%;
        padding: 2rem 1rem;
        border-left: none;
        border-top: 1px solid var(--border);
    }

    .heading {
        font-size: 1.65rem;
    }

    .admin-topbar {
        padding: 0.85rem 1rem;
    }

    .admin-main {
        padding: 1.5rem 1rem 3rem;
    }

    .card {
        padding: 1.25rem;
    }
}

@media (min-width: 2560px) {
    .login-box { max-width: 34rem; }
    .heading { font-size: 2.5rem; }
    .subheading, label { font-size: 1.125rem; }
}
