@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,wght@0,400;0,600;1,400&family=Inter:wght@400;500;600&display=swap');

/* ── CUSTOM PROPERTIES ── */
:root {
    --blue:         #1B3A6B;
    --blue-light:   #E8F0FB;
    --blue-mid:     #2d5a9e;
    --orange:       #E8600A;
    --orange-light: #FEF0E8;
    --teal:         #0E9B8A;
    --teal-light:   #E1F5EE;
    --surface:      #ffffff;
    --surface2:     #f5f5f5;
    --border:       #e2e2e2;
    --text:         #1a1a1a;
    --muted:        #6b6b6b;
    --r:            12px;
    --rm:           8px;
    --transition:   .22s cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', sans-serif;
    background: #f0f3f8;
    color: var(--text);
    font-size: 15px;
    min-height: 100vh;
    overflow-x: hidden;
    max-width: 1240px;
    margin: 0 auto;
}

/* ── ANIMAZIONI ── */

/* Entrata view: slide dal basso + fade */
@keyframes viewIn {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0);    }
}

/* Uscita view: fade verso l'alto */
@keyframes viewOut {
    from { opacity: 1; transform: translateY(0);     }
    to   { opacity: 0; transform: translateY(-12px); }
}

/* Entrata riga tabella (usata con stagger via JS) */
@keyframes rowIn {
    from { opacity: 0; transform: translateX(-8px); }
    to   { opacity: 1; transform: translateX(0);    }
}

/* Bounce sul bottone submit */
@keyframes btnBounce {
    0%   { transform: scale(1);    }
    40%  { transform: scale(.93);  }
    70%  { transform: scale(1.05); }
    100% { transform: scale(1);    }
}

/* Pulsazione dot loader */
@keyframes dotPulse {
    0%, 80%, 100% { transform: scale(0.6); opacity: .4; }
    40%            { transform: scale(1);   opacity: 1;  }
}

/* Spin classico (fallback) */
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Classe attiva per animare entrata di una view */
.view-enter {
    animation: viewIn var(--transition) both;
}

/* ── LOADER ── */
.modaleLoader {
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    z-index: 600;
    position: fixed;
    inset: 0;
    background-color: rgba(27, 58, 107, 0.72);
    backdrop-filter: blur(2px);
}
.dot-loader {
    display: flex;
    gap: 8px;
    align-items: center;
}
.dot-loader span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    animation: dotPulse 1.4s ease-in-out infinite;
}
.dot-loader span:nth-child(2) { animation-delay: .2s; }
.dot-loader span:nth-child(3) { animation-delay: .4s; }
.loader-label {
    font-size: 13px;
    color: rgba(255,255,255,.8);
    letter-spacing: .04em;
    font-family: 'Inter', sans-serif;
}

/* ── MODALE ── */
.modale {
    display: none;
    align-items: flex-start;
    justify-content: center;
    z-index: 500;
    position: fixed;
    inset: 0;
    background-color: rgba(27, 58, 107, 0.55);
    backdrop-filter: blur(2px);
    overflow-y: auto;
    padding: 1.5rem 1rem;
}
.divModale {
    background: var(--surface);
    border-radius: var(--r);
    padding: 1.5rem;
    max-width: 480px;
    width: 90%;
    margin: auto;
    animation: viewIn .25s cubic-bezier(.4,0,.2,1) both;
}
.divModale h2 {
    font-family: 'Fraunces', serif;
    font-size: 18px;
    color: var(--blue);
    margin-bottom: .75rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.divModale p { font-size: 14px; color: var(--muted); line-height: 1.6; }
.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

/* Animazione entrata logo */
@keyframes logoIn {
    from { opacity: 0; transform: translateY(-12px) scale(.88); }
    to   { opacity: 1; transform: translateY(0)     scale(1);   }
}

/* ── HERO ── */
.hero {
    background: var(--blue-light);
    border-bottom: 0.5px solid var(--border);
    padding: 2rem 1.25rem 1.5rem;
    position: relative;
    overflow: hidden;
}
/* Cerchio decorativo — animato lentamente */
.hero::before {
    content: '';
    position: absolute;
    right: -50px;
    top: -50px;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: var(--orange-light);
    opacity: .7;
    pointer-events: none;
    animation: heroOrb 8s ease-in-out infinite alternate;
}
@keyframes heroOrb {
    from { transform: translate(0, 0) scale(1);    }
    to   { transform: translate(-20px, 16px) scale(1.12); }
}
/* Logo hero — in alto a destra, sopra il cerchio decorativo */
.hero-logo {
    position: absolute;
    top: 1rem;
    right: 1rem;
    height: 160px;
    width: auto;
    object-fit: contain;
    z-index: 2;
    animation: logoIn .55s cubic-bezier(.4,0,.2,1) .1s both;
    filter: drop-shadow(0 2px 6px rgba(27,58,107,.18));
}
@media (max-width: 480px) {
    .hero-logo { height: 130px; top: .75rem; right: .75rem; }
}
@media (max-width: 400px) {
    .hero-logo { height: 100px; top: .75rem; right: .75rem; }
}

.hero-eyebrow {
    font-size: 11px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--orange);
    font-weight: 600;
    margin-bottom: .5rem;
    position: relative;
}
.hero-title {
    font-family: 'Fraunces', serif;
    font-size: 1.6em;
    font-weight: 600;
    color: var(--blue);
    line-height: 1.2;
    margin-bottom: .4rem;
    position: relative;
}
.hero-title em { font-style: italic; color: var(--orange); }
.hero-sub {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.7;
    position: relative;
}

