.bm-row{
    cursor:pointer;
}

#bm-widget .bm-row{
    cursor:pointer;
}

#bm-widget.bm-oro-active .bm-selected{
    background:#FBBA07;
    color:#000;
    font-weight:700;
}

#bm-widget.bm-argento-active .bm-selected{
    background:#c0c0c0;
    color:#000;
    font-weight:700;
}

#bm-widget{
    position:relative;
}

#bm-modal{
    display:none;
    position:absolute;
    top:0;
    left:0;
    right:0;
    bottom:0;
    background:#fff;
    z-index:999;
    padding:20px;
    overflow:auto;
    border:1px solid #ccc;
    box-sizing:border-box;
}

/*
 * Quando si apre la maschera, il contenuto principale viene nascosto
 * e il modal torna nel normale flusso della pagina. In questo modo
 * #bm-widget assume l'altezza reale del form o del messaggio finale.
 */
#bm-widget.bm-modal-open > .bm-hero,
#bm-widget.bm-modal-open > .bm-grammi-wrap,
#bm-widget.bm-modal-open > #bm-oro,
#bm-widget.bm-modal-open > #bm-argento,
#bm-widget.bm-modal-open > .bm-caratura-instruction,
#bm-widget.bm-modal-open > table,
#bm-widget.bm-modal-open > p,
#bm-widget.bm-modal-open > .bm-note{
    display:none;
}

#bm-widget.bm-modal-open #bm-modal{
    display:block;
    position:relative;
    inset:auto;
    width:100%;
    overflow:visible;
}

#bm-widget:has(#bm-modal[style*="display:block"]),
#bm-widget:has(#bm-modal[style*="display: block"]) {
    padding: 0 !important;
}

#bm-selected-info{
    background:#f8f8f8;
    padding:15px;
    margin-bottom:15px;
    border:1px solid #ddd;
}

.bm-row2{
    display:flex;
    gap:10px;
    margin-bottom:10px;
}

.bm-row2 input{
    width:100%;
}

.bm-row3{
    display:flex;
    gap:10px;
    align-items:stretch;
}

.bm-row3 textarea{
    flex:1;
    min-height:90px;
}

.bm-row3 button{
    white-space:nowrap;
}

.bm-summary-table{
    width:100%;
    font-size:13px;
    border-collapse:collapse;
}

.bm-market-chart{
    background:#fff;
    border:1px solid #e5e5e5;
    border-radius:14px;
    padding:25px;
    margin:25px 0;
    box-shadow:0 3px 15px rgba(0,0,0,.08);
}

.bm-market-chart h3{
    margin:0 0 20px;
    text-align:center;
    font-size:22px;
    font-weight:700;
}

.bm-market-header{
    margin-bottom:25px;
    padding-bottom:20px;
    border-bottom:1px solid #e5e5e5;
}

.bm-market-header-compare{
    display:flex;
    gap:25px;
}

.bm-market-price{
    flex:1;
}

.bm-market-price small{
    display:block;
    color:#666;
    font-size:12px;
    text-transform:uppercase;
    letter-spacing:1px;
    margin-bottom:6px;
}

.bm-market-price strong{
    display:block;
    font-size:34px;
    font-weight:700;
    line-height:1;
    color:#111;
}

.bm-chart-legend{
    margin-bottom:10px;
}

.bm-dot-gold,
.bm-dot-silver{
    display:inline-block;
    width:12px;
    height:12px;
    margin-right:5px;
    vertical-align:middle;
}

.bm-dot-gold{
    background:#018237;
}

.bm-dot-silver{
    background:#999;
}

.bm-market-chart svg{
    display:block;
    width:100%;
    height:auto;
}

.bm-market-chart text{
    font-family:inherit;
}
.bm-caratura-instruction {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin: 18px 0 12px;
    padding: 12px 15px;
    border-left: 4px solid #bf9b30;
    border-radius: 6px;
    background: rgba(191, 155, 48, 0.10);
    color: #222222;
    font-size: 15px;
    line-height: 1.45;
    font-weight: 600;
    box-sizing: border-box;
}

.bm-caratura-instruction::before {
    content: "↓";
    flex: 0 0 auto;
    font-size: 20px;
    line-height: 1;
    color: #bf9b30;
}

