/* ── Basket Gestionale – Public CSS ──────────────────────────────────────── */

:root {
    --bg-primary:   #FE0000;
    --bg-dark:      #1C1917;
    --bg-surface:   #FAFAF9;
    --bg-border:    #E7E5E4;
    --bg-text:      #292524;
    --bg-muted:     #78716C;
    --bg-success:   #16A34A;
    --bg-warning:   #D97706;
    --bg-danger:    #DC2626;
    --bg-radius:    10px;
    --bg-shadow:    0 2px 16px rgba(0,0,0,.07);
    --bg-font-base: 16px;
}

/* Base font size per tutti gli elementi del plugin */
.bg-form-wrap,
.bg-accesso-wrap,
.bg-dashboard,
.bg-ra-wrap {
    font-size: var(--bg-font-base);
    line-height: 1.6;
}

/* Imposta dimensione minima su mobile */
@media (max-width: 680px) {
    :root { --bg-font-base: 16px; }
    .bg-form-wrap,
    .bg-accesso-wrap,
    .bg-dashboard,
    .bg-ra-wrap {
        font-size: 16px;
    }
}

/* ── FORM ISCRIZIONE ───────────────────────────────────────────────────── */

.bg-form-wrap {
    max-width: 820px;
    margin: 2.5rem auto;
    padding: 2.5rem 3rem;
    background: #fff;
    border-radius: var(--bg-radius);
    box-shadow: var(--bg-shadow);
    border: 1px solid var(--bg-border);
}

.bg-form-wrap h2 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--bg-dark);
    margin: 0 0 .5rem;
    border-left: 4px solid var(--bg-primary);
    padding-left: .85rem;
}

.bg-form-intro {
    color: var(--bg-muted);
    font-size: 1rem;
    margin: 0 0 2rem .85rem;
}

.bg-form-section-title {
    font-size: .92rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--bg-muted);
    border-bottom: 2px solid var(--bg-border);
    padding-bottom: .5rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: baseline;
    gap: .75rem;
}

.bg-form-section-note {
    font-size: .92rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--bg-muted);
    font-style: italic;
}

.bg-section-mt { margin-top: 2rem; }

.bg-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.bg-form-group {
    margin-bottom: 1.25rem;
}

.bg-form-group label {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    color: var(--bg-text);
    margin-bottom: .4rem;
}

.bg-form-group label .req { color: var(--bg-danger); }

.bg-form-group input[type="text"],
.bg-form-group input[type="email"],
.bg-form-group input[type="tel"],
.bg-form-group input[type="date"],
.bg-form-group input[type="number"],
.bg-form-group select,
.bg-form-group textarea {
    width: 100%;
    padding: .75rem 1rem;
    border: 1.5px solid var(--bg-border);
    border-radius: 8px;
    font-size: 1.05rem;
    color: var(--bg-text);
    background: #fff;
    transition: border-color .2s, box-shadow .2s;
    box-sizing: border-box;
}

.bg-form-group input:focus,
.bg-form-group select:focus,
.bg-form-group textarea:focus {
    outline: none;
    border-color: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(254,0,0,.1);
}

.bg-field-hint {
    display: block;
    margin-top: .35rem;
    font-size: .95rem;
    color: var(--bg-muted);
}

/* ── UPLOAD BOX ────────────────────────────────────────────────────────── */

.bg-upload-box {
    position: relative;
    border: 2px dashed var(--bg-border);
    border-radius: 8px;
    background: var(--bg-surface);
    transition: border-color .2s, background .2s;
    cursor: pointer;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bg-upload-box:hover,
.bg-upload-box.bg-upload-drag {
    border-color: var(--bg-primary);
    background: #FFF0F0;
}

.bg-upload-box.bg-upload-selected {
    border-color: var(--bg-success);
    background: #F0FDF4;
    border-style: solid;
}

.bg-file-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.bg-upload-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .25rem;
    padding: 1.1rem;
    pointer-events: none;
    text-align: center;
}

.bg-upload-icon {
    font-size: 1.4rem;
    color: var(--bg-muted);
    line-height: 1;
}

.bg-upload-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--bg-text);
}

.bg-upload-hint {
    font-size: .92rem;
    color: var(--bg-muted);
}

.bg-upload-ok  { font-size: .88rem; font-weight: 600; color: var(--bg-success); }
.bg-upload-err { font-size: 1rem; font-weight: 600; color: var(--bg-danger); }

/* ── CHECKBOX ──────────────────────────────────────────────────────────── */

.bg-checkbox label {
    display: flex;
    gap: .6rem;
    align-items: flex-start;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.6;
    cursor: pointer;
}

.bg-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin-top: 2px;
    flex-shrink: 0;
    accent-color: var(--bg-primary);
}

/* ── SUBMIT BUTTON ─────────────────────────────────────────────────────── */

.bg-form-wrap .bg-btn,
.bg-accesso-wrap .bg-btn,
.bg-form-wrap .bg-btn:focus,
.bg-accesso-wrap .bg-btn:focus {
    display: block;
    width: 100%;
    padding: 1rem 2.5rem;
    background: #FE0000 !important;
    background-color: #FE0000 !important;
    color: #fff !important;
    border: none !important;
    border-radius: 8px !important;
    font-size: 1.15rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, transform .1s;
    margin-top: .75rem;
    box-shadow: none !important;
    text-decoration: none !important;
    line-height: 1.4;
}