/* ── STEP BAR ── */
.steps {
    display: flex;
    align-items: center;
    padding: 0 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 6px rgba(0,0,0,.06);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    position: sticky;
    top: 0;
    z-index: 100;
}
.steps::-webkit-scrollbar { display: none; }

.step-sep {
    color: var(--border);
    font-size: 13px;
    flex-shrink: 0;
    pointer-events: none;
    user-select: none;
    padding: 0 .05rem;
}

.step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: .6rem .65rem;
    border-radius: 8px;
    cursor: default;
    flex-shrink: 0;
    min-height: 56px;
    transition: background var(--transition), color var(--transition);
}

.step-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.step-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    line-height: 1.2;
    white-space: nowrap;
}

.step-sub {
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: none;
    line-height: 1.2;
    font-weight: 400;
}

.step-num {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    background: var(--surface2);
    color: var(--muted);
    flex-shrink: 0;
    transition: background var(--transition), color var(--transition);
}

/* Active step */
.step.active .step-num  { background: var(--orange); color: #fff; }
.step.active .step-label { color: var(--text); font-weight: 600; font-size: 13px; }

/* Done step — navigable back button */
.step.done { cursor: pointer; }
.step.done .step-num {
    background: var(--teal);
    color: #fff;
    font-size: 0;
}
.step.done .step-num::after  { content: '✓'; font-size: 12px; font-weight: 700; }
.step.done .step-label       { color: var(--teal); font-weight: 500; }
.step.done .step-sub         { display: block; }

.step.done:hover              { background: var(--teal-light); }
.step.done:hover .step-label  { color: var(--blue); }
.step.done:hover .step-num    { background: var(--blue); }
.step.done:hover .step-num::after { content: '←'; }

/* Mobile: hide sub-labels, tighten spacing */
@media (max-width: 540px) {
    .steps { padding: 0 .5rem; }
    .step  { padding: .55rem .4rem; gap: 6px; }
    .step-sub { display: none !important; }
    .step-label { font-size: 11px; }
    .step.active .step-label { font-size: 12px; }
}

/* ── PANELS ── */
.panel { padding: 1rem 1.25rem; background: var(--surface); }

/* ── FORM FIELDS ── */
.field-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-start;
    padding-left: 5px;
    padding-right: 5px;
}

.field-groupNoGap {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    padding-left: 5px;
    padding-right: 5px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1 1 140px;      /* cresce e si restringe, mai sotto 140px */
    min-width: 0;
}
.field label {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: .05em;
    text-transform: uppercase;
    white-space: normal;
}
.field select,
.field input[type="text"] {
    width: 100%;
    height: 42px;
    border: 0.5px solid var(--border);
    border-radius: var(--rm);
    padding: 0 12px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    min-width: 0;         /* evita overflow su mobile */
}
.field select:focus,
.field input[type="text"]:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(27,58,107,.1);
}
/* Campo ricerca scuola: occupa tutta la riga su mobile */
.field.wide { flex: 2 1 200px; }

/* ── BUTTONS ── */
.btn-primary {
    height: 42px;
    padding: 0 20px;
    border-radius: var(--rm);
    border: none;
    background: var(--orange);
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: opacity var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
    align-self: flex-end;
}
.btn-primary:hover   { opacity: .88; }
.btn-primary:disabled { opacity: .45; cursor: default; }
.btn-primary.bounce  { animation: btnBounce .35s ease both; }

/* Su mobile il bottone occupa tutta la larghezza */
@media (max-width: 750px) {
    .hero-eyebrow, .hero-title, .hero-sub { max-width: 320px; }
}

/* Su mobile il bottone occupa tutta la larghezza */
@media (max-width: 600px) {
    .hero-eyebrow, .hero-title, .hero-sub { max-width: 280px; }
}
@media (max-width: 480px) {
    .btn-primary { width: 100%; }
    .field, .field.wide { flex: unset; width: 100%; }
    .hero-title { max-width: 220px; }
    .hero-eyebrow  { max-width: 240px; }
}
.btn-back {
    height: 36px;
    padding: 0 14px;
    border-radius: var(--rm);
    border: 0.5px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background var(--transition);
    margin-bottom: 1rem;
}
.btn-back:hover { background: var(--surface2); }

/* Barra azioni in view-libri: back + copia link affiancati */
.nav-actions-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.nav-actions-bar .btn-back { margin-bottom: 0; }

/* Versione più visibile del pulsante "Cambia classe" */
.btn-back-main {
    height: 40px;
    padding: 0 18px;
    border-width: 1.5px;
    background: var(--surface2);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
}
.btn-back-main:hover { background: var(--border); }

/* Pulsante "Link ricerca" */
.btn-link-ricerca {
    height: 36px;
    padding: 0 14px;
    border-radius: var(--rm);
    border: 1px dashed var(--border);
    background: var(--surface);
    color: var(--muted);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.btn-link-ricerca:hover {
    background: var(--surface2);
    color: var(--text);
    border-style: solid;
}
.btn-link-ricerca.copiato {
    background: var(--teal-light);
    color: var(--teal);
    border-color: var(--teal);
    border-style: solid;
}

.btn-secondary {
    align-items: center;
    height: 38px;
    padding: 0 16px;
    border-radius: var(--rm);
    border: 0.5px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    cursor: pointer;
    transition: background var(--transition);
}
.btn-secondary:hover { background: var(--border); }

.icon-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--rm);
    border: 0.5px solid var(--border);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition), transform .12s;
    flex-shrink: 0;
}
.icon-btn:hover  { background: var(--blue-light); }
.icon-btn:active { transform: scale(.92); }
.icon-btn i { font-size: 15px; color: var(--muted); }

