/* Dashboard VIS MARCHE: stessi colori e font di prima (Bosco, Carta, Montserrat, Saira Condensed). */
@font-face { font-family: 'Montserrat'; font-weight: 400; font-display: swap; src: url('/fonts/montserrat-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-weight: 600; font-display: swap; src: url('/fonts/montserrat-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Saira Condensed'; font-weight: 700; font-display: swap; src: url('/fonts/saira-condensed-latin-700-normal.woff2') format('woff2'); }

:root {
  --bosco: #0b3f34; --notte: #072a23; --fronda: #1d6b57; --chiaro: #e7f3ee; --gesso: #ebe5dc; --carta: #f7f4ef;
  --ghisa: #1d2421; --muschio: #5f7a70; --bordo: #e2dbd0; --campo: #ddd5c9; --rosso: #b42318; --rosso-chiaro: #fdecea;
  --giallo: #8a5a00; --giallo-chiaro: #fff4d6; --verde-chiaro: #e3f4ea; --r: 10px; --r-scheda: 14px;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 400 16px/1.55 'Montserrat', system-ui, sans-serif; color: var(--ghisa); background: var(--carta); }
h1, h2, h3 { font-family: 'Saira Condensed', sans-serif; font-weight: 700; line-height: 1.1; margin: 0; }
h1 { font-size: clamp(34px, 2.6vw, 44px); } h2 { font-size: 26px; } h3 { font-size: 20px; }
p { margin: 0 0 .6em; }
a { color: var(--bosco); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #e5b52a; outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Struttura */
.barra { position: sticky; top: 0; z-index: 20; background: var(--notte); color: var(--gesso); display: flex; align-items: center; gap: 16px; padding: 0 20px; height: 60px; }
.barra img { height: 34px; width: auto; }
.barra__titolo { font: 700 20px/1 'Saira Condensed', sans-serif; }
.barra__utente { margin-left: auto; font-size: 13px; color: rgb(235 229 220 / .8); }
.barra__utente a { color: var(--gesso); margin-left: 10px; }
.barra__sito { color: var(--gesso); font-size: 13px; }
.guscio { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: calc(100vh - 60px); }
.menu { padding: 18px 10px; border-right: 1px solid var(--bordo); background: #fbf9f6; }
.menu a { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; font-size: 16px; margin: 2px 0; border-radius: var(--r); text-decoration: none; color: var(--ghisa); font-weight: 600; }
.menu a:hover { background: var(--chiaro); color: var(--bosco); }
.menu a[aria-current='page'] { background: var(--bosco); color: #fff; }
.menu hr { border: 0; border-top: 1px solid var(--bordo); margin: 10px 6px; }
.pallino { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--rosso); color: #fff; font-size: 12px; display: inline-grid; place-items: center; }
.contenuto { padding: 32px clamp(20px, 3vw, 48px) 80px; width: 100%; max-width: 1600px; }
.testa { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 6px; flex-wrap: wrap; }
.sotto { color: var(--muschio); margin-bottom: 24px; max-width: 70ch; }
.briciole { font-size: 13px; margin-bottom: 8px; }
.briciole a { text-decoration: none; }

/* Pulsanti */
.btn { display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; padding: 10px 18px; font-weight: 600; border: 1.5px solid transparent; cursor: pointer; text-decoration: none; background: #fff; border-color: var(--campo); color: var(--ghisa); }
.btn:hover { border-color: var(--bosco); }
.btn--primario { background: var(--bosco); border-color: var(--bosco); color: #fff; }
.btn--primario:hover { background: var(--fronda); border-color: var(--fronda); }
.btn--pericolo { color: var(--rosso); }
.btn--pericolo:hover { border-color: var(--rosso); }
.btn--grande { padding: 16px 26px; font-size: 17px; }
.btn--piccolo { padding: 6px 12px; font-size: 13px; }
.btn--link { background: none; border: 0; padding: 4px; color: var(--bosco); text-decoration: underline; }
.btn[disabled] { opacity: .55; cursor: progress; }
.azioni { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* Schede e liste */
.scheda { background: #fff; border: 1px solid var(--bordo); border-radius: var(--r-scheda); padding: 24px 26px; box-shadow: 0 8px 24px -18px rgb(29 36 33 / .3); }
.griglia { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; }
.scheda h2 { margin-bottom: 12px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.scheda h2 small { font: 400 13px 'Montserrat', sans-serif; color: var(--muschio); }
.lista { list-style: none; margin: 0; padding: 0; }
.lista > li { display: flex; align-items: center; gap: 14px; padding: 14px 4px; border-top: 1px solid var(--bordo); }
.lista > li:first-child { border-top: 0; }
.lista__testo { flex: 1; min-width: 0; }
.lista__titolo { font-weight: 600; display: block; text-decoration: none; color: var(--ghisa); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.lista__titolo:hover { color: var(--bosco); text-decoration: underline; }
.lista__meta { font-size: 14px; color: var(--muschio); }
.vuoto { text-align: center; padding: 28px 16px; color: var(--muschio); }
.vuoto p { margin-bottom: 12px; }
.grandi-azioni { display: flex; flex-wrap: wrap; gap: 12px; margin: 18px 0 28px; }

/* Stati */
.stato { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.stato--bozza { background: #eee9e1; color: #5b544a; }
.stato--revisione { background: var(--giallo-chiaro); color: var(--giallo); }
.stato--pubblicato { background: var(--verde-chiaro); color: #1d6b3a; }
.stato--nascosto { background: #eee; color: #555; }
.nota { background: var(--giallo-chiaro); border-left: 4px solid #e5b52a; padding: 10px 14px; border-radius: 6px; margin: 0 0 16px; }

/* Moduli */
.modulo { display: grid; gap: 18px; }
.riga { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.campo { display: grid; gap: 6px; }
.campo > span:first-child { font-weight: 600; font-size: 15px; }
.campo small { color: var(--muschio); font-size: 13px; }
.campo input, .campo select, .campo textarea { width: 100%; padding: 13px 15px; font-size: 16px; border: 1.5px solid var(--campo); border-radius: var(--r); background: #fff; }
.campo textarea { min-height: 110px; resize: vertical; }
.campo input:focus, .campo select:focus, .campo textarea:focus { outline: 2px solid var(--fronda); outline-offset: 0; border-color: var(--fronda); }
.campo [aria-invalid='true'] { border-color: var(--rosso); background: var(--rosso-chiaro); }
.campo .errore { color: var(--rosso); font-size: 13px; font-weight: 600; }
.spunta { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.spunta input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--bosco); }
.contatore { text-align: right; }
.piede { position: sticky; bottom: 0; background: rgb(247 244 239 / .96); border-top: 1px solid var(--bordo); margin: 24px calc(-1 * clamp(20px, 3vw, 48px)) -80px; padding: 16px clamp(20px, 3vw, 48px); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; backdrop-filter: blur(6px); }
.piede__stato { margin-right: auto; font-size: 13px; color: var(--muschio); }

/* Editor di testo */
.editor { border: 1.5px solid var(--campo); border-radius: var(--r); background: #fff; overflow: hidden; }
.editor:focus-within { border-color: var(--fronda); }
.editor__strumenti { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border-bottom: 1px solid var(--bordo); background: #fbf9f6; }
.editor__strumenti button { border: 0; background: none; padding: 6px 10px; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 13px; }
.editor__strumenti button:hover { background: var(--chiaro); }
.editor textarea { border: 0 !important; border-radius: 0 !important; min-height: 320px; font-size: 16px; line-height: 1.7; outline: none !important; }

/* Foto */
.foto-campo { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.foto-campo img { width: 160px; height: 100px; object-fit: cover; border-radius: 8px; border: 1px solid var(--bordo); }
.foto-campo label.btn input { display: none; }

/* Tabella risultati */
.scheda--tabella { padding: 0; overflow: hidden; }
.scheda--tabella .filtri { padding: 18px 22px; margin: 0; border-bottom: 1px solid var(--bordo); background: #fbf9f6; }
.tabella-scorri { overflow-x: auto; }
.tabella { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 16px; }
.tabella th { position: sticky; top: 0; text-align: left; font-size: 13px; letter-spacing: .02em; color: var(--muschio); font-weight: 600; padding: 14px 18px; background: #fff; border-bottom: 2px solid var(--bordo); white-space: nowrap; }
.tabella td { padding: 16px 18px; border-bottom: 1px solid var(--bordo); vertical-align: middle; }
.tabella tbody tr:last-child td { border-bottom: 0; }
.tabella tbody tr:nth-child(even) td { background: #fcfbf8; }
.tabella tbody tr.riga-cliccabile:hover td { background: var(--chiaro); }
.tabella td:first-child, .tabella th:first-child { padding-left: 24px; }
.tabella td:last-child, .tabella th:last-child { padding-right: 24px; text-align: right; }
.tabella .atleta { font-weight: 600; font-size: 17px; color: var(--ghisa); text-decoration: none; }
.tabella .atleta:hover { color: var(--bosco); text-decoration: underline; }
.tabella .kg { font: 700 28px/1 'Saira Condensed', sans-serif; color: var(--bosco); white-space: nowrap; }
.tabella .kg small { font-size: 15px; color: var(--muschio); margin-left: 2px; }
.tabella .medaglia { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: #eee9e1; }
.tabella .medaglia--oro { background: #fbefc4; color: #7a5a00; } .tabella .medaglia--argento { background: #eceff1; color: #455a64; } .tabella .medaglia--bronzo { background: #f6e1d3; color: #8a4b1f; }
.tabella .tipo { display: block; font-size: 13px; color: var(--muschio); margin-top: 2px; }
.filtri { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filtri input, .filtri select { padding: 11px 16px; border: 1.5px solid var(--campo); border-radius: 999px; background: #fff; font-size: 15px; }
.filtri input[type=search] { min-width: min(100%, 340px); }
.filtri__conta { margin-left: auto; color: var(--muschio); font-size: 14px; }

/* Anteprima */
.anteprima { background: #072a23; color: #ebe5dc; border-radius: var(--r-scheda); padding: 40px; }
.anteprima h1 { font-size: 46px; margin-bottom: 8px; }
.anteprima .meta { color: rgb(235 229 220 / .75); margin-bottom: 24px; }
.anteprima .corpo { max-width: 46rem; font-size: 17px; line-height: 1.75; }
.anteprima .corpo h2 { font-size: 30px; margin: 1.2em 0 .4em; } .anteprima .corpo h3 { font-size: 22px; margin: 1em 0 .4em; }
.anteprima .corpo a { color: #9fe0c9; } .anteprima .corpo blockquote { border-left: 3px solid #3fae8c; margin: 1em 0; padding-left: 16px; }
.anteprima img { max-width: 100%; border-radius: 12px; margin: 0 0 20px; }

/* Avvisi */
.avvisi { position: fixed; z-index: 60; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; width: min(92vw, 560px); }
.avviso { display: flex; gap: 12px; align-items: center; background: var(--ghisa); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: 0 20px 40px -20px rgb(0 0 0 / .6); animation: entra .2s ease-out; }
.avviso--ok { background: var(--bosco); } .avviso--errore { background: var(--rosso); }
.avviso span { flex: 1; } .avviso button { background: none; border: 1px solid rgb(255 255 255 / .5); color: #fff; border-radius: 999px; padding: 4px 12px; cursor: pointer; font-weight: 600; }
@keyframes entra { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
dialog { border: 0; border-radius: var(--r-scheda); padding: 24px; max-width: 460px; box-shadow: 0 30px 60px -20px rgb(0 0 0 / .5); }
dialog::backdrop { background: rgb(7 42 35 / .45); }
dialog h2 { margin-bottom: 10px; }
dialog textarea { width: 100%; min-height: 100px; padding: 10px; border: 1.5px solid var(--campo); border-radius: var(--r); margin: 8px 0 14px; }
.caricamento { padding: 40px; color: var(--muschio); }
.scheletro { height: 14px; background: linear-gradient(90deg, #eee9e1, #f6f2ec, #eee9e1); background-size: 200% 100%; animation: luce 1.2s infinite; border-radius: 6px; margin: 10px 0; }
@keyframes luce { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.grafico { display: flex; align-items: flex-end; gap: 6px; height: 70px; margin: 8px 0; }
.grafico span { flex: 1; background: var(--fronda); border-radius: 4px 4px 0 0; min-height: 3px; }
.grande-numero { font: 700 40px/1 'Saira Condensed', sans-serif; }

@media (max-width: 760px) {
  .guscio { grid-template-columns: 1fr; }
  .menu { display: flex; overflow-x: auto; gap: 4px; padding: 8px; border-right: 0; border-bottom: 1px solid var(--bordo); }
  .menu hr { display: none; } .menu a { white-space: nowrap; }
  .contenuto { padding: 20px 16px 80px; }
  .piede { margin: 24px -16px -80px; padding: 12px 16px; }
  .barra__utente span { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
[hidden] { display: none !important; }
.riga-cliccabile { cursor: pointer; }

/* Messaggi: elenco unico e lettura a tutto schermo */
.messaggi { list-style: none; margin: 0; padding: 0; }
.messaggio + .messaggio { border-top: 1px solid var(--bordo); }
.messaggio__apri { width: 100%; display: grid; grid-template-columns: 12px minmax(180px, 260px) minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 18px 24px; background: none; border: 0; text-align: left; cursor: pointer; }
.messaggio__apri:hover { background: var(--chiaro); }
.messaggio__punto { width: 10px; height: 10px; border-radius: 50%; }
.messaggio--nuovo .messaggio__punto { background: var(--rosso); }
.messaggio__chi { display: grid; min-width: 0; } .messaggio__chi strong, .messaggio__chi span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.messaggio:not(.messaggio--nuovo) .messaggio__chi strong { font-weight: 400; }
.messaggio__anteprima { color: var(--muschio); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.messaggio--nuovo .messaggio__anteprima { color: var(--ghisa); }
.messaggio__quando { font-size: 14px; color: var(--muschio); white-space: nowrap; }
dialog.dialog-grande { width: min(100vw - 32px, 960px); max-width: none; height: min(100vh - 32px, 860px); max-height: none; padding: 0; display: grid; grid-template-rows: auto 1fr auto; }
dialog.dialog-grande:not([open]) { display: none; }
.dialog-grande__testa { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 28px 32px 18px; border-bottom: 1px solid var(--bordo); }
.dialog-grande__testa h2 { font-size: 32px; margin-bottom: 4px; }
.dialog-grande__corpo { padding: 28px 32px; overflow-y: auto; font-size: 18px; line-height: 1.7; }
.dialog-grande__corpo p { max-width: 70ch; margin: 0 0 .4em; }
.dialog-grande__piede { display: flex; flex-wrap: wrap; gap: 12px; padding: 18px 32px; border-top: 1px solid var(--bordo); background: #fbf9f6; }
@media (max-width: 760px) {
  .messaggio__apri { grid-template-columns: 12px minmax(0, 1fr) auto; } .messaggio__anteprima { grid-column: 2 / -1; white-space: normal; }
  dialog.dialog-grande { width: 100vw; height: 100vh; border-radius: 0; }
}
