:root {
    color-scheme: light;
    font-family: "Segoe UI", system-ui, sans-serif;
    color: #17202a;
    background: #f4f7f9;
    --blue: #0067a8;
    --blue-dark: #06496f;
    --border: #d8e1e8;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
a { color: var(--blue-dark); }
.site-header {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 9000;
    background: rgba(255, 255, 255, .96);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 .5rem 1.9rem rgba(29, 58, 82, .08);
    backdrop-filter: blur(12px);
}
.site-header-inner, .site-main, .site-footer-inner { width: min(72.5rem, calc(100% - 2.25rem)); margin: 0 auto; }
.site-header-inner { min-height: 5.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1.25rem; }
.brand { flex: 0 0 auto; text-decoration: none; }
.brand img { width: 13.4rem; display: block; }
.site-header-content { min-width: 0; display: flex; align-items: center; justify-content: flex-end; gap: 1rem; }
.site-context { max-width: 16rem; overflow: hidden; padding: .45rem .8rem; border: 1px solid #dce8f2; border-radius: 999px; background: #f4f9fd; color: #456075; font-size: .86rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.site-navigation { min-width: 0; display: flex; gap: .8rem; align-items: center; color: #526673; font-size: .9rem; white-space: nowrap; }
.site-navigation a, .site-navigation .link-button { font-weight: 650; text-decoration: none; }
.site-navigation a:hover, .site-navigation .link-button:hover { color: var(--blue); text-decoration: underline; }
.site-navigation form { display: inline; margin: 0; }
.site-user { max-width: 13rem; overflow: hidden; text-overflow: ellipsis; }
.link-button { border: 0; padding: 0; background: none; color: var(--blue-dark); cursor: pointer; font: inherit; text-decoration: underline; }
.site-main { min-height: 100vh; padding: 7.9rem 0 6.8rem; }
.hero { max-width: 50rem; margin-bottom: 3rem; }
.hero h1 { margin: .25rem 0 1rem; font-size: clamp(2.2rem, 6vw, 4.6rem); line-height: 1.02; letter-spacing: -.04em; }
.eyebrow { color: var(--blue); font-weight: 700; letter-spacing: .12em; font-size: .78rem; }
.lede { max-width: 44rem; font-size: 1.25rem; line-height: 1.6; color: #44515c; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; }
.card { padding: 1.5rem; background: #fff; border: 1px solid var(--border); border-radius: .8rem; box-shadow: 0 .4rem 1.4rem rgba(30, 55, 70, .06); }
.card h2 { margin-top: 0; }
.button { display: inline-block; border: 0; border-radius: .35rem; padding: .75rem 1.15rem; background: var(--blue); color: #fff; font: inherit; font-weight: 650; text-decoration: none; cursor: pointer; }
.button.secondary { background: #526673; }
.button.danger { background: #9d291f; color: #fff; }
.button:disabled { opacity: .7; cursor: wait; }
button[aria-disabled="true"], a.button[aria-disabled="true"] { opacity: .7; cursor: wait; }
button[aria-busy="true"]::before, a.button[aria-busy="true"]::before {
    content: "";
    display: inline-block;
    flex: 0 0 auto;
    width: 1em;
    height: 1em;
    margin-right: .55em;
    border: .15em solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    vertical-align: -.15em;
    animation: button-spin .8s linear infinite;
}
@keyframes button-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    button[aria-busy="true"]::before, a.button[aria-busy="true"]::before { animation: none; }
}
.auth-shell { display: grid; place-items: center; min-height: 60vh; }
.auth-card { display: grid; width: min(28rem, 100%); gap: .65rem; }
.auth-card h1 { margin: 0; font-size: 2.4rem; }
.project-invite-registration-card { width: min(50rem, 100%); }
.project-invite-registration-form, .form-field { display: grid; gap: .55rem; }
.project-invite-registration-actions { display: flex; flex-wrap: wrap; gap: .65rem; margin-top: .35rem; }
.project-invite-registration-actions .button { text-align: center; }
.login-progress { margin: 0; color: #44515c; }
.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1rem; margin-top: .35rem; }
.account-choice-list { display: grid; gap: .55rem; margin: .35rem 0; }
.account-choice-list form { margin: 0; }
.account-choice { width: 100%; display: flex; align-items: center; gap: .8rem; padding: .75rem; border: 1px solid #c9d5de; border-radius: .45rem; background: #fff; color: inherit; cursor: pointer; font: inherit; text-align: left; }
.account-choice:hover, .account-choice:focus-visible { border-color: var(--blue); background: #f4f9fd; }
.account-choice-avatar { flex: 0 0 2.35rem; display: grid; place-items: center; width: 2.35rem; height: 2.35rem; border-radius: 50%; background: var(--blue); color: #fff; font-weight: 750; }
.account-choice-text { min-width: 0; display: grid; gap: .1rem; flex: 1; }
.account-choice-text strong, .account-choice-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-choice-text span { color: #526673; font-size: .88rem; }
.account-choice-current { flex: 0 0 auto; color: #456075; font-size: .78rem; font-weight: 700; }
.account-choice-other { width: 100%; text-align: center; }
.selected-account { display: flex; align-items: center; gap: .8rem; padding: .65rem 0; }
.login-different-account { justify-self: start; font-size: .9rem; }
label { font-weight: 650; margin-top: .4rem; }
input, textarea { width: 100%; padding: .75rem; border: 1px solid #aebbc5; border-radius: .35rem; font: inherit; }
textarea { resize: vertical; }
select { width: 100%; padding: .7rem; border: 1px solid #aebbc5; border-radius: .35rem; background: #fff; font: inherit; }
.checkbox { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
.checkbox input { width: auto; }
.validation { color: #a3231a; }
.validation-summary-valid { display: none; }
.validation-summary-errors li:empty { display: none; }
.notice { margin: 1rem 0; padding: .8rem 1rem; border-radius: .35rem; }
.success { color: #155a38; background: #e5f5ec; }
.warning { color: #6b4b00; background: #fff3cd; }
.error { color: #842029; background: #f8d7da; }
.danger { color: #9d291f; }
.hero.compact h1 { font-size: clamp(2rem, 4vw, 3.2rem); }
.manage-section { margin-top: 2.25rem; }
.manage-section-heading { max-width: 46rem; margin-bottom: 1rem; }
.manage-section-heading .eyebrow { margin: 0 0 .3rem; }
.manage-section-heading h2 { margin: 0 0 .4rem; font-size: clamp(1.55rem, 3vw, 2rem); }
.manage-section-heading > p:last-child { margin: 0; color: #526673; }
.account-details-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
.security-settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.security-settings-grid > .password-change-form { grid-column: 1 / -1; }
.account-details-grid > form { display: flex; flex-direction: column; gap: .6rem; }
.account-details-grid > form > .button { margin-top: auto; }
.security-settings-grid .password-change-form, .security-settings-grid .card > form { display: grid; align-content: start; gap: .6rem; }
.session-card { display: flex; align-items: center; justify-content: space-between; gap: 2rem; margin-top: 2.25rem; }
.session-card h2 { margin-bottom: .45rem; }
.session-card p:not(.eyebrow) { margin: 0; }
.session-card form { flex: 0 0 auto; }
.password-input-wrap { position: relative; }
.password-input-wrap input { padding-right: 5.5rem; }
.password-toggle { position: absolute; top: 50%; right: .65rem; transform: translateY(-50%); border: 0; padding: .3rem; background: transparent; color: var(--blue-dark); cursor: pointer; font: inherit; font-size: .82rem; font-weight: 650; }
.password-generator { display: grid; gap: .75rem; margin-top: .35rem; padding: 1rem; border: 1px solid var(--border); border-radius: .5rem; background: #f7fafc; }
.password-generator > div:first-child { display: grid; gap: .25rem; color: #44515c; font-size: .9rem; }
.password-generator > div:first-child strong { color: #17202a; }
.password-tool-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.password-tool-actions .button { padding: .6rem .8rem; font-size: .86rem; }
.password-tool-actions .button:disabled { cursor: not-allowed; }
.password-feedback { margin: 0; color: #155a38; font-size: .88rem; }
.password-feedback.is-error { color: #a3231a; }
.password-rules { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .35rem 1rem; margin: .15rem 0 .5rem; padding: 0; list-style: none; color: #526673; font-size: .88rem; }
.password-rules li::before { content: "\2717"; display: inline-block; width: 1.25rem; color: #a3231a; font-weight: 700; }
.password-rules li.valid { color: #155a38; }
.password-rules li.valid::before { content: "\2713"; color: #16804b; }
.security-code { padding: .7rem; background: #eef3f6; border-radius: .35rem; letter-spacing: .1em; }
.authenticator-qr { display: block; max-width: 100%; height: auto; margin: .8rem auto; padding: .5rem; border: 1px solid var(--border); border-radius: .5rem; background: #fff; }
.break-all { overflow-wrap: anywhere; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: .35rem 1rem; }
.danger-zone, .admin-section { margin-top: 1rem; }
.session-list { display: grid; margin-top: 1rem; border-top: 1px solid var(--border); }
.session-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--border); }
.session-row p { margin: .25rem 0 0; color: #526673; font-size: .88rem; }
.session-current { display: inline-block; margin-left: .5rem; padding: .15rem .45rem; border-radius: 999px; background: #e5f5ec; color: #155a38; font-size: .72rem; font-weight: 700; }
.account-disable-card { display: grid; gap: 1rem; margin-top: 2.25rem; border-color: #e2b5b0; }
.account-disable-card details { max-width: 34rem; }
.disable-account-form { display: grid; gap: .6rem; margin-top: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; align-items: end; }
.section-heading, .inline-form { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; }
.inline-form input { min-width: 18rem; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .75rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.actions-cell { display: grid; gap: .45rem; min-width: 10rem; }
.actions-cell form { margin: 0; }
.assistance-reason { grid-column: 1 / -1; }
.assistance-revoke-form { display: grid; gap: .45rem; min-width: 14rem; }
.assistance-revoke-form .button { width: 100%; padding: .55rem .8rem; }
.site-organization { max-width: 10rem; overflow: hidden; padding: .18rem .45rem; border-radius: 999px; background: #e5f5ec; color: #155a38; font-size: .75rem; font-weight: 700; text-overflow: ellipsis; }
.organization-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; }
.organization-card { display: grid; gap: 1rem; align-content: space-between; }
.organization-card.is-current { border-color: #69a888; box-shadow: 0 0 0 2px rgba(39, 132, 84, .08); }
.organization-card h2 { margin-bottom: .35rem; }
.organization-card p { margin: .25rem 0; }
.organization-card form { margin: 0; }
.organization-current { width: fit-content; padding: .25rem .55rem; border-radius: 999px; background: #e5f5ec; color: #155a38; font-size: .78rem; font-weight: 700; }
.field-help { color: #526673; font-size: .88rem; }
.member-search { justify-content: flex-end; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.25rem; }
.pagination .button { padding: .55rem .8rem; }
.access-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr)); gap: 1rem; margin-top: 1rem; }
.access-card { display: grid; align-content: start; gap: 1rem; }
.access-card h3, .access-card h4 { margin: 0; }
.access-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.access-card-heading p { margin: .3rem 0 0; color: #526673; }
.count-badge, .client-badge { display: inline-block; width: fit-content; padding: .2rem .5rem; border-radius: 999px; background: #eef3f6; color: #456075; font-size: .75rem; font-weight: 700; }
.client-badge { margin-bottom: .45rem; background: #e8f2fa; color: var(--blue-dark); }
.access-add-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: .6rem; }
.access-add-form .button { white-space: nowrap; }
.access-assignment-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.access-assignment-grid > section { display: grid; align-content: start; gap: .65rem; padding: .85rem; border: 1px solid var(--border); border-radius: .5rem; }
.assignment-list { display: grid; gap: .35rem; margin: 0; padding: 0; list-style: none; }
.assignment-list li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.assignment-list li > span { min-width: 0; display: grid; }
.assignment-list small { overflow: hidden; color: #526673; text-overflow: ellipsis; }
.assignment-list form { flex: 0 0 auto; margin: 0; }
.access-disable-form { margin-top: .25rem; padding-top: .75rem; border-top: 1px solid var(--border); }
.site-footer { position: fixed; right: 0; bottom: 0; left: 0; z-index: 9000; background: #122c40; color: #dce8f1; border-top: 1px solid #24465f; box-shadow: 0 -.45rem 1.5rem rgba(18, 44, 64, .12); }
.site-footer-inner { min-height: 4.15rem; padding: .85rem 1.1rem; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .25rem .5rem; font-size: .75rem; line-height: 1.45; text-align: center; }
.site-footer-separator { color: #6f91aa; }
code { word-break: break-word; }

@media (max-width: 760px) {
    .site-header-inner { min-height: 5rem; gap: .65rem; }
    .brand img { width: 9.8rem; }
    .site-header-content { min-width: 0; display: grid; justify-items: end; gap: .25rem; }
    .site-context { max-width: 10.5rem; padding: .35rem .55rem; font-size: .72rem; }
    .site-navigation { max-width: 10.5rem; overflow-x: auto; gap: .65rem; font-size: .75rem; scrollbar-width: thin; }
    .site-user { display: none; }
    .site-main { padding-top: 6.6rem; padding-bottom: 9.5rem; }
    .site-footer-inner { min-height: 7.75rem; flex-direction: column; gap: .1rem; }
    .site-footer-separator { display: none; }
    .password-rules { grid-template-columns: 1fr; }
    .project-invite-registration-actions { display: grid; }
    .account-details-grid, .security-settings-grid { grid-template-columns: 1fr; }
    .session-card { align-items: stretch; flex-direction: column; gap: 1rem; }
    .session-card .button { width: 100%; }
    .session-row { align-items: flex-start; }
    .access-grid, .access-assignment-grid { grid-template-columns: 1fr; }
    .access-add-form { grid-template-columns: 1fr; }
}


/* Le finestre di accesso strette mantengono tutto il contenuto scorrevole. */
@media (max-width: 640px) {
    .portal-shell:has(> .site-main > .auth-shell) { display: flex; flex-direction: column; }
    .portal-shell:has(> .site-main > .auth-shell) .site-header,
    .portal-shell:has(> .site-main > .auth-shell) .site-footer { position: static; box-shadow: none; }
    .portal-shell:has(> .site-main > .auth-shell) .site-main { flex: 1; min-height: 0; padding: 1.25rem 0; }
    .portal-shell:has(> .site-main > .auth-shell) .site-context { display: none; }
    .portal-shell:has(> .site-main > .auth-shell) .site-footer-inner { min-height: 0; flex-direction: row; padding: .85rem 0; gap: .2rem .65rem; }
    .auth-shell { min-height: 0; align-content: start; gap: 1rem; }
    .auth-card { padding: 1.25rem; }
    .auth-card h1 { font-size: 2rem; }
    .auth-card h2 { margin-bottom: .35rem; font-size: 1.3rem; }
    .auth-card > p { margin: .35rem 0; }
    .auth-card .validation:empty { display: none; }
}
/* Login e scelta account dedicano l'intera finestra al modulo di accesso. */
.portal-shell:has(.account-chooser, [data-login-form]) > .site-header,
.portal-shell:has(.account-chooser, [data-login-form]) > .site-footer { display: none; }
.portal-shell:has(> .site-main .account-chooser, > .site-main [data-login-form]) > .site-main {
    min-height: 100vh;
    padding: 1rem 0;
}
.portal-shell:has(.account-chooser, [data-login-form]) .auth-shell {
    min-height: 0;
    align-content: start;
    gap: 1rem;
}
.secret-value {
    display: block;
    margin-top: .75rem;
    overflow-wrap: anywhere;
    user-select: all;
}

.destructive-actions form {
    border-top: 1px solid var(--border, #d9dfe8);
    padding-top: .5rem;
}

.destructive-actions input {
    max-width: 15rem;
}
