/* ===== Font self-hosted ===== */
@font-face {
    font-family: 'TIM Sans';
    src: url('fonts/tim-sans/TIMSansWeb-Light.woff2') format('woff2'),
         url('fonts/tim-sans/TIMSansWeb-Light.woff')  format('woff');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'TIM Sans';
    src: url('fonts/tim-sans/TIMSansWeb-Regular.woff2') format('woff2'),
         url('fonts/tim-sans/TIMSansWeb-Regular.woff')  format('woff');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'TIM Sans';
    src: url('fonts/tim-sans/TIMSansWeb-Bold.woff2') format('woff2'),
         url('fonts/tim-sans/TIMSansWeb-Bold.woff')  format('woff');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
/* Gill Sans: font del cliente IVECO Bus, file forniti dal cliente (vedi fonts/gill-sans/LEGGIMI.txt).
   Finche' i file mancano, il ripiego e' Open Sans (vedi mappa font). */
@font-face {
    font-family: 'Gill Sans';
    src: url('fonts/gill-sans/GillSans-Light.woff2') format('woff2'),
         url('fonts/gill-sans/GillSans-Light.woff')  format('woff');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Gill Sans';
    src: url('fonts/gill-sans/GillSans-Regular.woff2') format('woff2'),
         url('fonts/gill-sans/GillSans-Regular.woff')  format('woff');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Gill Sans';
    src: url('fonts/gill-sans/GillSans-Bold.woff2') format('woff2'),
         url('fonts/gill-sans/GillSans-Bold.woff')  format('woff');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Work Sans';
    src: url('fonts/work-sans/WorkSans-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Juventus Fans';
    src: url('fonts/juventus-fans/Juventus-Fans-Light.woff2') format('woff2'),
         url('fonts/juventus-fans/Juventus-Fans-Light.woff')  format('woff');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Juventus Fans';
    src: url('fonts/juventus-fans/Juventus-Fans-Regular.woff2') format('woff2'),
         url('fonts/juventus-fans/Juventus-Fans-Regular.woff')  format('woff');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Juventus Fans';
    src: url('fonts/juventus-fans/Juventus-Fans-Bold.woff2') format('woff2'),
         url('fonts/juventus-fans/Juventus-Fans-Bold.woff')  format('woff');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Titillium Web';
    src: url('fonts/titillium-web/TitilliumWeb-Regular-latin-ext.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Titillium Web';
    src: url('fonts/titillium-web/TitilliumWeb-Regular-latin.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Titillium Web';
    src: url('fonts/titillium-web/TitilliumWeb-SemiBold-latin-ext.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Titillium Web';
    src: url('fonts/titillium-web/TitilliumWeb-SemiBold-latin.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Titillium Web';
    src: url('fonts/titillium-web/TitilliumWeb-Bold-latin-ext.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Titillium Web';
    src: url('fonts/titillium-web/TitilliumWeb-Bold-latin.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --text: #1d1d1f;
    --muted: #6e6e73;
    --border: #d9dde3;
    --primary: #B9322B;
    --primary-hover: #9f2924;
    --danger: #b00020;
    --radius: 14px;
    --shadow: 0 8px 24px rgba(0, 0, 0, .06);
    /* Form style — overridable via <style> block iniettato da form.php */
    --form-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    --form-font-size: 14px;
    --form-input-radius: 10px;
    --form-field-spacing: 20px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    font-family: var(--form-font-family);
    font-size: var(--form-font-size);
    background: var(--bg);
    color: var(--text);
}

.public-page {
    padding: 2px 16px 32px;
}

.public-page.public-vcenter {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.public-page.public-vcenter .public-wrapper {
    margin-top: auto;
    margin-bottom: auto;
}

/* Se c'è un menu di navigazione, si centra insieme al form (come un unico
   blocco) invece di restare ancorato in cima con un vuoto sotto. */
.public-page.public-vcenter .site-nav {
    /* In un contenitore flex i margini auto orizzontali già presenti su
       .site-nav farebbero "collassare" la larghezza al solo contenuto
       (stretch disattivato dagli auto-margin), spostando la barra fuori
       asse rispetto alla card sottostante. width:100% (fino al max-width
       già impostato inline) mantiene la stessa larghezza di sempre. */
    width: 100%;
    margin-top: auto;
    margin-bottom: 0;
}

.public-page.public-vcenter .site-nav ~ .public-wrapper {
    margin-top: 0;
}

.public-wrapper {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
}

.public-branding-header img,
.public-branding-footer img {
    display: block;
    width: 100%;
    height: auto;
}

.public-branding-header {
    margin-bottom: 0;
}

.public-branding-footer {
    margin-top: 0;
}

/* Footer testuale (Aspetto > Footer testuale): fascia colorata, testo centrato */
.public-branding-footer-text {
    box-sizing: border-box;
    padding: 28px 24px;
    text-align: center;
    line-height: 1.6;
}
.public-branding-footer-text a { color: inherit; }
.public-branding-footer-text p { margin: 0 0 4px; }

.public-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0;
    box-shadow: var(--shadow);
    padding: 32px;
}

/* Immagini inserite nei testi admin (banner, loghi…): mai più larghe della scheda, su desktop e mobile.
   Messa prima delle regole specifiche (slider, ecc.), che a parità di peso hanno la precedenza. */
.public-card img {
    max-width: 100%;
    height: auto;
}

/* Banner a tutta larghezza scheda, attaccato ai bordi (annulla lo spazio interno della scheda, 32px
   su desktop / 22px su mobile): nell'editor, vista "codice sorgente", dare all'immagine class="fa-banner". */
.public-card img.fa-banner {
    display: block;
    width: calc(100% + 64px);
    max-width: none;
    margin: -32px -32px 24px;
}
/* il paragrafo/titolo che contiene il banner non deve aggiungere un suo margine sopra */
.public-card > :has(> img.fa-banner) {
    margin-top: 0;
    margin-bottom: 0;
}
@media (max-width: 640px) {
    .public-card img.fa-banner {
        width: calc(100% + 44px);
        margin: -22px -22px 20px;
    }
}

.public-header {
    margin-bottom: 24px;
}

.public-header h1 {
    margin: 0 0 10px;
    font-size: 30px;
    line-height: 1.2;
}

.public-subtitle {
    margin: 0;
    color: var(--text);
    font-size: var(--form-font-size);
    line-height: 1.5;
}

.public-intro {
    margin-bottom: 24px;
    color: var(--text);
    font-size: var(--form-font-size);
    line-height: 1.6;
    overflow-wrap: break-word;
    word-break: break-word;
}
.public-intro > :first-child { margin-top: 0; }

/* Link dentro i testi admin (thank_you/pagine/riepiloghi): colore brand invece
   del blu di default. Icona identificativa via CSS mask (si colora da sola con
   currentColor) SOLO sui link riconosciuti dalla loro destinazione reale
   ($LinkForm$ → form.php, $LinkHome$ → home.php, link "aggiungi al calendario"),
   non sul testo del link (libero, configurato in admin) — altri link (es. mailto
   della segreteria) restano senza icona. */
.public-intro a {
    color: var(--link-color, var(--primary));
    font-weight: 600;
    text-decoration: none;
}
.public-intro a:hover,
.public-intro a:focus {
    text-decoration: underline;
}
.public-intro a[href*="/form.php"],
.public-intro a[href*="/home.php"],
.public-intro a[href*="view=home"],
.public-intro a[href*="token="],
.public-intro a[href*="add-to-calendar"] {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.public-intro a[href*="/form.php"]::before,
.public-intro a[href*="/home.php"]::before,
.public-intro a[href*="view=home"]::before,
.public-intro a[href*="token="]::before,
.public-intro a[href*="add-to-calendar"]::before {
    content: '';
    display: inline-block;
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    background-color: currentColor;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
}
/* $LinkForm$ — riepilogo/dati registrati: path standard /form.php, oppure su
   dominio vanity il link e' la root nuda col solo token (nessun /form.php
   letterale nell'URL - vedi buildFormUrl in includes/config.php) */
.public-intro a[href*="/form.php"]::before,
.public-intro a[href*="token="]:not([href*="/home.php"]):not([href*="view=home"]):not([href*="add-to-calendar"])::before {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 11l3 3L22 4'/%3E%3Cpath d='M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 11l3 3L22 4'/%3E%3Cpath d='M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11'/%3E%3C/svg%3E");
}
/* $LinkHome$ — informazioni utili / home evento: path standard /home.php,
   oppure su dominio vanity ?view=home (vedi buildHomeUrl) */
.public-intro a[href*="/home.php"]::before,
.public-intro a[href*="view=home"]::before {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='16' x2='12' y2='12'/%3E%3Cline x1='12' y1='8' x2='12.01' y2='8'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='16' x2='12' y2='12'/%3E%3Cline x1='12' y1='8' x2='12.01' y2='8'/%3E%3C/svg%3E");
}
/* Aggiungi al calendario */
.public-intro a[href*="add-to-calendar"]::before {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
}

.public-form-group {
    margin-bottom: var(--form-field-spacing);
}

.public-form-group label {
    display: block;
    margin-bottom: 7px;
    font-size: var(--form-font-size);
    font-weight: 600;
}

.public-form-group input,
.public-form-group select,
.public-form-group textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--form-input-radius);
    padding: 12px 13px;
    font-size: var(--form-font-size);
    font-family: inherit;
    color: var(--text);
    background: #fff;
}

/* Grid campi affiancati */
.fields-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 20px;
}

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

@media (max-width: 580px) {
    .fields-grid {
        grid-template-columns: 1fr;
    }
    .field-half {
        grid-column: auto;
    }
}

.public-form-group input:focus,
.public-form-group select:focus,
.public-form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(185, 50, 43, .12);
}

.public-form-group small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.field-help {
    display: block;
    margin: -2px 0 8px;
    color: var(--text);
    font-size: var(--form-font-size);
    line-height: 1.4;
}

.public-html-block {
    font-size: var(--form-font-size);
    line-height: 1.6;
}

.required {
    color: var(--danger);
}

.public-form-group input[readonly],
.public-form-group textarea[readonly] {
    background: #f4f4f5;
    color: var(--text);
    cursor: default;
}

.choice-list {
    display: grid;
    gap: 8px;
}

.choice-list--inline {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px 150px;
}

.choice-list--inline .choice-item {
    font-weight: 600 !important;
}

.choice-item {
    display: flex !important;
    align-items: center;
    gap: 8px;
    font-weight: 400 !important;
    margin: 0 !important;
}

.choice-item input {
    width: auto !important;
}

.privacy-box {
    margin-top: 24px;
    padding: 14px;
    border-radius: 10px;
    background: #fafafa;
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.public-actions {
    margin-top: 24px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.public-actions .public-btn {
    flex: 1 1 200px;
    width: auto;
}

.public-btn-secondary {
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text);
}

.public-btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #fff8f7;
}

.public-btn {
    width: 100%;
    border: 0;
    border-radius: 10px;
    padding: 13px 16px;
    background: var(--primary);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
}

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

.public-message {
    padding: 18px;
    border-radius: 10px;
    background: #fafafa;
    border: 1px dashed var(--border);
    color: var(--muted);
}

@media (max-width: 640px) {
    .public-page {
        padding: 16px;
    }

    .public-card {
        padding: 22px;
    }

    .lang-switcher {
        margin-top: -10px;
    }

    .public-header h1 {
        font-size: 24px;
    }

    .public-branding-header,
    .public-branding-footer {
        margin-left: -16px;
        margin-right: -16px;
    }
}
.public-message-error {
    background: #fdeaea;
    border-color: #f5c2c7;
    color: var(--danger);
}

.public-message-error p {
    margin: 0 0 8px;
}

.public-message-error p:last-child {
    margin-bottom: 0;
}

.public-btn-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}
.public-success-box {
    padding: 18px;
    border-radius: 10px;
    background: #eaf7ee;
    border: 1px solid #bfe5c8;
    color: #146c2e;
    line-height: 1.6;
}

.public-response-id {
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

/* ===== Menu di navigazione ===== */
.site-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--nav-bg, #333333);
    margin-top: 3px;
    margin-bottom: 3px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.site-nav-inner {
    margin: 0 auto;
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    padding: 0 16px;
}
.site-nav-links {
    list-style: none;
    display: flex;
    margin: 0;
    padding: 0;
    gap: 0;
}
.site-nav-links a {
    display: flex;
    align-items: center;
    padding: 0 18px;
    height: 42px;
    color: var(--nav-text, #ffffff);
    text-decoration: none;
    font-size: var(--nav-font-size, 14px);
    font-family: var(--nav-font-family, inherit);
    font-weight: 500;
    white-space: nowrap;
    transition: background .15s, color .15s;
}
.site-nav-links a:hover {
    background: var(--nav-hover-bg, #4a4a4a);
    color: var(--nav-hover-text, #ffffff);
}
.site-nav-links a.nav-active {
    background: var(--nav-active-bg, #B9322B);
    color: var(--nav-active-text, #ffffff);
}
.site-nav-burger {
    display: none;
    background: none;
    border: none;
    color: var(--nav-text, #ffffff);
    font-size: 44px;
    cursor: pointer;
    padding: 0 10px;
    line-height: 1;
    align-self: center;
    align-items: center;
    justify-content: center;
}
.site-nav-mobile {
    display: none;
    flex-direction: column;
    background: var(--nav-bg, #333333);
    padding: 4px 0;
}
.site-nav-mobile.open { display: flex; }
.site-nav-mobile a {
    display: block;
    padding: 12px 18px;
    color: var(--nav-text, #ffffff);
    text-decoration: none;
    font-size: var(--nav-font-size, 14px);
    font-family: var(--nav-font-family, inherit);
    font-weight: 500;
    border-top: 1px solid rgba(255,255,255,.08);
    transition: background .15s, color .15s;
}
.site-nav-mobile a:hover {
    background: var(--nav-hover-bg, #4a4a4a);
    color: var(--nav-hover-text, #ffffff);
}
.site-nav-mobile a.nav-active {
    background: var(--nav-active-bg, #B9322B);
    color: var(--nav-active-text, #ffffff);
}
@media (max-width: 640px) {
    .site-nav-links { display: none; }
    .site-nav-burger { display: flex; }
    .site-nav-inner { min-height: 46px; padding-left: 8px; }
}

/* ===== Scala di valutazione ===== */
.scale-list {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.scale-item {
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-weight: 400 !important;
    margin: 0 !important;
    cursor: pointer;
}

.scale-item input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.scale-item span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: #fff;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    transition: border-color .15s, background .15s, color .15s;
    user-select: none;
}

.scale-item:hover span {
    border-color: var(--primary);
    color: var(--primary);
}

.scale-item input[type="radio"]:checked + span {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.scale-item input[type="radio"]:focus-visible + span {
    outline: 3px solid rgba(185, 50, 43, .35);
    outline-offset: 2px;
}

/* ===== Sezione accompagnatori ===== */
.companion-section {
    margin: 0 0 24px;
}

.companion-section-heading {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 8px;
}

.companion-counter {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 10px;
}

.companion-counter:empty {
    display: none;
}

.companion-blocks {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 12px;
}

.companion-block {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
    background: #f8f9fb;
}

.companion-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.companion-block-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.companion-remove-btn {
    background: none;
    border: 1px solid var(--danger);
    color: var(--danger);
    border-radius: 6px;
    padding: 4px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.companion-remove-btn:hover {
    background: var(--danger);
    color: #fff;
}

.companion-add-wrap {
    margin-top: 4px;
}

.companion-add-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 8px 18px;
    font-size: 14px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.companion-add-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #fff8f7;
    opacity: .85;
}

/* === Modalità diretta (accordion) === */
[data-display-mode="direct"] .companion-block {
    border: none;
    padding: 0;
    background: none;
    margin-bottom: 6px;
}

[data-display-mode="direct"] .companion-block-header {
    border-radius: 8px;
    padding: 12px 18px;
    cursor: pointer;
    margin-bottom: 0;
    border-bottom: none;
    border: none;
    user-select: none;
    transition: opacity .15s;
    font-weight: 600;
}

[data-display-mode="direct"] .companion-block-header:hover {
    opacity: .85;
}

[data-display-mode="direct"] .companion-block-title {
    color: inherit;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 6px;
}

[data-display-mode="direct"] .companion-block-title::after {
    content: '▾';
    font-size: 14px;
    margin-left: auto;
    transition: transform .2s;
    display: inline-block;
}

[data-display-mode="direct"] .companion-block--open .companion-block-title::after {
    transform: rotate(180deg);
}

[data-display-mode="direct"] .companion-block-body {
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 16px 18px;
    background: #f8f9fb;
    margin-bottom: 2px;
}

[data-display-mode="direct"] .companion-block--open .companion-block-header {
    border-radius: 8px 8px 0 0;
}

/* === Modalità tabella (Referenti di Mercato / molti campi per partecipante) === */
.companion-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 14px;
    font-size: 14px;
}

.companion-table thead th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--muted);
    padding: 0 10px 8px;
    border-bottom: 1px solid var(--border);
}

.companion-table tbody tr {
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.companion-table tbody tr:hover {
    background: #fafafa;
}

.companion-table td {
    padding: 10px;
    vertical-align: middle;
}

.companion-table .companion-row-num {
    color: var(--muted);
    width: 28px;
}

.companion-table .companion-row-empty {
    color: var(--muted);
    font-style: italic;
}

.companion-row-remove {
    background: none;
    border: 1px solid var(--danger);
    color: var(--danger);
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 12px;
    cursor: pointer;
}

.companion-row-remove:hover {
    background: var(--danger);
    color: #fff;
}

.companion-table-empty-row td {
    padding: 16px 10px;
    color: var(--muted);
    font-style: italic;
    cursor: default;
}

.companion-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 20, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.companion-modal {
    background: #fff;
    border-radius: 12px;
    max-width: 640px;
    width: 100%;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.companion-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.companion-modal-header h4 {
    margin: 0;
    font-size: 16px;
}

.companion-modal-close {
    background: none;
    border: 0;
    font-size: 22px;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    padding: 4px 8px;
}

.companion-modal-close:hover {
    color: var(--text);
}

.companion-modal-body {
    padding: 18px 20px;
    overflow-y: auto;
}

.companion-modal-body .companion-block {
    border: 0;
    padding: 0;
    background: none;
}

.companion-modal-body .companion-block-header {
    display: none;
}

.companion-modal-errors {
    padding: 0 20px;
    color: var(--danger);
    font-size: 13px;
}

.companion-modal-errors p {
    margin: 4px 0;
}

.companion-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
}

.companion-modal-save-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 8px 18px;
    font-size: 14px;
    cursor: pointer;
    margin-left: auto;
    transition: border-color .15s, background .15s;
}

.companion-modal-save-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #fff8f7;
    opacity: .85;
}

@media (max-width: 560px) {
    .companion-table thead { display: none; }
    .companion-table, .companion-table tbody, .companion-table tr, .companion-table td {
        display: block;
        width: 100%;
    }
    .companion-table tr {
        padding: 10px 0;
    }
}
/* Switch lingua pubblico (Fase 5 multilingua) — vedi renderLangSwitcher() in includes/config.php.
   Vive dentro .public-card (stesso sfondo del form, nessuna fascia/sfondo propria) allineato
   a destra, così non lascia un "buco" visivo tra header/menu e card. */
.lang-switcher {
    text-align: right;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: .02em;
    /* riduce solo lo spazio sopra (dentro il padding-top della card) per
       avvicinarlo alla barra menu, senza toccare i lati (rischio overflow
       su mobile dove il padding della card è diverso) */
    margin-top: -20px;
    margin-bottom: 14px;
    color: var(--muted, #6b7280);
}
.lang-switcher a {
    color: var(--muted, #6b7280);
    text-decoration: none;
}
.lang-switcher a:hover {
    text-decoration: underline;
}
.lang-switcher strong {
    color: var(--primary, #B9322B);
}

/* Slider automatico (assets/auto_slider.js): nel testo di una pagina basta
   <div class="auto-slider"><img src="..."><img src="..."></div>. Proporzioni di default 3/2,
   cambiabili con style="aspect-ratio:16/9" sul blocco. */
.auto-slider {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 2;
    margin: 16px 0;
    overflow: hidden;
    background: #000;
    border-radius: 6px;
}
/* senza JavaScript: foto affiancate, scorrevoli a mano */
.auto-slider:not([data-ready]) {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
}
.auto-slider:not([data-ready]) img {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    object-fit: cover;
    scroll-snap-align: center;
}
.auto-slider__track {
    display: flex;
    height: 100%;
    will-change: transform;
    touch-action: pan-y;
}
.auto-slider__slide {
    flex: 0 0 100%;
    height: 100%;
    overflow: hidden;
}
.auto-slider__slide img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    user-select: none;
    -webkit-user-drag: none;
}
.auto-slider__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 42px;
    height: 42px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: rgba(0, 0, 0, .45);
    color: #fff;
    font-size: 24px;
    line-height: 42px;
    cursor: pointer;
}
.auto-slider__nav:hover { background: rgba(0, 0, 0, .65); }
.auto-slider__prev { left: 10px; }
.auto-slider__next { right: 10px; }
.auto-slider__dots {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 10px;
    display: flex;
    justify-content: center;
    gap: 8px;
}
.auto-slider__dots button {
    width: 10px;
    height: 10px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, .45);
    cursor: pointer;
    transition: transform 200ms ease, background 200ms ease;
}
.auto-slider__dots button.is-active {
    background: rgba(255, 255, 255, .95);
    transform: scale(1.15);
}

/* Pagine di conferma / non conferma: poco spazio tra la fine del testo e il footer che segue la scheda
   (di solito 32px di margine interno + il margine dell'ultimo paragrafo = ~48px). */
.public-card--compact-end {
    padding-bottom: 12px;
}
.public-card--compact-end .public-intro {
    margin-bottom: 0;
}
.public-card--compact-end .public-intro > :last-child {
    margin-bottom: 0;
}
