:root {
      --bg: #f5f6f4;
      --surface: #ffffff;
      --text: #18211d;
      --muted: #68736d;
      --line: #e1e7e3;
      --primary: #1f3d2b;
      --accent: #2f855a;
      --danger: #c53030;
      --shadow: 0 18px 44px rgba(20, 35, 27, 0.08);
    }

    * { box-sizing: border-box; }

    body {
      margin: 0;
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
      background: var(--bg);
      color: var(--text);
      line-height: 1.45;
      min-height: 100vh;
    }

    a {
      color: inherit;
      text-decoration: none;
    }

    header {
      background: rgba(255, 255, 255, 0.94);
      backdrop-filter: blur(14px);
      border-bottom: 1px solid var(--line);
      position: sticky;
      top: 0;
      z-index: 10;
    }

    .topbar {
      max-width: 960px;
      margin: auto;
      padding: 15px 20px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 16px;
    }

    .brand {
      display: flex;
      align-items: center;
      gap: 10px;
      font-weight: 900;
      font-size: 1.2rem;
    }

    .brand-mark {
      width: 38px;
      height: 38px;
      border-radius: 13px;
      background: linear-gradient(135deg, #1f3d2b, #38a169);
      display: grid;
      place-items: center;
      color: #fff;
      font-weight: 900;
    }

    .back-link {
      color: var(--muted);
      font-weight: 800;
      white-space: nowrap;
    }

    main {
      max-width: 960px;
      margin: auto;
      padding: 38px 20px 70px;
    }

    .hero {
      background: linear-gradient(135deg, #14281d, #2f855a);
      color: #fff;
      border-radius: 30px;
      padding: clamp(28px, 5vw, 40px);
      box-shadow: var(--shadow);
      margin-bottom: 22px;
    }

    .hero h1 {
      margin: 0 0 12px;
      font-size: clamp(2rem, 5vw, 3.5rem);
      line-height: 1;
      letter-spacing: -0.04em;
    }

    .hero p {
      margin: 0;
      max-width: 720px;
      color: #e6f4ea;
      font-size: 1.05rem;
    }

    .card {
      background: var(--surface);
      border: 1px solid var(--line);
      border-radius: 28px;
      padding: clamp(22px, 4vw, 32px);
      box-shadow: var(--shadow);
    }

    .form-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 18px;
    }

    .full { grid-column: 1 / -1; }

    label span {
      display: block;
      font-weight: 850;
      margin-bottom: 8px;
    }

    input {
      width: 100%;
      min-height: 50px;
      border: 1px solid var(--line);
      border-radius: 15px;
      padding: 13px 14px;
      font: inherit;
      background: #fff;
      color: var(--text);
    }


    select {
      width: 100%;
      min-height: 50px;
      border: 1px solid var(--line);
      border-radius: 15px;
      padding: 13px 14px;
      font: inherit;
      background: #fff;
      color: var(--text);
    }

    select:focus {
      outline: none;
      border-color: #9fd4b4;
      box-shadow: 0 0 0 4px rgba(47, 133, 90, 0.12);
    }


    .password-rules {
      margin: 10px 0 0;
      padding-left: 0;
      list-style: none;
      display: grid;
      gap: 5px;
      color: var(--muted);
      font-size: .88rem;
      font-weight: 700;
    }

    .password-rules li::before {
      content: "○";
      display: inline-block;
      width: 1.25em;
      color: var(--muted);
      font-weight: 900;
    }

    .password-rules li.valid {
      color: #166534;
    }

    .password-rules li.valid::before {
      content: "✓";
      color: #166534;
    }

    .password-strength-wrap { margin-top: 8px; }
    .password-strength-track {
      width: 100%;
      height: 10px;
      background: #fee2e2;
      border-radius: 999px;
      overflow: hidden;
      border: 1px solid #e5e7eb;
    }
    .password-strength-bar {
      width: 0%;
      height: 100%;
      border-radius: 999px;
      background: linear-gradient(90deg,#dc2626,#f59e0b,#16a34a);
      transition: width .25s ease;
    }
    .password-strength-text {
      display: block;
      margin-top: 6px;
      font-size: .9rem;
      font-weight: 800;
      color: var(--muted);
    }

    input:focus {
      outline: none;
      border-color: #9fd4b4;
      box-shadow: 0 0 0 4px rgba(47, 133, 90, 0.12);
    }

    input[type="file"] {
      padding: 11px;
    }



    .registration-error-box{
      display:none;
      grid-column:1 / -1;
      background:#fff5f5;
      color:#b91c1c;
      border:1px solid #fecaca;
      border-radius:18px;
      padding:14px 16px;
      font-weight:850;
      line-height:1.35;
      margin-bottom:4px;
    }

    label.has-error input,
    label.has-error select,
    label.has-error textarea{
      border-color:#dc2626!important;
      background:#fff7f7!important;
      box-shadow:0 0 0 4px rgba(220,38,38,.10)!important;
    }

    label.has-error span{
      color:#b91c1c;
    }

    .field-error-text{
      display:block;
      margin-top:6px;
      color:#b91c1c;
      font-size:.84rem;
      font-weight:850;
    }

    .admin-request-box {
      display: flex;
      align-items: flex-start;
      gap: 12px;
      border: 1px solid #cde9d8;
      background: #f0fbf4;
      border-radius: 18px;
      padding: 15px;
    }

    .admin-request-box input {
      width: auto;
      min-height: auto;
      margin-top: 4px;
      transform: scale(1.2);
    }

    .admin-request-box span {
      margin-bottom: 4px;
    }

    .hint {
      display: block;
      color: var(--muted);
      font-size: 0.86rem;
      margin-top: 6px;
    }

    .photo-block {
      display: grid;
      grid-template-columns: 150px 1fr;
      gap: 18px;
      align-items: center;
    }

    .photo-preview {
      width: 150px;
      height: 150px;
      border-radius: 26px;
      border: 1px dashed #b9c8be;
      background: #f8faf8;
      display: grid;
      place-items: center;
      overflow: hidden;
      color: var(--muted);
      text-align: center;
      padding: 12px;
      font-size: 0.92rem;
    }

    .photo-preview img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .gps-grid {
      display: grid;
      grid-template-columns: 1fr 1fr auto;
      gap: 16px;
      align-items: end;
    }

    .btn-row {
      display: flex;
      gap: 12px;
      flex-wrap: wrap;
      align-items: center;
      margin-top: 8px;
    }

    button, .btn {
      border: none;
      border-radius: 999px;
      min-height: 48px;
      padding: 14px 20px;
      font: inherit;
      font-weight: 900;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      transition: 0.2s ease;
    }

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

    .btn-light {
      background: #edf5ef;
      color: var(--primary);
    }

    .notice {
      margin-top: 20px;
      border: 1px solid #cde9d8;
      background: #e7f5ed;
      color: #1f3d2b;
      border-radius: 16px;
      padding: 14px;
      font-size: 0.94rem;
    }

    .error {
      display: none;
      margin-bottom: 18px;
      border: 1px solid #feb2b2;
      background: #fff5f5;
      color: var(--danger);
      border-radius: 16px;
      padding: 14px;
      font-weight: 750;
    }

    @media (max-width: 760px) {
      .form-grid, .gps-grid {
        grid-template-columns: 1fr;
      }

      .photo-block {
        grid-template-columns: 1fr;
      }

      .photo-preview {
        width: 130px;
        height: 130px;
      }
    }

    @media (max-width: 520px) {
      .brand span:last-child { display: none; }

      main {
        padding-left: 14px;
        padding-right: 14px;
      }

      .hero, .card {
        border-radius: 24px;
      }

      .btn-row .btn,
      .btn-row button {
        width: 100%;
      }
    }
  
@media (prefers-color-scheme: dark){
  html,body{background:#0f172a!important;color:#f8fafc!important;color-scheme:dark;}
  header,.card,.box,.panel,section,main form{background:#111827!important;color:#f8fafc!important;border-color:#334155!important;}
  h1,h2,h3,label,span,p,small,strong{color:#f8fafc!important;}
  input,select,textarea{background:#0b1220!important;color:#f8fafc!important;border-color:#475569!important;}
  a{color:#86efac!important;}
}
.legal-acceptance-box{
  border:1px solid rgba(22,163,74,.28)!important;
  background:rgba(236,253,245,.82)!important;
  border-radius:18px;
  padding:14px;
  display:grid;
  gap:10px;
  color:#14532d!important;
}
.legal-acceptance-box > strong,
.privacy-consent-block > strong{
  color:#14532d!important;
}
.legal-acceptance-box p{
  margin:0;
  color:#475569!important;
  font-size:.92rem;
}
.legal-check{
  display:flex!important;
  align-items:flex-start!important;
  gap:10px;
  margin:0!important;
  font-weight:700;
  color:#1f2937!important;
}
.legal-check span{
  color:#1f2937!important;
}
.legal-check input{
  width:20px!important;
  min-width:20px!important;
  height:20px!important;
  min-height:20px!important;
  margin-top:3px;
  padding:0!important;
  accent-color:#16a34a;
}
.legal-check a{
  color:#166534!important;
  font-weight:900;
  text-decoration:underline;
}
.privacy-consent-block{
  border-top:1px solid rgba(22,163,74,.18);
  margin-top:6px;
  padding-top:12px;
  display:grid;
  gap:10px;
}
.privacy-consent-choice{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:8px;
  margin-top:2px;
}
.privacy-consent-option{
  display:flex!important;
  align-items:center!important;
  gap:10px;
  margin:0!important;
  padding:12px 14px;
  border:1px solid rgba(22,163,74,.28)!important;
  border-radius:14px;
  background:rgba(255,255,255,.72)!important;
  font-weight:900;
  color:#1f2937!important;
}
.privacy-consent-option span{
  color:#1f2937!important;
}
.privacy-consent-option input{
  width:20px!important;
  min-width:20px!important;
  height:20px!important;
  min-height:20px!important;
  padding:0!important;
  accent-color:#16a34a;
}
.privacy-deny-note{
  font-size:.86rem!important;
  color:#7c2d12!important;
  background:#fff7ed!important;
  border:1px solid #fed7aa!important;
  border-radius:14px;
  padding:10px;
}
@media (prefers-color-scheme: dark){
  .legal-acceptance-box{
    background:#111827!important;
    border-color:#334155!important;
    color:#e5e7eb!important;
  }
  .legal-acceptance-box > strong,
  .privacy-consent-block > strong,
  .legal-check,
  .legal-check span{
    color:#f8fafc!important;
  }
  .legal-acceptance-box p{
    color:#cbd5e1!important;
  }
  .legal-check a{
    color:#86efac!important;
  }
  .privacy-consent-block{
    border-top-color:#334155!important;
  }
  .privacy-consent-option{
    background:#1f2937!important;
    border-color:#334155!important;
    color:#f8fafc!important;
  }
  .privacy-consent-option span{
    color:#f8fafc!important;
  }
  .privacy-deny-note{
    background:rgba(120,53,15,.36)!important;
    border-color:rgba(251,146,60,.55)!important;
    color:#fed7aa!important;
  }
}
body.cv-theme-scuro .legal-acceptance-box,
html.cv-theme-scuro .legal-acceptance-box,
html.cv-theme-sistema.cv-theme-resolved-scuro .legal-acceptance-box{
  background:#111827!important;
  border-color:#334155!important;
  color:#e5e7eb!important;
}
body.cv-theme-scuro .legal-acceptance-box > strong,
html.cv-theme-scuro .legal-acceptance-box > strong,
html.cv-theme-sistema.cv-theme-resolved-scuro .legal-acceptance-box > strong,
body.cv-theme-scuro .privacy-consent-block > strong,
html.cv-theme-scuro .privacy-consent-block > strong,
html.cv-theme-sistema.cv-theme-resolved-scuro .privacy-consent-block > strong,
body.cv-theme-scuro .legal-check,
html.cv-theme-scuro .legal-check,
html.cv-theme-sistema.cv-theme-resolved-scuro .legal-check,
body.cv-theme-scuro .legal-check span,
html.cv-theme-scuro .legal-check span,
html.cv-theme-sistema.cv-theme-resolved-scuro .legal-check span{
  color:#f8fafc!important;
}
body.cv-theme-scuro .legal-acceptance-box p,
html.cv-theme-scuro .legal-acceptance-box p,
html.cv-theme-sistema.cv-theme-resolved-scuro .legal-acceptance-box p{
  color:#cbd5e1!important;
}
body.cv-theme-scuro .legal-check a,
html.cv-theme-scuro .legal-check a,
html.cv-theme-sistema.cv-theme-resolved-scuro .legal-check a{
  color:#86efac!important;
}
body.cv-theme-scuro .privacy-consent-block,
html.cv-theme-scuro .privacy-consent-block,
html.cv-theme-sistema.cv-theme-resolved-scuro .privacy-consent-block{
  border-top-color:#334155!important;
}
body.cv-theme-scuro .privacy-consent-option,
html.cv-theme-scuro .privacy-consent-option,
html.cv-theme-sistema.cv-theme-resolved-scuro .privacy-consent-option{
  background:#1f2937!important;
  border-color:#334155!important;
  color:#f8fafc!important;
}
body.cv-theme-scuro .privacy-consent-option span,
html.cv-theme-scuro .privacy-consent-option span,
html.cv-theme-sistema.cv-theme-resolved-scuro .privacy-consent-option span{
  color:#f8fafc!important;
}
body.cv-theme-scuro .privacy-deny-note,
html.cv-theme-scuro .privacy-deny-note,
html.cv-theme-sistema.cv-theme-resolved-scuro .privacy-deny-note{
  background:rgba(120,53,15,.36)!important;
  border-color:rgba(251,146,60,.55)!important;
  color:#fed7aa!important;
}
@media(max-width:640px){.privacy-consent-choice{grid-template-columns:1fr}}

/* CV_REGISTER_THEME_COMPLETE_V309: tema coerente su Web/iOS/Android */
:root,
html.cv-theme-chiaro,
body.cv-theme-chiaro,
html.cv-theme-resolved-chiaro,
body.cv-theme-resolved-chiaro{
  --bg:#f5f6f4;
  --surface:#ffffff;
  --surface-soft:#f8faf8;
  --text:#18211d;
  --muted:#68736d;
  --line:#e1e7e3;
  --primary:#1f3d2b;
  --accent:#2f855a;
  --danger:#c53030;
  --success:#166534;
  --success-soft:#ecfdf5;
  --warning-soft:#fff7ed;
  --warning-text:#7c2d12;
  --warning-line:#fed7aa;
  --input-bg:#ffffff;
  --header-bg:rgba(255,255,255,.94);
  --hero-a:#14281d;
  --hero-b:#2f855a;
  --hero-text:#ffffff;
  --hero-muted:#e6f4ea;
  --focus:rgba(47,133,90,.12);
  --shadow:0 18px 44px rgba(20,35,27,.08);
}
html.cv-theme-scuro,
body.cv-theme-scuro,
html.cv-theme-resolved-scuro,
body.cv-theme-resolved-scuro,
html.cv-theme-sistema.cv-theme-resolved-scuro,
body.cv-theme-sistema.cv-theme-resolved-scuro{
  --bg:#0f172a;
  --surface:#111827;
  --surface-soft:#0b1220;
  --text:#f8fafc;
  --muted:#cbd5e1;
  --line:#334155;
  --primary:#bbf7d0;
  --accent:#16a34a;
  --danger:#fecaca;
  --success:#bbf7d0;
  --success-soft:#052e1a;
  --warning-soft:rgba(120,53,15,.36);
  --warning-text:#fed7aa;
  --warning-line:rgba(251,146,60,.55);
  --input-bg:#0b1220;
  --header-bg:rgba(17,24,39,.94);
  --hero-a:#052e1a;
  --hero-b:#166534;
  --hero-text:#f8fafc;
  --hero-muted:#dcfce7;
  --focus:rgba(34,197,94,.18);
  --shadow:0 18px 44px rgba(0,0,0,.35);
}
body{background:var(--bg)!important;color:var(--text)!important;}
header{background:var(--header-bg)!important;border-bottom-color:var(--line)!important;}
.brand,.brand span,.back-link,label span,h1,h2,h3,strong{color:var(--text)!important;}
.back-link,.hint,.password-rules,.password-strength-text{color:var(--muted)!important;}
.hero{background:linear-gradient(135deg,var(--hero-a),var(--hero-b))!important;color:var(--hero-text)!important;}
.hero p{color:var(--hero-muted)!important;}
.card,.admin-request-box,.notice,.legal-acceptance-box,.privacy-consent-option{background:var(--surface)!important;border-color:var(--line)!important;color:var(--text)!important;box-shadow:var(--shadow);}
input,select,textarea{background:var(--input-bg)!important;color:var(--text)!important;border-color:var(--line)!important;}
input::placeholder,textarea::placeholder{color:var(--muted)!important;opacity:1;}
input:focus,select:focus,textarea:focus{border-color:var(--accent)!important;box-shadow:0 0 0 4px var(--focus)!important;}
.photo-preview,.btn-light{background:var(--surface-soft)!important;border-color:var(--line)!important;color:var(--primary)!important;}
.password-strength-track{background:var(--surface-soft)!important;border-color:var(--line)!important;}
.legal-acceptance-box > strong,.privacy-consent-block > strong,.legal-check,.legal-check span,.privacy-consent-option,.privacy-consent-option span{color:var(--text)!important;}
.legal-acceptance-box p{color:var(--muted)!important;}
.legal-check a,a{color:var(--success)!important;}
.privacy-consent-block{border-top-color:var(--line)!important;}
.privacy-deny-note{background:var(--warning-soft)!important;border-color:var(--warning-line)!important;color:var(--warning-text)!important;}
.registration-error-box,.error{background:rgba(127,29,29,.10)!important;border-color:rgba(248,113,113,.45)!important;color:var(--danger)!important;}
label.has-error input,label.has-error select,label.has-error textarea{background:rgba(127,29,29,.10)!important;border-color:#dc2626!important;}
label.has-error span,.field-error-text{color:#ef4444!important;}
.btn-primary,button[type=submit]{background:var(--accent)!important;color:#fff!important;}
@media (prefers-color-scheme: dark){
  html:not(.cv-theme-chiaro):not(.cv-theme-resolved-chiaro),
  html:not(.cv-theme-chiaro):not(.cv-theme-resolved-chiaro) body{color-scheme:dark;}
}

/* CV_REGISTER_ACTIVE_FIELD_RED_BORDER_V357
   Evidenzia in rosso il campo/box attivo durante la compilazione. */
#registerForm label:focus-within:not(.legal-check):not(.privacy-consent-option){
  outline:2px solid #dc2626!important;
  outline-offset:4px;
  border-radius:18px;
}

#registerForm input:focus,
#registerForm select:focus,
#registerForm textarea:focus{
  outline:none!important;
  border-color:#dc2626!important;
  box-shadow:0 0 0 4px rgba(220,38,38,.16)!important;
}

#registerForm label:focus-within > span:first-child{
  color:#b91c1c!important;
}

#registerForm input[type="checkbox"]:focus,
#registerForm input[type="radio"]:focus{
  outline:3px solid rgba(220,38,38,.48)!important;
  outline-offset:3px!important;
  box-shadow:none!important;
}

#registerForm .legal-check:focus-within,
#registerForm .privacy-consent-option:focus-within{
  border-color:#dc2626!important;
  box-shadow:0 0 0 4px rgba(220,38,38,.13)!important;
}

html.cv-theme-scuro #registerForm label:focus-within > span:first-child,
body.cv-theme-scuro #registerForm label:focus-within > span:first-child,
html.cv-theme-sistema.cv-theme-resolved-scuro #registerForm label:focus-within > span:first-child,
body.cv-theme-sistema.cv-theme-resolved-scuro #registerForm label:focus-within > span:first-child{
  color:#fca5a5!important;
}