/* ── FILTER ROW ── */
.filter-row {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: .65rem 1.25rem;
    flex-wrap: wrap;
    border-bottom: 0.5px solid var(--border);
    background: var(--surface2);
}
.search-wrap {
    position: relative;
    flex: 1;
    min-width: 0;        /* non spinge oltre il contenitore */
}
.search-wrap i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: var(--muted);
    pointer-events: none;
}
.search-bar {
    width: 100%;
    height: 36px;
    border: 0.5px solid var(--border);
    border-radius: var(--rm);
    padding: 0 10px 0 32px;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color var(--transition);
    min-width: 0;
}
.search-bar:focus { border-color: var(--blue); }

/* ── BADGES ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}
.badge-blue   { background: var(--blue-light);   color: var(--blue);   }
.badge-orange { background: var(--orange-light);  color: var(--orange); }
.badge-teal   { background: var(--teal-light);    color: var(--teal);   }

/* ── PILLS ── */
.pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.pill-si  { background: var(--teal-light);   color: var(--teal);   }
.pill-no  { background: var(--surface2);      color: var(--muted);  }
.pill-new { background: var(--orange-light);  color: var(--orange); }

/* ── TABELLE ── */
/*
   Su desktop: tabella normale.
   Su mobile (<600px): ogni <tr> diventa una "card" impilata verticalmente.
   Le <td> mostrano l'etichetta (da data-label) sopra il valore.
   Nessun scroll orizzontale.
*/
.tbl-wrap { width: 100%; overflow-x: hidden; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: var(--surface);
}
thead th {
    padding: .6rem 1rem;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    text-align: left;
    border-bottom: 0.5px solid var(--border);
    background: var(--surface);
    white-space: nowrap;
    user-select: none;
}
thead th[data-sort="true"] { cursor: pointer; }
thead th[data-sort="true"]:hover { color: var(--text); }
thead th.sorted { color: var(--blue); }

/* Riga filtri per colonna */
.filter-inputs-row th {
    padding: .3rem .5rem;
    background: var(--surface2);
    border-bottom: 0.5px solid var(--border);
}
.col-filter {
    width: 100%;
    height: 30px;
    border: 0.5px solid var(--border);
    border-radius: var(--rm);
    padding: 0 8px;
    font-size: 12px;
    font-family: 'Inter', sans-serif;
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color var(--transition);
    min-width: 0;
}
.col-filter:focus { border-color: var(--blue); }

tbody tr {
    border-bottom: 0.5px solid var(--border);
    transition: background var(--transition);
}
tbody tr:hover { background: var(--blue-light); }
/* Scuola di riferimento per più plessi/indirizzi (elenco ricerca scuola) */
tbody tr.row-riferimento { background: var(--blue-light); box-shadow: inset 3px 0 0 var(--blue); }
tbody tr.row-riferimento:hover { filter: brightness(.96); }
/* Animazione entrata righe — classe aggiunta via JS */
tbody tr.row-enter {
    animation: rowIn .28s ease both;
}
tbody td {
    padding: .6rem 1rem;
    color: var(--text);
    vertical-align: middle;
}
tbody td.muted { color: var(--muted); }

/* ── RESPONSIVE TABELLE — card mode su mobile ── */
@media (max-width: 600px) {

    /* Nasconde intestazioni e riga filtri (rimane per screen reader) */
    table thead { display: none; }
    .filter-inputs-row { display: none; }

    /* Ogni riga diventa un blocco card */
    table tbody tr {
        display: block;
        margin: .5rem 0;
        border: 0.5px solid var(--border);
        border-radius: var(--rm);
        overflow: hidden;
        background: var(--surface);
    }
    table tbody tr:hover { background: var(--blue-light); }

    /* Ogni cella occupa tutta la larghezza */
    table tbody td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        padding: .5rem 1rem;
        border-bottom: 0.5px solid var(--border);
        font-size: 13px;
    }
    table tbody td:last-child { border-bottom: none; }

    /* Etichetta colonna prima del valore, presa da data-label */
    table tbody td::before {
        content: attr(data-label);
        font-size: 10px;
        font-weight: 600;
        letter-spacing: .05em;
        text-transform: uppercase;
        color: var(--muted);
        white-space: nowrap;
        flex-shrink: 0;
        min-width: 80px;
    }

    /* La prima cella (bottone) senza label */
    table tbody td:first-child {
        justify-content: flex-end;
        padding: .4rem 1rem;
        background: var(--surface2);
    }
    table tbody td:first-child::before { display: none; }
}

/* ── SCUOLA SELECTED LABEL ── */
.scuola-label {
    background: var(--blue-light);
    border-radius: var(--rm);
    padding: .65rem 1rem;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.scuola-label-title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
}
.scuola-label-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--blue);
    word-break: break-word;
}

.label-name11 {
    font-size: 11px;
    font-weight: 500;
    color: var(--blue);
    word-break: break-word;
}

/* ── DETAIL CARD ── */
.detail-card {
    background: var(--surface);
    border: 0.5px solid var(--border);
    border-radius: var(--r);
    overflow: hidden;
}
.detail-header {
    background: var(--blue);
    padding: 1.25rem;
}
.detail-title {
    font-family: 'Fraunces', serif;
    font-size: 20px;
    color: #fff;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: .3rem;
    word-break: break-word;
}
.detail-sub { font-size: 13px; color: rgba(255,255,255,.7); }
.detail-body { padding: 1.25rem; }
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .85rem 1.5rem;
}
@media (max-width: 480px) {
    .detail-grid { grid-template-columns: 1fr; }
}
.detail-row { display: flex; flex-direction: column; gap: 3px; }
.detail-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
}
.detail-value { font-size: 14px; color: var(--text); font-weight: 500; }
.detail-price {
    font-family: 'Fraunces', serif;
    font-size: 30px;
    color: var(--orange);
    font-weight: 600;
    line-height: 1;
    margin-bottom: 1rem;
}
.detail-isbn {
    font-size: 17px;
    font-family: monospace;
    background: var(--surface2);
    padding: 4px 10px;
    border-radius: 4px;
    color: var(--text);
    font-weight: 600;
    letter-spacing: .03em;
    display: inline-block;
    word-break: break-all;
}