.bg-form-wrap .bg-btn:hover,
.bg-accesso-wrap .bg-btn:hover {
    background: #CC0000 !important;
    background-color: #CC0000 !important;
    transform: translateY(-1px);
}
.bg-form-wrap .bg-btn:disabled,
.bg-accesso-wrap .bg-btn:disabled {
    background: #ccc !important;
    background-color: #ccc !important;
    cursor: not-allowed;
    transform: none;
}

/* ── MESSAGES ──────────────────────────────────────────────────────────── */

#bg-messages:not(:empty),
#bg-pwd-messages:not(:empty) {
    margin-bottom: 1.25rem;
    padding: 1rem 1.25rem;
    border-radius: 8px;
    font-size: .92rem;
    line-height: 1.6;
}

.bg-notice-success { background: #F0FDF4; border: 1px solid #86EFAC; color: #166534; }
.bg-notice-error   { background: #FEF2F2; border: 1px solid #FECACA; color: #991B1B; }
.bg-notice-info    { background: #EFF6FF; border: 1px solid #BFDBFE; color: #1E40AF; }

.bg-notice { padding: .9rem 1.1rem; border-radius: 8px; font-size: .92rem; line-height: 1.6; margin-bottom: 1rem; }

/* ── DASHBOARD GIOCATORE ───────────────────────────────────────────────── */

.bg-dashboard {
    max-width: 860px;
    margin: 2.5rem auto;
}

.bg-dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: .5rem;
}

.bg-dashboard-header h2 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--bg-dark);
    margin: 0;
}

.bg-card {
    background: #fff;
    border: 1px solid var(--bg-border);
    border-radius: var(--bg-radius);
    box-shadow: var(--bg-shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.bg-card h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--bg-text);
    margin: 0 0 1rem;
    padding-bottom: .6rem;
    border-bottom: 2px solid var(--bg-border);
}

.bg-dl {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: .4rem .8rem;
    margin: 0;
}

.bg-dl dt {
    font-weight: 600;
    font-size: 1rem;
    color: var(--bg-muted);
    padding: .35rem 0;
}

.bg-dl dd {
    margin: 0;
    font-size: 1.05rem;
    color: var(--bg-text);
    padding: .35rem 0;
    border-bottom: 1px solid var(--bg-border);
}

.bg-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1rem;
}

