:root {
  --blue: #1d4ed8;
  --blue-dark: #1e40af;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f3f4f6;
  --red: #b91c1c;
  --green: #15803d;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
.hidden { display: none !important; }

.topbar { background: #fff; border-bottom: 1px solid var(--border); padding: 12px 20px; }
.brand { font-size: 20px; color: var(--blue); display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--blue); color: #fff; font-size: 16px; }

.container { max-width: 860px; margin: 24px auto; padding: 0 16px; }
.card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 16px; }
.card h2 { margin: 0 0 12px; font-size: 18px; }
.center { text-align: center; color: var(--muted); }
.error { border-color: #fecaca; background: #fef2f2; color: var(--red); }
.success { border-color: #bbf7d0; background: #f0fdf4; }
.success h2 { color: var(--green); }

.sender-text { white-space: pre-wrap; word-break: break-word; margin: 0 0 12px; line-height: 1.5; }
.sender-email { margin: 0; color: var(--muted); }

label { display: block; font-weight: 600; margin: 4px 0 6px; }
input { font-size: 17px; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 8px; width: 100%; }
input:focus { outline: 2px solid #93c5fd; border-color: var(--blue); }
input:disabled { background: #f3f4f6; color: var(--muted); }
.otp-input { letter-spacing: 8px; font-size: 22px; text-align: center; max-width: 220px; display: block; }

.phone-row { display: flex; gap: 8px; margin-bottom: 14px; }
.country { position: relative; }
.country-btn { height: 100%; display: flex; align-items: center; gap: 6px; padding: 0 10px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; font-size: 16px; cursor: pointer; white-space: nowrap; }
.country-btn:disabled { background: #f3f4f6; cursor: default; }
.country-btn::after { content: "▾"; color: var(--muted); font-size: 12px; }
.country-list { position: absolute; z-index: 10; top: calc(100% + 4px); left: 0; min-width: 180px; margin: 0; padding: 4px; list-style: none; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.country-list li { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 6px; cursor: pointer; }
.country-list li:hover, .country-list li[aria-selected="true"] { background: #eff6ff; }
.flag { width: 24px; height: 16px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.1); flex: none; }

.btn { display: inline-block; border: 0; border-radius: 8px; padding: 12px 18px; font-size: 16px; font-weight: 600; cursor: pointer; text-decoration: none; background: #e5e7eb; color: var(--text); }
.btn.primary, .success .btn { background: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn:disabled { opacity: .55; cursor: default; }
#otpBox { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--border); }
#otpBox .btn { margin-top: 12px; }
.link { background: none; border: 0; color: var(--blue); cursor: pointer; padding: 8px 0; margin-left: 12px; font-size: 14px; }
.link:disabled { color: var(--muted); cursor: default; }
.hint { color: var(--muted); font-size: 14px; margin: 0 0 10px; }
.hint-after { margin: 10px 0 0; }
.message { margin: 14px 0 0; padding: 10px 12px; border-radius: 8px; background: #fef2f2; color: var(--red); }
.message.ok { background: #eff6ff; color: var(--blue-dark); }

.pdf-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.pdf-head a { font-size: 14px; color: var(--blue); }
.pdf-viewer { background: #e5e7eb; border-radius: 8px; padding: 8px; max-height: 80vh; overflow: auto; }
.pdf-viewer canvas { display: block; width: 100%; height: auto; margin: 0 auto 8px; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.pdf-viewer iframe { width: 100%; height: 75vh; border: 0; background: #fff; }

.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 20px; }
.footer a { color: var(--muted); }

@media (max-width: 520px) {
  .container { margin-top: 12px; }
  .card { padding: 16px; }
  .btn { width: 100%; }
  .link { margin-left: 0; }
}

/* Spiegazione semplice del codice OTP */
.howto { margin: 18px 0 4px; padding: 16px 18px; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 12px; }
.howto-title { margin: 0 0 10px; font-weight: 700; color: var(--blue-dark); font-size: 16px; }
.howto-steps { list-style: none; margin: 0; padding: 0; }
.howto-steps li { display: flex; gap: 12px; align-items: flex-start; margin: 0 0 10px; line-height: 1.45; font-size: 15px; }
.howto-icon { flex: 0 0 34px; height: 34px; display: grid; place-items: center; background: #fff; border-radius: 50%; font-size: 18px; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.howto-steps li > span:last-child { padding-top: 6px; }
.howto-note { margin: 6px 0 0; font-size: 14px; color: #334155; line-height: 1.5; }