/* ── EMPTY STATE ── */
.empty {
    padding: 3rem 1.25rem;
    text-align: center;
    color: var(--muted);
    background: var(--surface);
}
.empty i { font-size: 40px; display: block; margin-bottom: .75rem; opacity: .3; }
.empty p  { font-size: 14px; }

/* ── PANNELLO FILTRI UNIFICATO ── */
.filter-panel {
    background: var(--surface2);
    border-bottom: 0.5px solid var(--border);
    padding: .65rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}
.filter-panel-top {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.filter-panel-top .search-wrap {
    flex: 1;
    min-width: 160px;
}

/* ── CHIP FILTRI ── */
.filter-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}
.chip {
    height: 32px;
    padding: 0 14px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), color var(--transition),
                border-color var(--transition), transform .1s;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    user-select: none;
}
.chip:hover {
    border-color: var(--blue);
    color: var(--blue);
}
.chip:active { transform: scale(.95); }

/* Stato attivo — chip selezionato */
.chip.attivo {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
}
.chip.attivo:hover {
    background: var(--blue-mid);
    border-color: var(--blue-mid);
    color: #fff;
}

/* Chip reset — appare solo quando c'è un filtro attivo */
.chip-reset {
    border-color: var(--orange);
    color: var(--orange);
}
.chip-reset:hover {
    background: var(--orange-light);
    border-color: var(--orange);
    color: var(--orange);
}

/* ── SCELTA MODALITÀ ── */
.modalita-wrap {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-top: .5rem;
}
.modalita-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 1.25rem;
    border-radius: var(--r);
    border: 1.5px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition), transform .12s;
    text-align: left;
    font-family: 'Inter', sans-serif;
}
.modalita-card i {
    font-size: 28px;
    color: var(--muted);
    transition: color var(--transition);
}
.modalita-card:hover {
    border-color: var(--blue);
    box-shadow: 0 4px 16px rgba(27,58,107,.1);
    transform: translateY(-2px);
}
.modalita-card:hover i { color: var(--blue); }
.modalita-card:active { transform: translateY(0); }

.modalita-card-acquisto:hover { border-color: var(--orange); box-shadow: 0 4px 16px rgba(232,96,10,.1); }
.modalita-card-acquisto:hover i { color: var(--orange); }
.modalita-card-vendita:hover  { border-color: var(--teal);   box-shadow: 0 4px 16px rgba(14,155,138,.1); }
.modalita-card-vendita:hover i { color: var(--teal); }

.modalita-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}
.modalita-card-sub {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.5;
}

/* ── MARKETPLACE ── */
.mercato-section-title {
    font-family: 'Fraunces', serif;
    font-size: 17px;
    font-weight: 600;
    color: var(--blue);
    margin-bottom: .75rem;
    padding-bottom: .4rem;
    border-bottom: 0.5px solid var(--border);
}
.mercato-annunci { margin-bottom: 1.5rem; }
.mercato-form-wrap {
    background: var(--surface2);
    border-radius: var(--r);
    padding: 1.25rem;
    border: 0.5px solid var(--border);
}

/* Card annuncio */
.annuncio-card {
    background: var(--surface);
    border: 0.5px solid var(--border);
    border-radius: var(--rm);
    padding: .85rem 1rem;
    margin-bottom: .5rem;
    animation: rowIn .25s ease both;
}
.annuncio-top {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: .35rem;
}
.annuncio-nome {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    flex: 1;
    min-width: 80px;
}
.annuncio-prezzo {
    font-family: 'Fraunces', serif;
    font-size: 16px;
    font-weight: 600;
    color: var(--orange);
}
.annuncio-data {
    font-size: 11px;
    color: var(--muted);
}
.annuncio-info-pubblica {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem .75rem;
    margin: .35rem 0 .5rem;
}
.annuncio-info-item {
    font-size: 13px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 4px;
}
.annuncio-info-item i { color: var(--muted); font-size: 14px; }
.annuncio-contatti-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .6rem .75rem;
    margin-top: .4rem;
    display: flex;
    flex-direction: column;
    gap: .35rem;
}
.annuncio-contatti-intro {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: .15rem;
}
.annuncio-contatto-riga {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.annuncio-contatto-riga i { color: var(--blue); font-size: 15px; }
.annuncio-contatto-riga a { color: var(--blue); text-decoration: none; }
.annuncio-contatto-riga a:hover { text-decoration: underline; }
.annuncio-nota {
    font-size: 12px;
    color: var(--muted);
    font-style: italic;
}
.wa-link {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    color: #25d366;
    text-decoration: none;
    font-weight: 600;
    margin-left: 4px;
}
.wa-link:hover { text-decoration: underline; }
.wa-link i { color: #25d366; font-size: 15px; }
.annuncio-vuoto {
    font-size: 13px;
    color: var(--muted);
    padding: .75rem 0;
    font-style: italic;
}
.annuncio-loading {
    font-size: 13px;
    color: var(--blue);
    font-weight: 500;
    padding: .5rem 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.annuncio-loading .spin-icon {
    font-size: 16px;
    display: inline-block;
    animation: spin .8s linear infinite;
}

/* ── CHAT (messaggi legati a un annuncio) ── */
.btn-chat {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--rm);
    border: 1px solid var(--blue);
    background: var(--surface);
    color: var(--blue);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.btn-chat:hover { background: var(--blue-light); }
.btn-chat.btn-chat-attiva {
    background: var(--blue);
    color: #fff;
}
.btn-chat.btn-chat-attiva:hover { opacity: .9; }
.btn-chat .chat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--orange);
    display: inline-block;
}

.notifiche-badge {
    position: absolute;
    top: -4px;
    right: -6px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--orange);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}