.bg-table th {
    text-align: left;
    padding: .5rem .75rem;
    font-size: .92rem;
    font-weight: 700;
    color: var(--bg-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 2px solid var(--bg-border);
}

.bg-table td {
    padding: .85rem .85rem;
    border-bottom: 1px solid var(--bg-border);
    vertical-align: middle;
}

.bg-table tr:last-child td { border-bottom: none; }

/* ── BADGES ────────────────────────────────────────────────────────────── */

.bg-badge {
    display: inline-block;
    padding: .22rem .65rem;
    border-radius: 999px;
    font-size: .92rem;
    font-weight: 600;
}

.bg-badge-valido      { background: #F0FDF4; color: #166534; }
.bg-badge-in_scadenza { background: #FFFBEB; color: #92400E; }
.bg-badge-scaduto     { background: #FEF2F2; color: #991B1B; }

.bg-stato-approvato { background: #F0FDF4; color: #166534; border-radius: 999px; padding: .22rem .75rem; font-size: .82rem; font-weight: 600; }
.bg-stato-in_attesa { background: #FFFBEB; color: #92400E; border-radius: 999px; padding: .22rem .75rem; font-size: .82rem; font-weight: 600; }
.bg-stato-rifiutata { background: #FEF2F2; color: #991B1B; border-radius: 999px; padding: .22rem .75rem; font-size: .82rem; font-weight: 600; }

.bg-link { color: var(--bg-primary); font-weight: 600; text-decoration: none; font-size: 1rem; }
.bg-link:hover { text-decoration: underline; }
.bg-link-logout { color: var(--bg-muted); font-size: 1rem; text-decoration: none; }
.bg-link-logout:hover { color: var(--bg-danger); }

.bg-empty { color: var(--bg-muted); font-style: italic; font-size: .92rem; }

/* ── LOGIN ─────────────────────────────────────────────────────────────── */

#bg-login-form {
    max-width: 420px;
    margin: 2.5rem auto;
    background: #fff;
    padding: 2.5rem;
    border-radius: var(--bg-radius);
    box-shadow: var(--bg-shadow);
    border: 1px solid var(--bg-border);
}

#bg-login-form .input {
    width: 100%;
    padding: .75rem 1rem;
    border: 1.5px solid var(--bg-border);
    border-radius: 8px;
    margin-bottom: .9rem;
    font-size: 1rem;
    box-sizing: border-box;
}

#bg-login-form .button-primary {
    background: var(--bg-primary) !important;
    border-color: var(--bg-primary) !important;
    width: 100%;
    padding: .75rem 0;
    font-size: 1rem;
    border-radius: 8px !important;
}

/* ── RESPONSIVE ────────────────────────────────────────────────────────── */

@media (max-width: 680px) {
    .bg-form-wrap   { padding: 1.25rem; margin: 0; border-radius: 0; border-left: none; border-right: none; }
    .bg-accesso-panel { padding: 1.25rem; border-radius: 0; border-left: none; border-right: none; }
    .bg-form-row    { grid-template-columns: 1fr; gap: 0; }
    .bg-dl          { grid-template-columns: 1fr; }
    .bg-dashboard-header { flex-direction: column; align-items: flex-start; }
    .bg-form-wrap h2, .bg-accesso-title { font-size: 1.5rem; }
    .bg-form-group  { margin-bottom: 1.1rem; }
    .bg-form-group input,
    .bg-form-group select,
    .bg-form-group textarea {
        font-size: 16px; /* Impedisce zoom automatico su iOS */
        padding: .85rem 1rem;
    }
    .bg-accesso-wrap .bg-accesso-tab { padding: .85rem 1.5rem; font-size: 1rem; }
}

/* ── Upload section nella dashboard ───────────────────────────────────── */

.bg-upload-section {
    margin-top: 1.25rem;
    border-top: 1px dashed var(--bg-border);
    padding-top: 1rem;
}

.bg-upload-toggle {
    display: inline-block;
    font-size: 1rem;
    font-weight: 600;
    color: var(--bg-primary);
    cursor: pointer;
    padding: .35rem 0;
    user-select: none;
    transition: opacity .15s;
}
.bg-upload-toggle:hover { opacity: .75; }

.bg-upload-panel {
    margin-top: .9rem;
    padding: 1.25rem;
    background: var(--bg-surface);
    border: 1px solid var(--bg-border);
    border-radius: 8px;
}

/* ── Riepilogo admin frontend ──────────────────────────────────────────── */

.bg-ra-wrap {
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    box-sizing: border-box;
    padding: 0 1.5rem;
    font-size: .93rem;
}

/* Statistiche */
.bg-ra-stats {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: .75rem;
    margin-bottom: 1.5rem;
}
.bg-ra-stat {
    background: #fff;
    border: 1px solid var(--bg-border);
    border-radius: var(--bg-radius);
    padding: 1rem;
    text-align: center;
    box-shadow: var(--bg-shadow);
}
.bg-ra-stat-ok { border-top: 3px solid #639922; }
.bg-ra-stat-no { border-top: 3px solid #DC2626; }
.bg-ra-stat-n {
    display: block;
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1;
    color: var(--bg-dark);
}
.bg-ra-stat-ok .bg-ra-stat-n { color: #3B6D11; }
.bg-ra-stat-no .bg-ra-stat-n { color: #A32D2D; }
.bg-ra-stat-l {
    display: block;
    font-size: .92rem;
    color: var(--bg-muted);
    margin-top: .35rem;
    line-height: 1.3;
}

/* Filtri */
.bg-ra-filters {
    background: #fff;
    border: 1px solid var(--bg-border);
    border-radius: var(--bg-radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem;
    box-shadow: var(--bg-shadow);
}
.bg-ra-filter-group {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    flex: 1;
    min-width: 140px;
}
.bg-ra-filter-group label {
    font-size: .9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--bg-muted);
}
.bg-ra-filter-group select,
.bg-ra-filter-group input[type="search"] {
    padding: .7rem .95rem;
    border: 1.5px solid var(--bg-border);
    border-radius: 7px;
    font-size: 1rem;
    background: #fff;
    color: var(--bg-text);
    width: 100%;
    box-sizing: border-box;
}
.bg-ra-filter-group select:focus,
.bg-ra-filter-group input:focus {
    outline: none;
    border-color: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(254,0,0,.1);
}
.bg-ra-filter-actions {
    display: flex;
    gap: .5rem;
    align-items: flex-end;
    flex-shrink: 0;
}

/* Bottoni */
.bg-ra-btn {
    padding: .6rem 1.25rem;
    border-radius: 7px;
    border: 1.5px solid var(--bg-primary);
    background: var(--bg-primary);
    color: #fff;
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s;
    text-decoration: none;
}
.bg-ra-btn:hover { background: #CC0000; color: #fff; }
.bg-ra-btn-ghost {
    background: transparent;
    color: var(--bg-primary);
}
.bg-ra-btn-ghost:hover { background: #FFF0F0; color: var(--bg-primary); }
.bg-ra-btn-secondary {
    background: #fff;
    color: var(--bg-text);
    border-color: var(--bg-border);
}
.bg-ra-btn-secondary:hover { background: var(--bg-surface); color: var(--bg-text); }

/* Tabella */
.bg-ra-table-wrap {
    background: #fff;
    border: 1px solid var(--bg-border);
    border-radius: var(--bg-radius);
    overflow-x: auto;
    box-shadow: var(--bg-shadow);
}
.bg-ra-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1rem;
}
.bg-ra-table th {
    background: #F8FAFC;
    text-align: left;
    padding: .85rem 1rem;
    font-size: .85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--bg-muted);
    border-bottom: 2px solid var(--bg-border);
    white-space: nowrap;
}
.bg-ra-table td {
    padding: .6rem .75rem;
    border-bottom: 1px solid var(--bg-border);
    vertical-align: middle;
}
.bg-ra-table tr:last-child td { border-bottom: none; }
.bg-ra-table tr:hover td { background: #FAFAF9; }

.bg-ra-muted { color: var(--bg-muted); font-size: .95rem; }

/* Badge */
.bg-ra-badge {
    display: inline-block;
    padding: .3rem .8rem;
    border-radius: 999px;
    font-size: .88rem;
    font-weight: 600;
    white-space: nowrap;
}
.bg-ra-ok   { background: #EAF3DE; color: #3B6D11; }
.bg-ra-warn { background: #FAEEDA; color: #854F0B; }
.bg-ra-no   { background: #FCEBEB; color: #A32D2D; }

/* Bottoni azione tabella */
.bg-ra-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.bg-ra-btn-sm {
    padding: .25rem .65rem;
    font-size: .75rem;
    font-weight: 600;
    border-radius: 5px;
    border: 1px solid;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity .15s;
}
.bg-ra-btn-sm:disabled { opacity: .5; cursor: not-allowed; }
.bg-ra-btn-ok { background: #EAF3DE; border-color: #97C459; color: #3B6D11; }
.bg-ra-btn-ok:hover { background: #d4edbc; color: #3B6D11; }
.bg-ra-btn-no { background: #FCEBEB; border-color: #F09595; color: #A32D2D; }
.bg-ra-btn-no:hover { background: #f8d0d0; color: #A32D2D; }

.bg-ra-footer {
    padding: 1rem 1.25rem;
    font-size: 1rem;
    color: var(--bg-muted);
    border-top: 1px solid var(--bg-border);
    margin: 0;
    background: #fff;
    border-radius: 0 0 var(--bg-radius) var(--bg-radius);
}
.bg-ra-empty {
    padding: 2rem;
    text-align: center;
    color: var(--bg-muted);
    font-style: italic;
}

@media (max-width: 768px) {
    .bg-ra-stats { grid-template-columns: repeat(3,1fr); }
    .bg-ra-filter-group { min-width: 100%; }
    .bg-ra-table th:nth-child(6),
    .bg-ra-table td:nth-child(6) { display: none; }
}
@media (max-width: 480px) {
    .bg-ra-stats { grid-template-columns: repeat(2,1fr); }
}

/* ── Riepilogo admin – statistiche cliccabili ──────────────────────────── */
.bg-ra-stat-link {
    text-decoration: none;
    transition: transform .15s, box-shadow .15s;
    cursor: pointer;
}
.bg-ra-stat-link:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,.1); }
.bg-ra-stat-active { outline: 2px solid var(--bg-primary); outline-offset: 2px; }
.bg-ra-stat-warn { border-top: 3px solid #D97706; }
.bg-ra-stat-warn .bg-ra-stat-n { color: #854F0B; }

/* ── Pannello modifica inline ──────────────────────────────────────────── */
.bg-ra-edit-row > td { padding: 0 !important; }
.bg-ra-edit-panel {
    background: #F8FAFC;
    border-top: 2px solid var(--bg-primary);
    border-bottom: 1px solid var(--bg-border);
    padding: 1.5rem;
}
.bg-ra-edit-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.25rem;
}
.bg-ra-edit-section {
    background: #fff;
    border: 1px solid var(--bg-border);
    border-radius: var(--bg-radius);
    padding: 1.1rem;
}
.bg-ra-edit-section-title {
    font-size: .88rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--bg-muted);
    margin-bottom: .85rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--bg-border);
}
.bg-ra-field {
    margin-bottom: .75rem;
}
.bg-ra-field label {
    display: block;
    font-size: .92rem;
    font-weight: 600;
    color: var(--bg-muted);
    margin-bottom: .25rem;
}
.bg-ra-field input,
.bg-ra-field select,
.bg-ra-field textarea {
    width: 100%;
    padding: .65rem .9rem;
    border: 1.5px solid var(--bg-border);
    border-radius: 7px;
    font-size: 1rem;
    background: #fff;
    color: var(--bg-text);
    box-sizing: border-box;
}
.bg-ra-field input:focus,
.bg-ra-field select:focus,
.bg-ra-field textarea:focus {
    outline: none;
    border-color: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(254,0,0,.1);
}
.bg-ra-field textarea { resize: vertical; }

.bg-ra-doc-info {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: .75rem;
    padding: .75rem 1rem;
    background: var(--bg-surface);
    border-radius: 6px;
    font-size: .95rem;
}
.bg-ra-link-small {
    color: var(--bg-primary) !important;
    font-size: .92rem;
    font-weight: 600;
    text-decoration: none !important;
}
.bg-ra-link-small:hover,
.bg-ra-link-small:focus,
.bg-ra-link-small:visited { 
    color: #CC0000 !important;
    text-decoration: underline !important;
}

/* Fix tutti i link nel riepilogo che diventano bianchi */
.bg-ra-wrap a,
.bg-ra-wrap .bg-ra-link-small,
.bg-ra-edit-panel a {
    color: var(--bg-primary) !important;
}
.bg-ra-wrap a:hover,
.bg-ra-edit-panel a:hover {
    color: #CC0000 !important;
}
.bg-ra-bulk-templates .bg-ra-btn-secondary,
.bg-ra-bulk-templates .bg-ra-btn-secondary:hover {
    color: #1a1a1a !important;
}

.bg-ra-ric-list { margin-bottom: .5rem; }
.bg-ra-ric-item {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
    padding: .4rem .6rem;
    background: var(--bg-surface);
    border-radius: 5px;
    font-size: .95rem;
    margin-bottom: .35rem;
}
.bg-ra-upload-box {
    position: relative;
    border: 2px dashed var(--bg-border);
    border-radius: 7px;
    background: var(--bg-surface);
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
}
.bg-ra-upload-box:hover, .bg-ra-upload-box.bg-upload-drag { border-color: var(--bg-primary); background: #FFF0F0; }
.bg-ra-upload-box.bg-upload-selected { border-color: var(--bg-success); background: #F0FDF4; border-style: solid; }

.bg-ra-edit-footer {
    display: flex;
    gap: .75rem;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid var(--bg-border);
}
.bg-ra-edit-msg {
    padding: .7rem 1rem;
    border-radius: 7px;
    font-size: .88rem;
    font-weight: 500;
    margin-bottom: 1rem;
}
.bg-ra-edit-msg-ok    { background: #EAF3DE; color: #3B6D11; }
.bg-ra-edit-msg-error { background: #FCEBEB; color: #A32D2D; }

.bg-ra-btn-edit {
    background: #EFF6FF;
    border-color: #BFDBFE;
    color: #1E40AF;
}
.bg-ra-btn-edit:hover { background: #DBEAFE; color: #1E40AF; }

@media (max-width: 860px) {
    .bg-ra-edit-grid { grid-template-columns: 1fr; }
}

/* ── Accesso unico (login + iscrizione) ────────────────────────────────── */

.bg-accesso-wrap {
    max-width: 860px;
    margin: 2.5rem auto;
}

.bg-accesso-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 0;
    border-bottom: 2.5px solid var(--bg-border);
}

/* Alta specificità per battere gli stili del tema sui <button> */
.bg-accesso-wrap .bg-accesso-tab,
.bg-accesso-wrap .bg-accesso-tab:focus,
.bg-accesso-wrap .bg-accesso-tab:visited {
    display: inline-block;
    padding: 1rem 2.25rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--bg-muted) !important;
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    border-bottom: 3px solid transparent !important;
    border-radius: 0 !important;
    margin-bottom: -2.5px;
    cursor: pointer;
    transition: color .15s, border-color .15s;
    box-shadow: none !important;
    text-decoration: none !important;
    outline: none;
}

.bg-accesso-wrap .bg-accesso-tab.active,
.bg-accesso-wrap .bg-accesso-tab.active:focus {
    color: #FE0000 !important;
    background: transparent !important;
    background-color: transparent !important;
    border-bottom: 3px solid #FE0000 !important;
    box-shadow: none !important;
}

.bg-accesso-wrap .bg-accesso-tab:hover:not(.active) {
    color: var(--bg-text) !important;
    background: transparent !important;
    background-color: transparent !important;
}

.bg-accesso-panel {
    display: none;
    background: #fff;
    border: 1px solid var(--bg-border);
    border-top: none;
    border-radius: 0 0 var(--bg-radius) var(--bg-radius);
    box-shadow: var(--bg-shadow);
    padding: 2.5rem 3rem;
}

.bg-accesso-panel.active {
    display: block;
}

.bg-accesso-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--bg-dark);
    margin: 0 0 .35rem;
}

.bg-accesso-sub {
    color: var(--bg-muted);
    font-size: 1rem;
    margin: 0 0 2rem;
}

/* Login panel centrato e compatto */
.bg-accesso-login-wrap {
    max-width: 420px;
    margin: 0 auto;
}

#bg-login-form {
    max-width: 100%;
    margin: 0;
    background: none;
    padding: 0;
    border: none;
    box-shadow: none;
}

.bg-accesso-login-footer {
    margin-top: 1.25rem;
    font-size: 1rem;
    display: flex;
    gap: .75rem;
    align-items: center;
    flex-wrap: wrap;
}

.bg-accesso-sep {
    color: var(--bg-border);
}

@media (max-width: 680px) {
    .bg-accesso-panel { padding: 1.5rem; }
    .bg-accesso-tab   { padding: .7rem 1.25rem; font-size: .9rem; }
}

/* ── Bottoni categoria ─────────────────────────────────────────────────── */
.bg-cat-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    padding: .75rem;
    border: 1.5px solid var(--bg-border);
    border-radius: 8px;
    background: #fff;
}
.bg-cat-buttons-sm {
    padding: .4rem;
    gap: .35rem;
}
.bg-cat-buttons .bg-cat-btn,
.bg-cat-buttons .bg-cat-btn:focus,
.bg-cat-buttons .bg-cat-btn:visited {
    display: inline-block;
    padding: .6rem 1.25rem;
    border: 1.5px solid #C0C0C0 !important;
    border-radius: 999px !important;
    background: #F5F5F5 !important;
    background-color: #F5F5F5 !important;
    color: #333 !important;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
    user-select: none;
    line-height: 1.4;
    white-space: nowrap;
    box-shadow: none !important;
    text-decoration: none !important;
}
.bg-cat-buttons .bg-cat-btn:hover {
    border-color: #FE0000 !important;
    color: #FE0000 !important;
    background: #FFF0F0 !important;
    background-color: #FFF0F0 !important;
}
.bg-cat-buttons .bg-cat-btn.active,
.bg-cat-buttons .bg-cat-btn.active:focus {
    background: #FE0000 !important;
    background-color: #FE0000 !important;
    border-color: #FE0000 !important;
    color: #fff !important;
    font-weight: 700;
}

/* ── Selezione multipla e email di massa ───────────────────────────────── */
.bg-sel-row, #bg-sel-all {
    width: 16px;
    height: 16px;
    accent-color: #FE0000;
    cursor: pointer;
}

.bg-ra-bulk-panel {
    background: #fff;
    border: 2px solid #FE0000;
    border-radius: var(--bg-radius);
    margin-top: 1rem;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(254,0,0,.1);
}

.bg-ra-bulk-header {
    background: #FFF0F0;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    border-bottom: 1px solid #FECACA;
    font-size: .92rem;
}

.bg-ra-bulk-body {
    padding: 1.25rem 1.5rem;
}

.bg-ra-bulk-templates {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    align-items: center;
    margin-top: .75rem;
    padding: .6rem .8rem;
    background: var(--bg-surface);
    border-radius: 7px;
    border: 1px solid var(--bg-border);
}

/* Toggle link per aggiungi documento */
.bg-ra-upload-toggle {
    font-size: .83rem;
    font-weight: 600;
    color: #FE0000;
    cursor: pointer;
    display: inline-block;
    padding: .25rem 0;
    user-select: none;
    transition: opacity .15s;
}
.bg-ra-upload-toggle:hover { opacity: .7; }

/* ── Fix toolbar WordPress che copre il contenuto ──────────────────────── */
/* Quando l'admin bar è presente, aggiunge spazio sufficiente in cima       */
.admin-bar .bg-form-wrap,
.admin-bar .bg-accesso-wrap,
.admin-bar .bg-dashboard,
.admin-bar .bg-ra-wrap {
    scroll-margin-top: 46px; /* altezza admin bar desktop */
}

@media (max-width: 782px) {
    .admin-bar .bg-form-wrap,
    .admin-bar .bg-accesso-wrap,
    .admin-bar .bg-dashboard,
    .admin-bar .bg-ra-wrap {
        scroll-margin-top: 46px; /* admin bar mobile */
    }
}

/* Fix z-index pannelli a tendina che finiscono sotto la toolbar */
.bg-ra-bulk-panel,
.bg-ra-edit-row > td,
.bg-accesso-panel {
    position: relative;
    z-index: 1;
}

/* ── Barra compleanni ───────────────────────────────────────────────────── */
.bg-ra-birthday-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem;
    padding: .85rem 1.25rem;
    background: #FFFBEB;
    border: 1px solid #FDE68A;
    border-radius: var(--bg-radius);
    margin-bottom: 1.25rem;
    font-size: .95rem;
}
.bg-ra-birthday-icon { font-size: 1.3rem; }
.bg-ra-birthday-pill {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    background: #fff;
    border: 1px solid #FDE68A;
    border-radius: 999px;
    padding: .25rem .75rem;
    font-size: .88rem;
}
.bg-ra-birthday-pill em  { color: #92400E; font-style: normal; font-weight: 500; }
.bg-ra-birthday-pill small { color: #78716C; }
.bg-ra-birthday-oggi {
    background: #FEF3C7;
    border-color: #F59E0B;
    font-weight: 600;
}

/* ── Sezione genitori ───────────────────────────────────────────────────── */
.bg-minorenne-notice {
    background: #EFF6FF;
    border: 1px solid #BFDBFE;
    border-radius: 8px;
    padding: .85rem 1.1rem;
    font-size: .95rem;
    color: #1E40AF;
    margin-bottom: 1.25rem;
}
.bg-gen2-toggle { margin-top: .5rem; }
.bg-gen2-toggle-btn {
    background: none !important;
    border: none !important;
    color: #FE0000 !important;
    font-size: .95rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    padding: .35rem 0 !important;
    box-shadow: none !important;
    text-decoration: underline !important;
}

/* ── Consensi ───────────────────────────────────────────────────────────── */
.bg-consenso-box {
    border: 1px solid var(--bg-border);
    border-radius: var(--bg-radius);
    padding: 1.1rem 1.25rem;
    margin-bottom: 1rem;
    background: #fff;
}
.bg-consenso-required {
    border-color: #FECACA;
    background: #FFF5F5;
}
.bg-consenso-header {
    display: flex;
    align-items: center;
    gap: .65rem;
    margin-bottom: .6rem;
}
.bg-consenso-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #FE0000;
    color: #fff;
    font-size: .78rem;
    font-weight: 700;
    flex-shrink: 0;
}
.bg-consenso-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--bg-text);
}
.bg-consenso-text {
    font-size: .9rem;
    color: var(--bg-muted);
    line-height: 1.6;
    margin: 0 0 .75rem;
}
.bg-consenso-box .bg-checkbox label {
    font-size: .95rem;
    font-weight: 500;
    color: var(--bg-text);
}

/* ── Firma digitale ─────────────────────────────────────────────────────── */
.bg-firma-wrap {
    border: 2px solid var(--bg-border);
    border-radius: var(--bg-radius);
    overflow: hidden;
    background: #fff;
}
.bg-firma-canvas {
    display: block;
    width: 100%;
    height: 160px;
    cursor: crosshair;
    touch-action: none;
    background: #FAFAFA;
    border-bottom: 1px solid var(--bg-border);
}
.bg-firma-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .5rem .85rem;
    background: var(--bg-surface);
}
.bg-firma-clear {
    background: none !important;
    border: 1px solid var(--bg-border) !important;
    border-radius: 5px !important;
    padding: .3rem .75rem !important;
    font-size: .85rem !important;
    cursor: pointer !important;
    color: var(--bg-text) !important;
    box-shadow: none !important;
}
.bg-firma-clear:hover {
    background: #f0f0f0 !important;
}
.bg-firma-hint {
    font-size: .82rem;
    color: var(--bg-muted);
}
.bg-firma-canvas.bg-firma-signed {
    background: #fff;
}

/* ── Leggibilità migliorata (font più grandi, mobile-first) ────────────── */
.bg-form-wrap,
.bg-accesso-wrap,
.bg-dashboard,
.bg-ra-wrap {
    font-size: 17px !important;
    line-height: 1.6;
}

/* Card dashboard */
.bg-card { font-size: 1rem; }
.bg-card h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: 1rem; }

/* DL dati personali */
.bg-dl dt { font-size: .95rem; font-weight: 600; color: var(--bg-muted); }
.bg-dl dd { font-size: 1.05rem; font-weight: 500; }

/* Tabelle */
.bg-table th { font-size: .95rem; }
.bg-table td { font-size: 1rem; padding: .7rem .75rem; }

/* Form labels */
.bg-form-group label { font-size: 1rem; font-weight: 600; }
.bg-form-group input,
.bg-form-group select,
.bg-form-group textarea {
    font-size: 1rem !important;
    padding: .75rem 1rem !important;
}

/* Pulsanti */
.bg-btn { font-size: 1.05rem !important; padding: .85rem 1.75rem !important; }
.bg-link { font-size: 1rem; }
.bg-link-logout { font-size: 1rem; }

/* Consensi */
.bg-consenso-text { font-size: 1rem !important; }
.bg-checkbox label { font-size: 1rem !important; }
.bg-consenso-title { font-size: 1.05rem !important; }

/* Badge */
.bg-badge { font-size: .9rem; padding: .3rem .75rem; }

/* Section titles */
.bg-form-section-title { font-size: 1.05rem !important; font-weight: 700 !important; }

/* Mobile */
@media (max-width: 640px) {
    .bg-form-wrap,
    .bg-accesso-wrap,
    .bg-dashboard,
    .bg-ra-wrap { font-size: 16px !important; }

    .bg-form-group input,
    .bg-form-group select,
    .bg-form-group textarea {
        font-size: 16px !important; /* evita zoom automatico iOS */
        padding: .85rem 1rem !important;
    }

    .bg-card { padding: 1.1rem !important; }
    .bg-card h3 { font-size: 1.15rem; }

    .bg-dl dt { font-size: .9rem; }
    .bg-dl dd { font-size: 1rem; }

    .bg-table th,
    .bg-table td { font-size: .95rem; padding: .6rem .5rem; }

    .bg-btn { font-size: 1rem !important; padding: .85rem 1.5rem !important; width: 100%; }

    .bg-accesso-tab { font-size: 1rem !important; padding: .75rem 1.25rem !important; }

    .bg-consenso-box { padding: .9rem 1rem; }
    .bg-consenso-text { font-size: .95rem !important; }

    .bg-form-row { flex-direction: column !important; gap: 0 !important; }
    .bg-form-section-title { font-size: 1rem !important; }
}

/* ── Font grandi su desktop (override definitivo) ───────────────────────── */
@media (min-width: 641px) {
    .bg-form-wrap,
    .bg-accesso-wrap,
    .bg-dashboard,
    .bg-ra-wrap { font-size: 18px !important; line-height: 1.65; }

    .bg-card h3 { font-size: 1.25rem !important; }
    .bg-card { font-size: 1rem; }

    .bg-dl dt { font-size: 1rem !important; }
    .bg-dl dd { font-size: 1.1rem !important; }

    .bg-table th { font-size: 1rem !important; font-weight: 700; }
    .bg-table td { font-size: 1rem !important; padding: .8rem .9rem !important; }

    .bg-form-group label    { font-size: 1.05rem !important; font-weight: 600; }
    .bg-form-group input,
    .bg-form-group select,
    .bg-form-group textarea { font-size: 1.05rem !important; padding: .8rem 1rem !important; }

    .bg-btn { font-size: 1.1rem !important; padding: .9rem 2rem !important; }

    .bg-link,
    .bg-link-logout { font-size: 1.05rem !important; }

    .bg-consenso-text  { font-size: 1rem !important; line-height: 1.65; }
    .bg-consenso-title { font-size: 1.1rem !important; }
    .bg-checkbox label { font-size: 1rem !important; }

    .bg-badge { font-size: .95rem !important; padding: .3rem .85rem !important; }

    .bg-form-section-title { font-size: 1.1rem !important; font-weight: 700 !important; }
    .bg-field-hint { font-size: .9rem !important; }

    .bg-accesso-tab   { font-size: 1.05rem !important; }
    .bg-accesso-title { font-size: 1.4rem !important; }
    .bg-accesso-sub   { font-size: 1rem !important; }

    .bg-ra-table th,
    .bg-ra-table td   { font-size: 1rem !important; }
    .bg-ra-field label { font-size: 1rem !important; font-weight: 600; }
    .bg-ra-field input,
    .bg-ra-field select,
    .bg-ra-field textarea { font-size: 1rem !important; }
    .bg-ra-btn { font-size: 1rem !important; }
}

/* ── Firma obbligatoria - stato errore ──────────────────────────────────── */
.bg-firma-wrap.bg-firma-error {
    border-color: #FE0000;
    box-shadow: 0 0 0 3px rgba(254,0,0,.15);
}
.bg-firma-wrap.bg-firma-error .bg-firma-canvas {
    background: #FFF5F5;
}
.bg-firma-obbligatoria-hint {
    font-size: .85rem;
    color: #C2410C;
    margin-top: .35rem;
    display: flex;
    align-items: center;
    gap: .3rem;
}

/* ── Autocomplete comuni ─────────────────────────────────────────────────── */
.bg-comuni-suggest {
    position: absolute;
    z-index: 999;
    background: #fff;
    border: 1.5px solid var(--bg-border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
    max-height: 220px;
    overflow-y: auto;
    width: 100%;
}
.bg-comune-item {
    padding: .65rem 1rem;
    cursor: pointer;
    font-size: 1rem;
    border-bottom: 1px solid var(--bg-border);
}
.bg-comune-item:last-child { border-bottom: none; }
.bg-comune-item:hover { background: var(--bg-surface); color: var(--bg-primary); }
.bg-form-group { position: relative; }

/* ── Validazione campi ──────────────────────────────────────────────────── */
.bg-input-ok    { border-color: #16A34A !important; background: #F0FDF4 !important; }
.bg-input-error { border-color: #DC2626 !important; background: #FFF5F5 !important; }
.bg-input-warn  { border-color: #D97706 !important; background: #FFFBEB !important; }

.bg-validation-hint { display: block; margin-top: .3rem; font-size: .85rem; font-weight: 500; }
.bg-hint-ok    { color: #16A34A; }
.bg-hint-error { color: #DC2626; }
.bg-hint-warn  { color: #D97706; }

/* ── Autocomplete comuni ────────────────────────────────────────────────── */
.bg-comuni-suggest {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1.5px solid var(--bg-border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
    z-index: 999;
    max-height: 220px;
    overflow-y: auto;
}
.bg-comuni-item {
    padding: .7rem 1rem;
    cursor: pointer;
    font-size: .95rem;
    border-bottom: 1px solid var(--bg-border);
    transition: background .1s;
}
.bg-comuni-item:last-child { border-bottom: none; }
.bg-comuni-item:hover { background: #FFF5F5; color: var(--bg-primary); }

/* Il campo comune ha bisogno di position:relative per il suggest */
.bg-comune-input { width: 100%; }
.bg-form-group:has(.bg-comune-input) { position: relative; }

/* ── Consenso immagini con radio button ─────────────────────────────────── */
.bg-radio-group {
    display: flex;
    flex-direction: column;
    gap: .6rem;
    margin: .5rem 0 .75rem;
}
.bg-radio-label {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    cursor: pointer;
    padding: .65rem .9rem;
    border-radius: 8px;
    border: 1.5px solid var(--bg-border);
    background: #fff;
    transition: border-color .15s, background .15s;
    font-size: 1rem;
    line-height: 1.5;
}
.bg-radio-label:has(input:checked) {
    border-color: var(--bg-primary);
    background: #fff5f5;
}
.bg-radio-label input[type="radio"] {
    margin-top: .25rem;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    accent-color: var(--bg-primary);
}
.bg-radio-label span { flex: 1; }
.bg-consenso-note {
    font-size: .85rem;
    color: var(--bg-muted);
    background: #f9f9f9;
    border-radius: 6px;
    padding: .6rem .9rem;
    margin-top: .25rem;
    line-height: 1.5;
}

/* ── Capitalizzazione automatica nome/cognome ───────────────────────────── */
input.bg-capitalize {
    text-transform: capitalize;
}
input.bg-lowercase {
    text-transform: lowercase;
}

/* ============================================================
   Previene lo zoom automatico di iOS sui campi input quando
   il font-size è inferiore a 16px (problema dentro app Capacitor)
   ============================================================ */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="search"],
input[type="date"],
select,
textarea {
    font-size: 16px !important;
}

/* ============================================================
   Font più grandi per la pagina di login/accesso dentro l'app
   ============================================================ */
@media (max-width: 768px) {
    .bg-accesso-title { font-size: 1.6rem !important; }
    .bg-accesso-tab { font-size: 1.05rem !important; padding: 1rem 1.5rem !important; }
    .bg-accesso-wrap label { font-size: 1.05rem !important; }
    .bg-accesso-wrap input[type="text"],
    .bg-accesso-wrap input[type="email"],
    .bg-accesso-wrap input[type="password"] {
        font-size: 17px !important;
        padding: 0.9rem 1rem !important;
    }
    .bg-accesso-wrap .bg-btn,
    .bg-accesso-wrap #wp-submit {
        font-size: 17px !important;
        padding: 0.9rem 1.5rem !important;
        min-height: 48px !important;
    }
}
