:root {
  --c-primary: #0a5cab;
  --c-primary-dark: #084a8a;
  --c-bg: #f4f6f9;
  --c-card: #ffffff;
  --c-text: #1c2530;
  --c-muted: #5b6776;
  --c-border: #d8dee6;
  --c-success: #1f8a55;
  --c-error: #c0392b;
  --c-star: #f5b400;
  --radius: 12px;
  --shadow: 0 4px 16px rgba(10, 30, 60, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.topbar {
  background: #fff;
  color: var(--c-text);
  padding: 10px 16px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  border-bottom: 3px solid var(--c-primary);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 720px;
  margin: 0 auto;
}
.brand-logo {
  height: 48px;
  width: auto;
  flex-shrink: 0;
  object-fit: contain;
}
.brand-text { flex: 1; min-width: 0; text-align: center; }
.brand h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--c-primary);
  line-height: 1.2;
}
.subtitle {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--c-muted);
}
@media (min-width: 480px) {
  .brand-logo { height: 56px; }
  .brand h1 { font-size: 18px; }
  .subtitle { font-size: 12px; }
}

.container {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px 80px;
}

.card {
  background: var(--c-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 18px;
  margin-bottom: 16px;
}

.card h2 { margin: 0 0 12px; font-size: 22px; }
.card h3 { margin: 16px 0 8px; font-size: 17px; }
.card p { margin: 0 0 12px; color: var(--c-text); }

.hidden { display: none !important; }

/* Form */
.field { margin-bottom: 14px; display: flex; flex-direction: column; }
.field label { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field input,
.field select,
.field textarea {
  font: inherit;
  padding: 12px 12px;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  background: #fff;
  color: var(--c-text);
  width: 100%;
  min-height: 44px;
}
.field textarea { min-height: 80px; resize: vertical; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--c-primary);
  outline-offset: 1px;
  border-color: var(--c-primary);
}
.hint { color: var(--c-muted); font-size: 12px; margin-top: 4px; }

.consent { background: #f0f5fb; padding: 12px; border-radius: 8px; }
.checkbox { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: 14px; cursor: pointer; }
.checkbox input { width: 20px; height: 20px; min-height: 20px; margin-top: 2px; flex-shrink: 0; }

.error {
  background: #fdecea;
  color: var(--c-error);
  border: 1px solid #f5b7b1;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 12px;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.actions .btn { flex: 1 1 auto; }

/* Buttons */
.btn {
  font: inherit;
  font-weight: 600;
  padding: 13px 18px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  min-height: 48px;
  transition: background .15s ease, transform .05s ease;
  width: 100%;
  margin-top: 8px;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-dark); }
.btn-secondary { background: #e6ebf2; color: var(--c-text); }
.btn-secondary:hover { background: #d8dee6; }
.btn-ghost { background: transparent; color: var(--c-muted); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Info / details */
.info {
  background: #f7f9fc;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 12px 0 18px;
  font-size: 14px;
}
.info summary { cursor: pointer; font-weight: 600; }
.info p { margin: 8px 0; color: var(--c-muted); }

/* Success */
.success { text-align: center; padding: 8px 0 4px; }
.success-icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--c-success);
  color: #fff;
  font-size: 36px;
  line-height: 64px;
  margin: 0 auto 12px;
  font-weight: bold;
}
.meta { color: var(--c-muted); font-size: 13px; }
.meta code { background: #eef2f7; padding: 2px 6px; border-radius: 4px; }
.sep { border: none; border-top: 1px solid var(--c-border); margin: 18px 0; }

/* Rating stars */
.rating {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 12px 0 4px;
}
.rating .star {
  font-size: 40px;
  background: none;
  border: none;
  color: #d0d7df;
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
  transition: color .1s ease, transform .1s ease;
}
.rating .star:hover,
.rating .star.active {
  color: var(--c-star);
}
.rating .star:active { transform: scale(1.15); }

/* Footer */
.footer {
  text-align: center;
  color: var(--c-muted);
  padding: 20px 16px 28px;
  font-size: 12px;
}
.footer a { color: var(--c-muted); }
.footer-logos {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.footer-logos img {
  height: 40px;
  width: auto;
  opacity: 0.85;
}

/* Loader overlay */
.loader {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.85);
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  justify-content: center;
  z-index: 100;
  color: var(--c-text);
  font-weight: 600;
}
.spinner {
  width: 42px;
  height: 42px;
  border: 4px solid #d8dee6;
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Tablet+ */
@media (min-width: 720px) {
  .card { padding: 28px; }
  .container { padding-top: 28px; }
}

/* --- Barra utente in testata --- */
.barra-utente {
  max-width: 720px;
  margin: 8px auto 0;
  padding-top: 8px;
  border-top: 1px solid var(--c-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--c-muted);
}
.barra-utente span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Pulsante testuale: azione, non navigazione, quindi <button> e non <a>.
   Stilizzato come collegamento ma raggiungibile da tastiera come un pulsante. */
.link-azione {
  font: inherit;
  background: none;
  border: none;
  padding: 0;
  color: var(--c-primary);
  text-decoration: underline;
  cursor: pointer;
  flex-shrink: 0;
}
.link-azione:hover { color: var(--c-primary-dark); }

/* --- Accesso con provider --- */
.provider { margin-bottom: 4px; }

.btn-provider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  border: 1px solid var(--c-border);
}
.provider-icona {
  font-weight: 700;
  font-size: 18px;
  line-height: 1;
  width: 20px;
  text-align: center;
}
.btn-google { background: #fff; color: var(--c-text); }
.btn-google:hover { background: #f4f6f9; }
.btn-apple { background: #000; color: #fff; border-color: #000; }
.btn-apple:hover { background: #1a1a1a; }

.separatore {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
  color: var(--c-muted);
  font-size: 13px;
}
.separatore::before,
.separatore::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--c-border);
}

/* --- Avviso non di errore (conferme, istruzioni) --- */
.avviso {
  background: #eaf5ee;
  color: #1d6b45;
  border: 1px solid #b7dcc6;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 12px;
}

.centrato { text-align: center; }