.conversazione-card {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem;
    border: 1px solid var(--border);
    border-radius: var(--rm);
    margin-bottom: .5rem;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}
.conversazione-card:hover { background: var(--blue-light); border-color: var(--blue); }
.conversazione-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--blue-light);
    color: var(--blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.conversazione-info { flex: 1; min-width: 0; }
.conversazione-nome { font-weight: 600; font-size: 14px; }
.conversazione-ultimo {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}
.conversazione-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}
.conversazione-data { font-size: 11px; color: var(--muted); }
.conversazione-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--orange);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.divModale-chat {
    max-width: 480px;
    height: 82vh;
    max-height: 640px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
/* Evita che un nome lungo spinga fuori schermo i pulsanti Blocca/Chiudi */
#chatTitolo {
    min-width: 0;
    overflow: hidden;
}
#chat-titolo-nome {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}
/* Su mobile la chat occupa tutto lo schermo, senza margini/bordi sprecati */
@media (max-width: 480px) {
    #divModaleChat {
        padding: 0;
        align-items: stretch;
    }
    #divModaleChat .divModale-chat {
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
    }
}
.chat-thread {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: .5rem .25rem;
    background: var(--surface2);
    border-radius: var(--rm);
}
.chat-bubble-row { display: flex; }
.chat-bubble-row.mio { justify-content: flex-end; }
.chat-bubble {
    max-width: 78%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    word-break: break-word;
    position: relative;
}
.chat-bubble.altro {
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom-left-radius: 3px;
}
.chat-bubble.mio {
    background: var(--blue-light);
    color: var(--text);
    border-bottom-right-radius: 3px;
}
.chat-bubble-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 3px;
    font-size: 10px;
    color: var(--muted);
}
.chat-spunte { font-size: 13px; color: var(--muted); }
.chat-spunte.letto { color: #34b7f1; } /* stile WhatsApp: doppia spunta blu se letto */
.chat-input-row {
    display: flex;
    gap: .5rem;
    margin-top: .75rem;
}
.chat-input-row input {
    flex: 1;
    height: 42px;
    padding: 0 12px;
    border: 0.5px solid var(--border);
    border-radius: var(--rm);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
}
.chat-input-row .btn-primary {
    width: 42px;
    height: 42px;
    padding: 0;
    justify-content: center;
}
.notifica-card {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .65rem;
    border: 1px solid var(--border);
    border-left: 3px solid var(--orange);
    border-radius: var(--rm);
    margin-bottom: .5rem;
    cursor: pointer;
    transition: background var(--transition);
}
.notifica-card:hover { background: var(--orange-light); }

/* Feedback esito form */
.esito-ok {
    color: var(--teal);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}
.esito-ko {
    color: #c0392b;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ── MODALE I MIEI ANNUNCI ── */

.divModale-annunci {
    max-width: 560px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: auto;
}

.miei-annunci-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .75rem;
    gap: 1rem;
}
.miei-annunci-header h2 { margin-bottom: 0; }

.lista-annunci-filtro {
    display: flex;
    align-items: center;
    gap: .85rem;
    flex-wrap: wrap;
    background: var(--surface2);
    border: 0.5px solid var(--border);
    border-radius: var(--rm);
    padding: .5rem .75rem;
    margin-bottom: .75rem;
    font-size: 13px;
}
.lista-annunci-filtro-label { color: var(--muted); font-weight: 600; }
.lista-annunci-filtro label { display: inline-flex; align-items: center; gap: .3rem; cursor: pointer; }
.lista-annunci-filtro-contatore { color: var(--muted); font-size: 12px; margin-left: auto; }

.miei-annunci-tabs {
    display: flex;
    gap: .35rem;
    margin-bottom: .85rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}
.miei-tab {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem .9rem;
    font-size: 13px;
    font-weight: 500;
    border: none;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    margin-bottom: -2px;
    border-radius: 6px 6px 0 0;
    transition: color var(--transition), border-color var(--transition);
}
.miei-tab:hover { color: var(--text); }
.miei-tab.active {
    color: var(--blue);
    border-bottom-color: var(--blue);
    background: var(--blue-light);
}
.miei-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 10px;
    background: var(--border);
    color: var(--muted);
}
.miei-tab.active .miei-tab-badge {
    background: var(--blue);
    color: #fff;
}

@media (max-width: 480px) {
    .miei-tab-label { display: none; }
    .miei-tab {
        flex: 1;
        justify-content: center;
        padding: .45rem .4rem;
        font-size: 15px;
    }
    .miei-tab i { font-size: 1.2rem; }
}

#miei-annunci-corpo {
    overflow-y: auto;
    flex: 1;
}