@media (max-width: 767px) {

    /* Tabella principale */
    #bm-widget > table,
    #bm-widget > table tbody {
        display: block;
        width: 100%;
    }

    #bm-widget > table thead {
        display: none;
    }

    #bm-widget > table tr.bm-row {
        position: relative;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px 14px;
        width: 100%;
        margin: 0 0 12px;
        padding: 15px 16px;
        border: 1px solid #dedede;
        border-radius: 10px;
        background: #fff;
        cursor: pointer;
        box-sizing: border-box;
        transition:
            border-color 0.2s ease,
            box-shadow 0.2s ease,
            background-color 0.2s ease;
    }

    #bm-widget > table tr.bm-row td {
        display: block;
        width: auto;
        padding: 0;
        border: 0;
        text-align: left;
        box-sizing: border-box;
    }

    /* Caratura */
    #bm-widget > table tr.bm-row td:nth-child(1) {
        grid-column: 1 / -1;
        padding-right: 32px;
        font-size: 19px;
        line-height: 1.2;
        font-weight: 700;
    }

    #bm-widget > table tr.bm-row td:nth-child(1)::before {
        content: "Caratura";
        display: block;
        margin-bottom: 3px;
        font-size: 11px;
        line-height: 1.2;
        font-weight: 600;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        opacity: 0.65;
    }

    /* Prezzo al grammo */
    #bm-widget > table tr.bm-row td:nth-child(2)::before {
        content: "Prezzo al grammo";
        display: block;
        margin-bottom: 3px;
        font-size: 11px;
        line-height: 1.2;
        font-weight: 600;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        opacity: 0.65;
    }

    /* Valore totale */
    #bm-widget > table tr.bm-row td:nth-child(3) {
        text-align: right;
        font-weight: 700;
    }

    #bm-widget > table tr.bm-row td:nth-child(3)::before {
        content: "Valore";
        display: block;
        margin-bottom: 3px;
        font-size: 11px;
        line-height: 1.2;
        font-weight: 600;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        opacity: 0.65;
    }

    /* Indicatore circolare di selezione */
    #bm-widget > table tr.bm-row::after {
        content: "";
        position: absolute;
        top: 16px;
        right: 16px;
        width: 18px;
        height: 18px;
        border: 2px solid #b8b8b8;
        border-radius: 50%;
        box-sizing: border-box;
    }

    #bm-widget > table tr.bm-row.bm-selected {
        border-color: currentColor;
        box-shadow: 0 0 0 1px currentColor;
    }

    #bm-widget > table tr.bm-row.bm-selected::after {
        border-width: 5px;
        border-color: currentColor;
    }

    /* Campo peso */
    #bm-widget .bm-grammi-wrap {
        width: 100%;
        margin-bottom: 16px;
    }

    #bm-widget #bm-grammi {
        width: 100%;
        min-height: 48px;
        padding: 10px 14px;
        font-size: 16px;
        box-sizing: border-box;
    }

    /* Pulsanti metallo */
    #bm-widget #bm-oro,
    #bm-widget #bm-argento {
        width: calc(50% - 4px);
        min-height: 46px;
        margin-bottom: 14px;
    }

    /* Pulsante Blocca prezzo */
    #bm-widget #bm-open {
        width: 100%;
        min-height: 50px;
    }
    
       /* Contenitore riepilogo */
    #bm-selected-info {
        width: 100%;
        margin-bottom: 20px;
    }

    /* Tabella riepilogo */
    #bm-selected-info .bm-summary-table {
        display: block;
        width: 100%;
        margin: 0;
        border: 0;
        border-collapse: separate;
    }

    #bm-selected-info .bm-summary-table tbody {
        display: block;
        width: 100%;
    }

    /*
     * Nasconde la prima riga contenente le intestazioni:
     * Metallo, Caratura, Peso, Prezzo/g, Totale
     */
    #bm-selected-info .bm-summary-table tr:first-child {
        display: none;
    }

    /* Riga dei valori trasformata in scheda */
    #bm-selected-info .bm-summary-table tr:last-child {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 14px 18px;
        width: 100%;
        padding: 18px;
        border: 1px solid #dedede;
        border-radius: 12px;
        background: #ffffff;
        box-sizing: border-box;
    }

    /* Celle */
    #bm-selected-info .bm-summary-table td {
        display: block;
        width: auto;
        padding: 0;
        border: 0;
        text-align: left;
        font-size: 16px;
        line-height: 1.3;
    }

    /* Etichette sopra ogni valore */
    #bm-selected-info .bm-summary-table td::before {
        display: block;
        margin-bottom: 5px;
        font-size: 11px;
        line-height: 1.2;
        font-weight: 700;
        letter-spacing: 0.05em;
        text-transform: uppercase;
        opacity: 0.65;
    }

    #bm-selected-info .bm-summary-table td:nth-child(1)::before {
        content: "Metallo";
    }

    #bm-selected-info .bm-summary-table td:nth-child(2)::before {
        content: "Caratura";
    }

    #bm-selected-info .bm-summary-table td:nth-child(3)::before {
        content: "Peso";
    }

    #bm-selected-info .bm-summary-table td:nth-child(4)::before {
        content: "Prezzo al grammo";
    }

    /* Totale a larghezza piena */
    #bm-selected-info .bm-summary-table td:nth-child(5) {
        grid-column: 1 / -1;
        margin-top: 2px;
        padding-top: 14px;
        border-top: 1px solid rgba(0, 0, 0, 0.12);
        font-size: 21px;
        font-weight: 700;
    }

    #bm-selected-info .bm-summary-table td:nth-child(5)::before {
        content: "Valore totale";
    }

    /* Numeri del riepilogo */
    #bm-selected-info .bm-summary-number {
        white-space: nowrap;
    }

    #bm-selected-info .bm-summary-total {
        font-size: inherit;
        font-weight: 700;
    }
    
    #bm-widget .bm-grammi-wrap {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        width: 100%;
    }

    #bm-widget .bm-grammi-wrap .bm-label {
        display: block;
        width: 100%;
        margin: 0;
    }

    #bm-widget .bm-grammi-wrap #bm-grammi {
        display: block;
        width: 100%;
        min-height: 48px;
        margin: 0;
        box-sizing: border-box;
    }
    
      .bm-caratura-instruction {
        margin: 16px 0 10px;
        padding: 11px 13px;
        font-size: 14px;
        line-height: 1.4;
    }

    .bm-caratura-instruction::before {
        font-size: 18px;
    }
}
