@font-face {
    font-family: "Montserrat";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/montserrat-latin-400-normal.woff2") format("woff2");
}

@font-face {
    font-family: "Montserrat";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/montserrat-latin-500-normal.woff2") format("woff2");
}

@font-face {
    font-family: "Montserrat";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/montserrat-latin-600-normal.woff2") format("woff2");
}

:root {
    --brand: #5e80d6;
    --brand-strong: #4a6bc4;
    --brand-soft: rgba(94, 128, 214, 0.14);
    --ink: #1f2937;
    --ink-soft: #4b5563;
    --ink-muted: #6b7280;
    --line: #d7dce5;
    --surface: #ffffff;
    --page: #ffffff;
    --soft: #f4f6fb;
    --ok-bg: #e9f8ef;
    --ok-ink: #166534;
    --err-bg: #fdecec;
    --err-ink: #991b1b;
    --radius: 12px;
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--page);
    color: var(--ink);
    font-family: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

[hidden] {
    display: none !important;
}

.page {
    width: 100%;
    max-width: 460px;
    margin: 0 auto;
    padding: 20px 16px 32px;
}

.topbar {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 56px;
    margin-bottom: 16px;
}

.logo {
    display: block;
    width: auto;
    max-width: 150px;
    max-height: 64px;
}

.lang-switch {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    gap: 4px;
}

.lang-switch a {
    padding: 4px 8px;
    border-radius: 999px;
    color: var(--ink-muted);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
}

.lang-switch a[aria-current="true"] {
    background: var(--brand-soft);
    color: var(--brand-strong);
}

.steps {
    display: flex;
    justify-content: space-between;
    margin: 0 0 16px;
    padding: 0;
    list-style: none;
    counter-reset: none;
}

.steps li {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    position: relative;
    color: var(--ink-muted);
    font-size: 12px;
}

.steps li + li::before {
    content: "";
    position: absolute;
    top: 13px;
    right: 50%;
    width: 100%;
    height: 2px;
    background: var(--line);
    z-index: 0;
}

.steps li.is-done + li::before,
.steps li.is-done + li.is-current::before {
    background: var(--brand);
}

.steps-dot {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--line);
    background: var(--surface);
    font-weight: 600;
}

.steps li.is-current {
    color: var(--ink);
    font-weight: 500;
}

.steps li.is-current .steps-dot {
    border-color: var(--brand);
    color: var(--brand);
}

.steps li.is-done .steps-dot {
    border-color: var(--brand);
    background: var(--brand);
    color: #fff;
}

.card {
    background: var(--surface);
    border: 1px solid #e5e9f2;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(31, 41, 55, 0.07);
    padding: 24px 20px;
}

h1 {
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
}

.lead {
    margin: 0 0 18px;
    color: var(--ink-soft);
    text-align: center;
}

.form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.field label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-soft);
}

input[type="text"],
input[type="email"],
input[type="tel"] {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 16px; /* evita lo zoom automatico su iOS */
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}

.otp-input {
    text-align: center;
    font-size: 28px !important;
    font-weight: 600;
    letter-spacing: 0.4em;
    padding: 14px 8px 14px calc(8px + 0.4em) !important;
}

.hint {
    margin: 6px 0 0;
    color: var(--ink-muted);
    font-size: 13px;
}

.hint-box {
    margin-top: 16px;
    padding: 10px 12px;
    border-radius: var(--radius);
    background: var(--soft);
}

.check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
    color: var(--ink-soft);
    cursor: pointer;
}

.check input {
    flex: none;
    width: 20px;
    height: 20px;
    margin: 1px 0 0;
    accent-color: var(--brand);
}

a {
    color: var(--brand-strong);
    font-weight: 500;
}

.btn {
    display: block;
    width: 100%;
    padding: 13px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.btn-primary {
    background: var(--brand);
    color: #fff;
}

.btn-primary:hover {
    background: var(--brand-strong);
}

.btn-secondary {
    background: var(--surface);
    border-color: var(--line);
    color: var(--ink);
}

.btn-link {
    background: none;
    color: var(--brand-strong);
    font-weight: 500;
    padding: 8px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.btn.is-loading {
    opacity: 0.8;
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 16px;
}

.alert-slot:empty {
    display: none;
}

.alert {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 14px;
}

.alert-ok {
    background: var(--ok-bg);
    color: var(--ok-ink);
}

.alert-error {
    background: var(--err-bg);
    color: var(--err-ink);
}

.center {
    text-align: center;
}

.center .btn {
    margin-top: 8px;
}

.spinner {
    width: 44px;
    height: 44px;
    margin: 4px auto 16px;
    border: 4px solid var(--brand-soft);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

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

.badge-ok {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    margin: 4px auto 16px;
    border-radius: 50%;
    background: var(--ok-bg);
    color: var(--ok-ink);
}

.prose p {
    margin: 0 0 12px;
    color: var(--ink-soft);
}

.dialog {
    width: min(560px, calc(100% - 32px));
    max-height: calc(100vh - 48px);
    padding: 22px 20px;
    border: none;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(31, 41, 55, 0.25);
    color: var(--ink);
}

.dialog::backdrop {
    background: rgba(17, 24, 39, 0.45);
}

.dialog h2 {
    margin: 0 0 12px;
    font-size: 19px;
    font-weight: 600;
}

.dialog-body {
    max-height: 55vh;
    overflow-y: auto;
    margin-bottom: 16px;
    color: var(--ink-soft);
    font-size: 14px;
}

@media (max-width: 360px) {
    .row-2 {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    .spinner {
        animation-duration: 3s;
    }
}