/* ── STORICO ── */
.storico-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .75rem;
    padding: .75rem 0 1rem;
}
.storico-stat-card {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: .75rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .25rem;
    background: var(--surface);
}
.storico-stat-icon { font-size: 1.3rem; opacity: .7; }
.storico-stat-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.storico-stat-count {
    font-size: 1.8rem;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    border-radius: 8px;
    padding: 2px 10px;
    transition: background var(--transition), color var(--transition);
}
.storico-stat-count:hover { background: var(--blue-light); color: var(--blue); }
.storico-venduto    { border-left: 3px solid var(--green); }
.storico-acquistato { border-left: 3px solid var(--blue); }
.storico-scaduto    { border-left: 3px solid var(--border); }
.storico-possesso   { border-left: 3px solid var(--orange, #f59e0b); }
.storico-venduto    .storico-stat-count { color: var(--green); }
.storico-acquistato .storico-stat-count { color: var(--blue); }
.storico-scaduto    .storico-stat-count { color: var(--muted); }
.storico-possesso   .storico-stat-count { color: var(--orange, #f59e0b); }

.storico-dettaglio {
    margin-bottom: 1rem;
    animation: fadeIn .15s ease;
}
.storico-tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.storico-tbl th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    padding: .3rem .5rem;
    border-bottom: 1px solid var(--border);
}
.storico-tbl td {
    padding: .35rem .5rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.storico-tbl tr:last-child td { border-bottom: none; }

/* ── Segna come posseduto ── */
.segna-possesso-sep {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin: 1rem 0 .75rem;
    color: var(--muted);
    font-size: 12px;
}
.segna-possesso-sep::before,
.segna-possesso-sep::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
.btn-possesso {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem .9rem;
    border-radius: var(--radius);
    border: 1px solid var(--blue);
    background: var(--blue-light);
    color: var(--blue);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    width: 100%;
    justify-content: center;
}
.btn-possesso:hover { background: var(--blue); color: #fff; }
.btn-possesso:disabled { opacity: .55; cursor: not-allowed; }
.btn-togli-possesso {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem .9rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
    width: 100%;
    justify-content: center;
}
.btn-togli-possesso:hover { border-color: var(--red, #ef4444); color: var(--red, #ef4444); background: var(--surface); }
.btn-togli-possesso:disabled { opacity: .55; cursor: not-allowed; }

.miei-annunci-sezione {
    margin-bottom: 1.25rem;
}
.miei-annunci-sezione-titolo {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: .6rem;
    padding-bottom: .4rem;
    border-bottom: 1px solid var(--border);
}

/* ── ANNUNCI - CONTROLLI PROPRIETARIO ── */

.annuncio-card-own {
    border-left: 3px solid var(--blue);
}

.annuncio-azioni {
    display: flex;
    gap: .5rem;
    margin-top: .6rem;
    flex-wrap: wrap;
}

.btn-annuncio-edit,
.btn-annuncio-chiudi {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: 12px;
    font-weight: 600;
    padding: .3rem .7rem;
    border-radius: 6px;
    border: 1px solid;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.btn-annuncio-edit {
    background: var(--surface2);
    border-color: var(--border);
    color: var(--text);
}
.btn-annuncio-edit:hover { background: #e0e0e0; }

.btn-annuncio-chiudi {
    background: var(--teal-light);
    border-color: var(--teal);
    color: var(--teal);
}
.btn-annuncio-chiudi:hover { background: var(--teal); color: #fff; }

.btn-annuncio-elimina {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: 12px;
    padding: .3rem .65rem;
    border-radius: 6px;
    border: 1px solid var(--red, #e53e3e);
    background: transparent;
    color: var(--red, #e53e3e);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.btn-annuncio-elimina:hover { background: var(--red, #e53e3e); color: #fff; }

/* Prima colonna tabella libri: pulsante + icone su riga unica */
#tbody-libri td:first-child {
    white-space: nowrap;
}

/* Icone annuncio nella prima colonna tabella libri */
.mio-annuncio-ico {
    font-size: 14px;
    display: inline-block;
    margin-left: 3px;
    vertical-align: middle;
}
.mio-annuncio-v { color: var(--teal); }
.mio-annuncio-a { color: var(--blue); }
.mio-annuncio-p { color: var(--blue); font-size: 15px; }
.mio-annuncio-bell { color: var(--orange); }

/* ── Confronto libri anno precedente ── */
.confronto-bar {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}
.btn-confronta {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .4rem .9rem;
    font-size: 13px;
    font-weight: 500;
    border-radius: 20px;
    border: 1.5px solid var(--blue);
    background: transparent;
    color: var(--blue);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    align-self: flex-start;
}
.btn-confronta:hover { background: color-mix(in srgb, var(--blue) 12%, transparent); }
.btn-confronta-attivo {
    background: var(--blue) !important;
    color: #fff !important;
}
.btn-confronta-attivo i { color: #fff; }
.confronto-panel {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
    padding: .6rem .85rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.confronto-panel-label {
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
}
.confronto-sel {
    font-size: 13px;
    padding: .25rem .5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
}

/* Riga libro trovata nel confronto */
#tbody-libri tr.riga-posseduta {
    background: #e6f7f4;
}
#tbody-libri tr.riga-posseduta td {
    border-color: #b2e0d8;
}
.confronto-match-icon {
    color: var(--teal);
    font-size: 15px;
    vertical-align: middle;
    margin-left: 2px;
    title: "Probabilmente già in tuo possesso";
}

.annuncio-edit-form {
    margin-top: .75rem;
    padding-top: .75rem;
    border-top: 1px solid var(--border);
}

/* ── AUTENTICAZIONE ── */

.divModale-auth {
    max-width: 500px;
    max-height: 88vh;
    overflow-y: auto;
}

.auth-intro {
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.auth-otp-input {
    font-size: 1.8rem;
    letter-spacing: .4em;
    text-align: center;
    font-family: 'Inter', monospace;
    font-weight: 600;
}

/* Accordion regolamento / privacy */
.auth-accordion {
    border: 1px solid var(--border);
    border-radius: var(--rm);
    margin-bottom: .5rem;
    overflow: hidden;
}
.auth-accordion-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .5rem;
    background: var(--surface2);
    border: none;
    padding: .55rem .75rem;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    color: var(--text);
    transition: background var(--transition);
}
.auth-accordion-btn:hover { background: #eaeaea; }
.auth-chevron {
    margin-left: auto;
    transition: transform var(--transition);
    font-size: 16px;
}
.auth-accordion.open .auth-chevron { transform: rotate(180deg); }
.auth-accordion-body {
    display: none;
    padding: .75rem;
    font-size: 12px;
    line-height: 1.65;
    color: var(--muted);
    max-height: 220px;
    overflow-y: auto;
    border-top: 1px solid var(--border);
}
.auth-accordion-body h3 { font-size: 13px; margin-bottom: .4rem; color: var(--text); }
.auth-accordion-body p  { margin-bottom: .5rem; }
.auth-accordion-body ul { padding-left: 1.2rem; }
.auth-accordion-body li { margin-bottom: .25rem; }
.auth-accordion.open .auth-accordion-body { display: block; }

/* Checkbox accettazione */
.auth-check {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 13px;
    padding: .2rem 0 .5rem;
    cursor: pointer;
}
.auth-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--blue);
}
.auth-check label { cursor: pointer; }

/* Badge utente nell'hero */
.hero-auth {
    display: flex;
    justify-content: center;
    margin-top: .85rem;
}

.hero-auth i {
    font-size: 24px;
}

.btn-accedi {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: 13px;
    font-weight: 600;
    color: var(--blue);
    background: rgba(255,255,255,.85);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: .3rem .9rem;
    cursor: pointer;
    transition: background var(--transition), box-shadow var(--transition);
}
.btn-accedi:hover {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,.1);
}

#utente-badge {
    display: none;
    align-items: center;
    gap: .4rem;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    background: rgba(255,255,255,.85);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: .3rem .9rem;
    margin-top: .85rem;
}

/* Badge utente simulato (modalità admin) */
.admin-simula-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    background: var(--orange);
    border-radius: 20px;
    padding: 2px 8px;
    margin-left: .3rem;
    letter-spacing: .02em;
}

/* ── ADMIN SCUOLE ── */
.req { color: var(--orange); font-weight: 600; }

.admin-scuole-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.admin-scuole-table th {
    background: var(--blue-light);
    color: var(--blue);
    font-weight: 600;
    padding: .4rem .5rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.admin-scuole-table td {
    padding: .4rem .5rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    word-break: break-word;
}
.admin-scuole-table tr:last-child td { border-bottom: none; }
.admin-scuole-table tr:hover td { background: var(--blue-light); }
.admin-scuole-actions { display: flex; gap: .3rem; }
.admin-scuole-actions button {
    background: none;
    border: none;
    cursor: pointer;
    padding: .2rem .3rem;
    border-radius: var(--rm);
    color: var(--muted);
    font-size: 16px;
    transition: color var(--transition), background var(--transition);
}
.admin-scuole-actions button:hover { background: var(--surface2); }
.admin-scuole-actions .btn-edit:hover  { color: var(--blue); }
.admin-scuole-actions .btn-del:hover   { color: #c0392b; }
.admin-scuole-scroll {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 55vh;
}

.auth-edit-btn,
.auth-logout-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    padding: 0 0 0 .3rem;
    font-size: 15px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    transition: color var(--transition);
}
.auth-edit-btn:hover   { color: var(--blue); }
.auth-logout-btn:hover { color: #c0392b; }

/* Identità utente nel form marketplace */
.form-utente-info {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 13px;
    font-weight: 500;
    background: var(--blue-light);
    border: 1px solid #c8d9f0;
    border-radius: var(--rm);
    padding: .5rem .75rem;
    color: var(--blue);
}

/* Badge riepilogativo annunci */
.annunci-badge-wrap {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    padding: .6rem .75rem;
    background: var(--blue-light);
    border: 1px solid #c8d9f0;
    border-radius: var(--rm);
}
.annunci-badge-count {
    font-size: 14px;
    font-weight: 600;
    color: var(--blue);
    flex: 1;
}
.btn-sm {
    padding: .3rem .75rem;
    font-size: 13px;
}

/* Form contatta nel modal */
.annuncio-edit-form textarea {
    width: 100%;
    padding: .5rem;
    border: 1px solid var(--border);
    border-radius: var(--rm);
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    background: var(--bg);
    color: var(--text);
}

/* Checkbox label nel form annuncio */
.check-label {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    font-size: 13px;
    cursor: pointer;
    line-height: 1.4;
}
.check-label input[type="checkbox"] {
    margin-top: 2px;
    flex-shrink: 0;
}

/* ── Gerarchia z-index tra modali annidati ──
   Base .modale = 500. Dal più basso al più alto, ogni modale che può essere aperto
   "sopra" un altro deve avere uno z-index maggiore, altrimenti finisce nascosto dietro.
   Ordine: modali base (500) < lista annunci (550) < conversazioni/notifiche (555) <
   chat (560, apribile da lista annunci/conversazioni/notifiche) < conferma (580, può
   essere aperta da dentro la chat) < avvisi/errori (590, sempre in cima a tutto). */
#divModaleListaAnnunci {
    z-index: 550;
}
#divModaleConversazioni,
#divModaleNotifiche {
    z-index: 555;
}
#divModaleChat {
    z-index: 560;
}
#divModaleConferma {
    z-index: 580;
}
#divModaleAvvisi {
    z-index: 590;
}

/* ── Overlay successo pubblicazione ── */
.pubblica-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 900;
    pointer-events: none;
    animation: overlayFadeIn .25s ease;
}
.pubblica-overlay.pubblica-overlay-hide {
    animation: overlayFadeOut .5s ease forwards;
}
@keyframes overlayFadeIn  { from { opacity:0 } to { opacity:1 } }
@keyframes overlayFadeOut { from { opacity:1 } to { opacity:0 } }

.pubblica-card {
    background: var(--surface);
    border: 2px solid var(--blue);
    border-radius: 1.25rem;
    padding: 2rem 2.5rem;
    text-align: center;
    box-shadow: 0 8px 40px rgba(0,0,0,.18);
    animation: cardPop .35s cubic-bezier(.34,1.56,.64,1);
}
@keyframes cardPop {
    from { transform: scale(.6); opacity:0 }
    to   { transform: scale(1);  opacity:1 }
}
.pubblica-icon {
    font-size: 3rem;
    line-height: 1;
    margin-bottom: .5rem;
    animation: iconBounce .5s cubic-bezier(.34,1.56,.64,1) .1s both;
}
@keyframes iconBounce {
    from { transform: scale(0) rotate(-20deg) }
    to   { transform: scale(1) rotate(0deg) }
}
.pubblica-titolo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--blue);
    margin-bottom: .35rem;
}
.pubblica-sub {
    font-size: .9rem;
    color: var(--muted);
}

/* Coriandoli */
.coriandoli {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}
.coriandolo {
    position: absolute;
    top: -10px;
    display: block;
    animation: corianFall linear forwards;
}
@keyframes corianFall {
    0%   { transform: translateY(0)    rotate(0deg);   opacity:1 }
    80%  { opacity: 1 }
    100% { transform: translateY(105vh) rotate(720deg); opacity:0 }
}

/* Invito al login nella sezione annunci */
.annunci-login-invite {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
    padding: .6rem .75rem;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--rm);
    font-size: 14px;
    color: var(--muted);
}
.annunci-login-invite i { font-size: 1rem; }
.annunci-login-invite span { flex: 1; }

/* Chip "Tutte le classi" in stato bloccato (attivo e non modificabile) */
.chip.chip-locked {
    opacity: 1;
    cursor: default;
}
.chip.chip-locked:hover {
    background: var(--chip-attivo-bg, #1d4ed8);
    border-color: var(--chip-attivo-border, #1d4ed8);
}

/* Pannello login richiesto nella sezione mercato */
.mercato-login-required {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem 1.25rem;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--rm);
    text-align: center;
    margin-bottom: 1rem;
}
.mercato-login-required-icon {
    font-size: 2rem;
    color: var(--muted);
    line-height: 1;
}
.mercato-login-required-titolo {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: .35rem;
}
.mercato-login-required-lista {
    list-style: disc;
    text-align: left;
    padding-left: 1.2rem;
    margin: 0;
    font-size: 13px;
    color: var(--muted);
    line-height: 1.7;
}
.mercato-login-required-btn {
    min-width: 120px;
}

/* ── Verifica ISBN ── */
.btn-isbn-check {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--blue);
    cursor: pointer;
    transition: background var(--transition);
}
.btn-isbn-check:hover { background: var(--blue-light); }

.isbn-check-non-trovato {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    padding: 1.5rem 1rem;
    color: var(--muted);
    text-align: center;
}
.isbn-check-trovato { display: flex; flex-direction: column; gap: .5rem; }
.isbn-check-stats {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.isbn-stat {
    flex: 1;
    min-width: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: .6rem .5rem;
    background: var(--blue-light);
    border-radius: 8px;
    gap: .1rem;
}
.isbn-stat-num {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--blue);
    line-height: 1;
}
.isbn-stat-label { font-size: 11px; color: var(--muted); }
.isbn-scuole-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.isbn-scuole-tbl th {
    text-align: left;
    padding: .3rem .5rem;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
}
.isbn-scuole-tbl td { padding: .35rem .5rem; border-bottom: 1px solid var(--border); }
.isbn-scuole-tbl tr:last-child td { border-bottom: none; }

/* Pannello "hai già un annuncio" nel dettaglio libro */
.annuncio-gia-presente {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    padding: .85rem 1rem;
    background: color-mix(in srgb, var(--green) 10%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--green) 35%, var(--border));
    border-radius: var(--rm);
}
.annuncio-gia-icon {
    font-size: 1.4rem;
    color: var(--green);
    line-height: 1;
    margin-bottom: .1rem;
}
.annuncio-gia-testo { font-size: 14px; }

/* Modalità Verifica – card selezione */
.modalita-card-verifica:hover { border-color: var(--purple, #7c3aed); box-shadow: 0 4px 16px rgba(124,58,237,.1); }
.modalita-card-verifica:hover i { color: var(--purple, #7c3aed); }

/* Pulsanti "Metti in vendita" / "Richiedi acquisto" nel dettaglio modo C */
.btn-verifica-modo {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem .9rem;
    font-size: .88rem;
    font-weight: 500;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition), color var(--transition);
}
.btn-verifica-modo:hover {
    border-color: var(--blue);
    background: rgba(29,78,216,.07);
    color: var(--blue);
}
.btn-verifica-modo.attivo {
    border-color: var(--blue);
    background: var(--blue);
    color: #fff;
}

/* Messaggi ricerca libro in modalità C */
.msg-verifica {
    font-size: .9rem;
    color: var(--muted);
    margin-top: .5rem;
    min-height: 1.4em;
}
.msg-verifica-warn { color: var(--orange); }
