/*
  Replica dell'interfaccia di TED Monitor (site.css + Bootstrap 5.3), limitata a .tm.
  Stessi token, stesso stile "operativo compatto": un solo accento, grigi neutri, righe dense.
  .tm è un contenitore: sotto i 700 px di larghezza l'app passa alla versione mobile,
  sia dentro il MacBook sia dentro l'iPhone, indipendentemente dalla finestra.
*/
.tm {
  --tm-accento: #0f766e;
  --tm-accento-scuro: #115e59;
  --tm-accento-tenue: #e6f2f1;
  --tm-accento-bordo: #b9dcd8;
  --tm-testo: #18181b;
  --tm-testo-2: #52525b;
  --tm-bordo: #e4e4e7;
  --tm-bordo-input: #d4d4d8;
  --tm-sfondo: #fafafa;
  --tm-sfondo-intestazione: #f4f4f5;
  --tm-errore: #b91c1c;
  --tm-ambra: #f59e0b;
  --tm-font: "Source Sans 3", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --tm-mono: "JetBrains Mono", "Cascadia Mono", Consolas, ui-monospace, monospace;

  container: tm / inline-size;
  position: relative;
  display: flex; flex-direction: column;
  height: 100%; min-height: 0;
  overflow: hidden;
  font-family: var(--tm-font); font-size: 15px; line-height: 1.5; color: var(--tm-testo);
  text-align: left; letter-spacing: normal;
  background: var(--tm-sfondo) url("img/illustrazioni/app-sfondo.jpg") center / cover no-repeat;
  -webkit-font-smoothing: antialiased;
}
.tm *, .tm *::before, .tm *::after { box-sizing: border-box; }
.tm h1, .tm h2, .tm h3, .tm p, .tm ul, .tm ol { margin: 0; letter-spacing: normal; }
.tm ul, .tm ol { padding: 0; list-style: none; }
.tm a { color: var(--tm-accento); text-decoration: none; }
.tm a:hover { color: var(--tm-accento-scuro); text-decoration: underline; }
.tm button, .tm input, .tm select, .tm textarea { font: inherit; color: inherit; }
.tm button { cursor: pointer; }
.tm img { display: block; max-width: 100%; height: auto; }
.tm :focus-visible { outline: 0; box-shadow: 0 0 0 .25rem rgba(15, 118, 110, .25); }

.tm h1 { font-size: 1.4rem; font-weight: 600; line-height: 1.2; text-wrap: balance; }
.tm h2 { font-size: 1.05rem; font-weight: 600; line-height: 1.25; margin: 1.5rem 0 .5rem; }
.tm h3 { font-size: .95rem; font-weight: 600; }
.tm .mono { font-family: var(--tm-mono); font-size: .82rem; }
.tm .small { font-size: .875em; }
.tm .text-muted { color: var(--tm-testo-2); }
.tm .icona { width: 1.1em; height: 1.1em; stroke-width: 1.75; vertical-align: -0.2em; flex-shrink: 0; }

/* Scorrimento della pagina dell'app */
.tm-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; }
.tm-container { width: 100%; max-width: 1320px; margin: 0 auto; padding: 0 1.25rem; }
.tm-main { flex: 1; padding-bottom: 2.5rem; }

/* INIZIO BARRA IN ALTO */
.tm-barra { flex: none; position: relative; z-index: 20; background: #fff; border-bottom: 1px solid var(--tm-bordo); }
.tm-barra .tm-container { display: flex; align-items: center; gap: 1rem; }
.tm-brand { display: inline-flex; align-items: center; gap: .5rem; margin-right: .5rem; font-weight: 600; font-size: 1rem; color: var(--tm-testo) !important; white-space: nowrap; text-decoration: none !important; }
.tm-brand img { width: 28px; height: 28px; }
.tm-nav { display: flex; align-items: stretch; margin-right: auto; }
.tm-nav > * {
  display: inline-flex; align-items: center; gap: .35rem; padding: .9rem .75rem; border: 0; border-bottom: 2px solid transparent;
  background: none; color: var(--tm-testo-2); white-space: nowrap; text-decoration: none;
}
.tm-nav > :hover { color: var(--tm-testo); text-decoration: none; }
.tm-nav .is-active { color: var(--tm-accento); border-bottom-color: var(--tm-accento); }
.tm-destra { display: flex; align-items: center; gap: 1rem; padding: .5rem 0; white-space: nowrap; }
.tm-utente { color: var(--tm-testo-2); font-size: .9rem; }
.tm-link { color: var(--tm-testo-2) !important; font-size: .875em; background: none; border: 0; padding: 0; display: inline-flex; align-items: center; gap: .3rem; }
.tm-burger { display: none; margin-left: auto; width: 40px; height: 34px; border: 1px solid var(--tm-bordo-input); border-radius: 4px; background: #fff; place-items: center; }
.tm-burger i { display: block; width: 18px; height: 2px; background: var(--tm-testo-2); border-radius: 2px; box-shadow: 0 -5px 0 var(--tm-testo-2), 0 5px 0 var(--tm-testo-2); }
/* FINE BARRA IN ALTO */

.tm-piede { flex: none; margin-top: auto; background: #fff; border-top: 1px solid var(--tm-bordo); padding: .7rem 0; text-align: center; font-size: .82rem; color: var(--tm-testo-2); }
.tm-piede b { color: var(--tm-accento); font-weight: 600; }

.intestazione-pagina { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin: 1.75rem 0 1rem; }
.intestazione-pagina .azioni { margin-left: auto; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.illustrazione-titolo { width: 48px !important; height: 48px; flex-shrink: 0; margin: -.25rem -.15rem -.25rem 0; }
.intestazione-pagina .sottotitolo { font-size: .875em; color: var(--tm-testo-2); margin-top: .15rem; }

/* INIZIO PULSANTI: un solo pulsante pieno per pagina, gli altri neutri */
.tm .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .3rem; padding: .3rem .8rem;
  font-size: .9rem; line-height: 1.5; border: 1px solid transparent; border-radius: 4px; white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .1s ease;
  text-decoration: none;
}
.tm .btn-sm { font-size: .82rem; padding: .2rem .6rem; border-radius: 3px; }
.tm .btn-sm .icona { width: 1em; height: 1em; }
.tm .btn-primary { background: var(--tm-accento); border-color: var(--tm-accento); color: #fff; }
.tm .btn-primary:hover { background: var(--tm-accento-scuro); border-color: var(--tm-accento-scuro); color: #fff; text-decoration: none; }
.tm .btn-neutro { background: #fff; border-color: var(--tm-bordo-input); color: var(--tm-testo); }
.tm .btn-neutro:hover { background: var(--tm-sfondo-intestazione); border-color: #a1a1aa; text-decoration: none; }
.tm .btn-neutro:active { background: #e4e4e7; }
.tm .btn-pericolo { background: #fff; border-color: #e7c4c4; color: var(--tm-errore); }
.tm .btn-pericolo:hover { background: var(--tm-errore); border-color: var(--tm-errore); color: #fff; }
.tm .btn-link { border: 0; background: none; padding: 0; color: var(--tm-accento); }
.tm .btn:disabled { opacity: .65; cursor: default; }
.tm .btn.is-pressed { transform: scale(.95); filter: brightness(.95); }
/* FINE PULSANTI */

.pannello { background: #fff; border: 1px solid var(--tm-bordo); border-radius: 4px; padding: 1rem 1.15rem; }
.pannello + .pannello { margin-top: 1rem; }
.pannello > h2:first-child { margin-top: 0; }
.stato-vuoto { text-align: center; padding: 2rem 1.5rem 2.25rem; }
.stato-vuoto img { width: 120px; height: 120px; margin: 0 auto .9rem; }
.stato-vuoto p { max-width: 34rem; margin: .35rem auto 0; color: var(--tm-testo-2); }
.stato-vuoto .btn { margin-top: 1rem; }

/* INIZIO TABELLE DENSE */
.tabella { background: #fff; border: 1px solid var(--tm-bordo); border-radius: 4px; overflow-x: auto; }
.tabella table { width: 100%; margin: 0; border-collapse: collapse; font-size: .93rem; }
.tabella th { background: var(--tm-sfondo-intestazione); color: var(--tm-testo-2); font-weight: 600; font-size: .8rem; padding: .4rem .7rem; text-align: left; white-space: nowrap; }
.tabella td { padding: .5rem .7rem; border-top: 1px solid var(--tm-bordo); vertical-align: top; }
.tabella tr.spenta td { color: var(--tm-testo-2); }
.tabella tr.riga-nuova td { background: var(--tm-accento-tenue); }
.tabella tr.tolta { opacity: .45; }
.tabella .nome { font-weight: 600; }
.tabella .azioni { text-align: right; white-space: nowrap; }
.tabella .text-end { text-align: right; white-space: nowrap; }
.tabella td.azioni .btn + .btn { margin-left: .25rem; }
.tabella tr.is-flash td { animation: tm-flash 1.6s ease; }
@keyframes tm-flash { 0%, 40% { background: #c9e7e3; } }
/* FINE TABELLE DENSE */

.stato-ok { color: var(--tm-accento); }
.stato-neutro { color: var(--tm-testo-2); }
.stato-errore { color: var(--tm-errore); }
.stato-ok, .stato-neutro, .stato-errore { display: inline-flex; align-items: center; gap: .3rem; font-size: .9rem; }
.etichetta-nuovo { display: inline-block; background: var(--tm-accento); color: #fff; font-size: .72rem; font-weight: 600; border-radius: 3px; padding: .05rem .4rem; }
.riepilogo-controllo { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; background: #fff; border: 1px solid var(--tm-bordo); border-radius: 4px; padding: .6rem .9rem; }
.riepilogo-controllo .numero { font-size: 1.5rem; font-weight: 600; line-height: 1; color: var(--tm-testo-2); min-width: 1.5rem; text-align: center; }
.riepilogo-controllo.con-nuove { background: var(--tm-accento-tenue); border-color: var(--tm-accento-bordo); }
.riepilogo-controllo.con-nuove .numero { color: var(--tm-accento); }
.query-ted { font-family: var(--tm-mono); font-size: .8rem; background: var(--tm-sfondo-intestazione); border-radius: 4px; padding: .5rem .7rem; overflow-wrap: anywhere; color: var(--tm-testo); }
.conteggio { display: inline-block; margin-left: .4rem; padding: 0 .4rem; border-radius: 3px; background: var(--tm-accento-tenue); color: var(--tm-accento); font-size: .78rem; font-weight: 600; }
.riga-conteggio { margin: 0 0 .6rem; font-size: .93rem; color: var(--tm-testo-2); }
.riga-conteggio b { color: var(--tm-testo); }

/* Gara: numero, stella, titolo, sintesi AI, giudizio del team */
.gara-numero { display: inline-flex; align-items: center; gap: .3rem; font-family: var(--tm-mono); font-size: .8rem; }
.gara-numero .icona { width: .9em; height: .9em; }
.btn-stella { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; margin-left: .15rem; padding: 0; border: 0; background: none; color: #a1a1aa; vertical-align: middle; border-radius: 3px; }
.btn-stella:hover { color: #d97706; }
.btn-stella[aria-pressed="true"] { color: #d97706; }
.btn-stella[aria-pressed="true"] svg { fill: var(--tm-ambra); }
.btn-stella .icona { width: 1rem; height: 1rem; vertical-align: 0; }
.btn-stella.is-pop svg { animation: tm-pop .45s ease; }
@keyframes tm-pop { 40% { transform: scale(1.45) rotate(-10deg); } }
.gara-titolo { margin-top: .1rem; font-weight: 500; line-height: 1.35; }
.sintesi-ai { margin-top: .35rem; font-size: .86rem; color: var(--tm-testo-2); line-height: 1.45; }
.sintesi-ai ul { margin-top: .25rem; padding-left: 1rem; list-style: disc; }
.punteggio { display: inline-flex; align-items: baseline; gap: .3rem; margin-right: .35rem; padding: 0 .4rem; border: 1px solid var(--tm-bordo); border-radius: 3px; font-size: .78rem; color: var(--tm-testo-2); background: #fff; white-space: nowrap; }
.punteggio b { font-family: var(--tm-mono); color: var(--tm-testo); }
.punteggio.alto { background: var(--tm-accento-tenue); border-color: var(--tm-accento-bordo); color: var(--tm-accento-scuro); }
.punteggio.alto b { color: var(--tm-accento); }
.giudizio { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .45rem; }
.giudizio .btn { padding: .05rem .45rem; font-size: .76rem; color: var(--tm-testo-2); }
.giudizio .btn[aria-pressed="true"] { border-color: var(--tm-accento); color: var(--tm-accento); background: var(--tm-accento-tenue); }
.azioni-gara { display: inline-flex; gap: .25rem; }

/* Moduli */
.tm .form-label { display: block; margin-bottom: .3rem; font-weight: 600; font-size: .88rem; }
.tm .form-text { margin-top: .25rem; font-size: .82rem; color: var(--tm-testo-2); }
.tm .form-control, .tm .form-select {
  display: block; width: 100%; padding: .375rem .75rem; font-size: .95rem; line-height: 1.5; color: var(--tm-testo);
  background: #fff; border: 1px solid var(--tm-bordo-input); border-radius: 4px; transition: border-color .15s ease, box-shadow .15s ease;
}
.tm .form-control-sm { padding: .2rem .55rem; font-size: .85rem; }
.tm .form-control:focus, .tm .form-select:focus { outline: 0; border-color: #87bbb6; box-shadow: 0 0 0 .25rem rgba(15, 118, 110, .25); }
.tm .form-control.mono { font-family: var(--tm-mono); font-size: .85rem; }
.tm .form-control.is-invalid { border-color: var(--tm-errore); }
.tm .invalid-feedback { margin-top: .25rem; font-size: .82rem; color: var(--tm-errore); }
.tm .invalid-feedback:empty { display: none; }
.tm textarea.form-control { resize: vertical; }
.tm .form-check { display: flex; align-items: center; gap: .45rem; min-height: 1.5rem; font-size: .93rem; }
.tm .form-check input { width: 1em; height: 1em; margin: 0; accent-color: var(--tm-accento); }
.tm .form-switch input {
  appearance: none; -webkit-appearance: none; width: 2em; height: 1.1em; border-radius: 2em; border: 1px solid var(--tm-bordo-input);
  background: #fff radial-gradient(circle at 30% 50%, #a1a1aa .32em, transparent .34em); transition: background .15s ease; cursor: pointer;
}
.tm .form-switch input:checked { background: var(--tm-accento) radial-gradient(circle at 70% 50%, #fff .32em, transparent .34em); border-color: var(--tm-accento); }
.tm .griglia-campi { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1rem; }
.tm .griglia-campi .intero { grid-column: 1 / -1; }
.etichette { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .4rem; }
.etichetta-valore { display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .3rem .1rem .5rem; border: 1px solid var(--tm-bordo-input); border-radius: 3px; background: #fff; font-size: .82rem; }
.etichetta-valore .mono { font-size: .76rem; color: var(--tm-testo-2); }
.etichetta-valore button { border: 0; background: none; padding: 0 .15rem; color: var(--tm-testo-2); line-height: 1; }
.etichetta-valore button:hover { color: var(--tm-errore); }
.scelte { display: flex; flex-wrap: wrap; gap: .35rem; }
.scelta { padding: .15rem .55rem; border: 1px solid var(--tm-bordo-input); border-radius: 3px; background: #fff; font-size: .82rem; color: var(--tm-testo-2); }
.scelta .mono { font-size: .74rem; margin-left: .25rem; }
.scelta[aria-pressed="true"] { border-color: var(--tm-accento); background: var(--tm-accento-tenue); color: var(--tm-accento-scuro); }
.alert { padding: .65rem .9rem; border: 1px solid; border-radius: 4px; font-size: .9rem; }
.alert-success { background: var(--tm-accento-tenue); border-color: var(--tm-accento-bordo); color: var(--tm-accento-scuro); }
.alert-warning { background: #fdf6e7; border-color: #f1dfb4; color: #6b4a0b; }
.alert-danger { background: #fdf0f0; border-color: #f0caca; color: #8f1a1a; }

.dettaglio-griglia { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 1.5rem; align-items: start; }
.anteprima-fissa { position: sticky; top: 1rem; }
.campo-ricerca { background: var(--tm-sfondo-intestazione) !important; }
.assistente-ai .illustrazione-riquadro { float: right; width: 72px; height: 72px; margin: -.25rem 0 .25rem 1rem; }
.avviso { padding: .55rem 0; border-top: 1px solid var(--tm-bordo); font-size: .9rem; }
.avviso:first-of-type { border-top: 0; }
.avviso .meta { font-size: .8rem; color: var(--tm-testo-2); }
.pulsanti-modulo { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.cambia-modo { display: flex; justify-content: space-between; margin: 1rem 0 .5rem; font-size: .9rem; }

/* Costruttore a blocchi (modalità esperto) */
.costruttore { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 1rem; margin-top: .5rem; }
.tavolozza { font-size: .82rem; }
.tavolozza h3 { font-size: .85rem; margin-bottom: .25rem; }
.tavolozza .gruppo-campi { margin-top: .6rem; color: var(--tm-testo-2); font-size: .74rem; font-weight: 600; }
.elemento-tavolozza { display: inline-block; margin: .2rem .2rem 0 0; padding: .1rem .5rem; border: 1px solid var(--tm-bordo-input); border-radius: 999px; background: #fff; font-size: .78rem; color: var(--tm-testo); cursor: pointer; }
.elemento-tavolozza:hover { border-color: var(--tm-accento); color: var(--tm-accento); }
.elemento-tavolozza.struttura { border-style: dashed; }
.blocco-gruppo { padding: .55rem; border: 1px dashed #a1a1aa; border-radius: 4px; background: #fafafa; display: grid; gap: .4rem; }
.blocco-gruppo.radice { border-style: solid; background: #fff; }
.blocco-gruppo.or { border-color: #c2410c; background: #fffaf5; }
.blocco-testa { display: flex; align-items: center; gap: .4rem; font-size: .82rem; }
.blocco-testa select { width: auto; padding: .05rem .35rem; font-size: .8rem; border: 1px solid var(--tm-bordo-input); border-radius: 3px; background: #fff; }
.blocco-non { margin-left: auto; padding: 0 .4rem; border: 1px solid var(--tm-bordo-input); border-radius: 3px; background: #fff; font-size: .7rem; font-weight: 700; letter-spacing: .04em; color: var(--tm-testo-2); }
.blocco-non[aria-pressed="true"] { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.blocco-condizione { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; padding: .35rem .5rem; border: 1px solid var(--tm-bordo); border-radius: 4px; background: #fff; font-size: .84rem; }
.blocco-condizione .maniglia, .blocco-testa .maniglia { color: #a1a1aa; display: inline-flex; }
.blocco-condizione .operatore { color: var(--tm-testo-2); }
.blocco-condizione .rimuovi { margin-left: auto; border: 0; background: none; color: var(--tm-testo-2); padding: 0 .2rem; }
.blocco-vuoto { padding: .5rem; border: 1px dashed var(--tm-bordo-input); border-radius: 4px; text-align: center; font-size: .8rem; color: var(--tm-testo-2); }
.blocco-condizione.is-new { animation: tm-flash 1.2s ease; }

/* Notifiche inviate */
.notifica-gruppo { margin-bottom: 1rem; }
.notifica-riepilogo { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .85rem 1rem; background: #fff; border: 1px solid var(--tm-bordo); border-radius: 6px; cursor: pointer; list-style: none; }
.notifica-riepilogo::-webkit-details-marker { display: none; }
.notifica-titolo { flex: 1; min-width: 12rem; }
.notifica-titolo span { display: block; font-size: .85rem; color: var(--tm-testo-2); }
.notifica-esiti { display: flex; gap: .8rem; }
.notifica-gruppo[open] .notifica-riepilogo { border-radius: 6px 6px 0 0; }
.notifica-gruppo .tabella { border-top: 0; border-radius: 0 0 4px 4px; }

/* Radar animato del logo: per le attese (come RadarAi.svg dell'app) */
.radar-ai { width: 1.25em; height: 1.25em; vertical-align: -0.28em; flex-shrink: 0; }
.radar-ai .radar-fascio { transform-box: view-box; transform-origin: 32px 32px; animation: radar-giro 1.6s linear infinite; }
.radar-ai .radar-punto { transform-box: fill-box; transform-origin: center; animation: radar-punto 1.6s ease-in-out infinite; }
@keyframes radar-giro { to { transform: rotate(360deg); } }
@keyframes radar-punto { 0%, 100% { opacity: .35; transform: scale(.75); } 45% { opacity: 1; transform: scale(1.15); } }

/* Chat AI */
.chat-pagina { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 1.25rem; height: 100%; min-height: 0; }
.chat-elenco { border-right: 1px solid var(--tm-bordo); padding: 1.25rem 1rem 1rem 0; font-size: .9rem; }
.chat-elenco summary { font-weight: 600; margin-bottom: .6rem; list-style: none; }
.chat-elenco summary::-webkit-details-marker { display: none; }
.chat-elenco li { padding: .35rem .5rem; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--tm-testo-2); }
.chat-elenco li.attiva { background: var(--tm-sfondo-intestazione); color: var(--tm-testo); font-weight: 600; }
.chat-elenco .btn { width: 100%; margin-bottom: .6rem; }
.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; width: 100%; max-width: 860px; margin: 0 auto; padding-top: 1rem; }
.chat-messaggi { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 1rem; padding: .5rem .25rem 1rem; }
.chat.vuota .chat-messaggi { justify-content: center; }
.chat-benvenuto { text-align: center; }
.chat-benvenuto img { width: 72px; height: 72px; margin: 0 auto .6rem; }
.chat-benvenuto h1 { font-size: 1.6rem; font-weight: 500; }
.chat-benvenuto p { margin-top: .3rem; font-size: .9rem; color: var(--tm-testo-2); }
.msg.utente { display: flex; justify-content: flex-end; }
.fumetto { max-width: 80%; padding: .5rem .9rem; border-radius: 1rem; background: var(--tm-sfondo-intestazione); }
.msg.ai .testo p + p, .msg.ai .testo ul + p, .msg.ai .testo p + ul { margin-top: .5rem; }
.msg.ai .testo ul { margin-top: .4rem; padding-left: 1.1rem; list-style: disc; }
.msg.ai .testo li + li { margin-top: .2rem; }
.schede { display: grid; gap: .6rem; margin-top: .7rem; }
.scheda-chat { background: #fff; border: 1px solid var(--tm-bordo); border-radius: 4px; padding: .7rem .9rem; font-size: .9rem; }
.scheda-chat .query-ted { margin: .4rem 0 .2rem; }
.scheda-chat .gare li { padding: .45rem 0; border-top: 1px solid var(--tm-bordo); }
.scheda-chat .gare li:first-child { border-top: 0; }
.scheda-chat .gare .meta { font-size: .8rem; color: var(--tm-testo-2); }
.scheda-chat.proposta { background: var(--tm-accento-tenue); border-color: var(--tm-accento-bordo); }
.scheda-chat.proposta p { margin-top: .3rem; color: var(--tm-testo-2); }
.scheda-chat .pulsanti { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.stato-lavoro { display: inline-flex; align-items: center; gap: .5rem; color: var(--tm-testo-2); font-size: .92rem; }
.stato-lavoro .radar-ai { width: 1.4rem; height: 1.4rem; }
.chat-casella { display: flex; align-items: flex-end; gap: .4rem; padding: .4rem .4rem .4rem 1rem; border: 1px solid var(--tm-bordo-input); border-radius: 1.4rem; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
.chat-casella textarea { flex: 1; min-width: 0; border: 0; outline: 0; resize: none; padding: .35rem 0; background: none; max-height: 7.5rem; line-height: 1.45; }
.chat-casella .scelta-ragionamento { flex: none; border: 0; background: none; font-size: .82rem; color: var(--tm-testo-2); padding: .35rem .2rem; }
.chat-casella .invia { flex: none; width: 2.3rem; height: 2.3rem; padding: 0; border-radius: 50%; }
.chat-casella .invia .icona { margin: 0; }
.chat-suggerimenti { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem; margin-top: .7rem; }
.chat-nota { margin: .5rem 0 .75rem; text-align: center; font-size: .75rem; color: var(--tm-testo-2); }
.chat-barra { display: flex; justify-content: flex-end; margin-bottom: .25rem; }
.chat.vuota .chat-barra { display: none; }
.cursore::after { content: ""; display: inline-block; width: .5em; height: 1em; margin-left: 2px; vertical-align: -.15em; background: var(--tm-accento); animation: tm-cursore 1s steps(1) infinite; }
@keyframes tm-cursore { 50% { opacity: 0; } }

/* Pannello Analizza (offcanvas a destra) */
.tm-velo { position: absolute; inset: 0; z-index: 40; background: rgba(0, 0, 0, .3); opacity: 0; visibility: hidden; transition: opacity .3s ease, visibility .3s; }
.tm-velo.is-open { opacity: 1; visibility: visible; }
.chat-avviso { position: absolute; top: 0; right: 0; bottom: 0; z-index: 41; width: min(560px, 100%); display: flex; flex-direction: column; background: var(--tm-sfondo); border-left: 1px solid var(--tm-bordo); box-shadow: 0 0 32px rgba(0, 0, 0, .12); transform: translateX(102%); transition: transform .35s cubic-bezier(.2, .7, .2, 1); }
.chat-avviso.is-open { transform: none; }
.chat-avviso-testa { display: flex; align-items: flex-start; gap: .75rem; padding: .8rem 1rem; border-bottom: 1px solid var(--tm-bordo); background: #fff; }
.chat-avviso-testa div { flex: 1; min-width: 0; }
.chat-avviso-testa .mono { font-size: .76rem; color: var(--tm-testo-2); }
.chat-avviso-testa h2 { margin: .1rem 0 0; font-size: .95rem; font-weight: 600; }
.chat-avviso-testa .chiudi { border: 0; background: none; padding: .2rem; color: var(--tm-testo-2); }
.chat-avviso .chat { flex: 1; padding: 0 1rem; max-width: none; }

/* Toast e finestre di conferma */
.tm-toasts { position: absolute; right: 1rem; bottom: 1rem; z-index: 60; display: grid; gap: .5rem; width: min(360px, calc(100% - 2rem)); pointer-events: none; }
.toast-avviso { display: flex; align-items: flex-start; gap: .5rem; padding: .65rem .85rem; background: #fff; border: 1px solid var(--tm-bordo); border-left: 4px solid var(--tm-accento); border-radius: 4px; box-shadow: 0 8px 24px rgba(0, 0, 0, .1); font-size: .9rem; animation: tm-toast .3s ease both; pointer-events: auto; }
.toast-avviso.errore { border-left-color: var(--tm-errore); }
.toast-avviso.is-out { animation: tm-toast-out .3s ease both; }
@keyframes tm-toast { from { opacity: 0; transform: translateY(10px); } }
@keyframes tm-toast-out { to { opacity: 0; transform: translateY(10px); } }
.tm-modale { position: absolute; inset: 0; z-index: 70; display: grid; place-items: center; padding: 1rem; background: rgba(0, 0, 0, .35); }
.tm-modale-carta { width: min(480px, 100%); max-height: 100%; overflow: auto; background: #fff; border-radius: 6px; box-shadow: 0 12px 32px rgba(0, 0, 0, .12); }
.tm-modale-carta header { padding: 1rem 1.15rem .5rem; }
.tm-modale-carta header h2 { margin: 0; font-size: 1.1rem; }
.tm-modale-carta .corpo { padding: 0 1.15rem 1rem; color: var(--tm-testo-2); font-size: .93rem; }
.tm-modale-carta footer { display: flex; justify-content: flex-end; gap: .5rem; padding: .75rem 1.15rem; border-top: 1px solid var(--tm-bordo); }

/* Versione mobile dell'app: stessa logica di site.css sotto i 768 px */
@container tm (max-width: 700px) {
  .tm { background-image: none; }
  .tm-container { padding: 0 .9rem; }
  .tm-barra .tm-container { flex-wrap: wrap; gap: 0; }
  .tm-brand { padding: .6rem 0; }
  .tm-burger { display: grid; }
  .tm-nav, .tm-destra { display: none; flex-basis: 100%; }
  .tm-barra.is-open .tm-nav { display: flex; flex-direction: column; }
  .tm-barra.is-open .tm-destra { display: flex; flex-wrap: wrap; gap: .5rem 1rem; padding: .5rem 0 .8rem; border-top: 1px solid var(--tm-bordo); }
  .tm-nav > * { padding: .65rem .25rem; border-bottom: 0; border-left: 2px solid transparent; padding-left: .6rem; }
  .tm-nav .is-active { border-left-color: var(--tm-accento); }
  .tm-utente { display: none; }
  .intestazione-pagina { margin: 1.1rem 0 .8rem; }
  .intestazione-pagina h1 { font-size: 1.25rem; }
  .illustrazione-titolo { width: 36px !important; height: 36px; }
  .intestazione-pagina .azioni { margin-left: 0; width: 100%; }
  .intestazione-pagina .azioni .btn { flex: 1; min-height: 44px; }
  .intestazione-pagina .azioni .ricerca-veloce { display: none; }
  .tm .btn-sm { min-height: 36px; }
  .giudizio .btn { min-height: 32px; }

  /* Tabelle adattive: ogni riga diventa una scheda a due colonne con etichette */
  .tabella-adattiva { border: 0; background: none; overflow: visible; }
  .tabella-adattiva table, .tabella-adattiva tbody, .tabella-adattiva tr, .tabella-adattiva td { display: block; }
  .tabella-adattiva thead { display: none; }
  .tabella-adattiva tr { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem .75rem; margin-bottom: .6rem; padding: .7rem .8rem; background: #fff; border: 1px solid var(--tm-bordo); border-radius: 4px; }
  .tabella-adattiva tr.riga-nuova { background: var(--tm-accento-tenue); border-color: var(--tm-accento-bordo); }
  .tabella-adattiva tr.riga-nuova td { background: none; }
  .tabella-adattiva td { padding: 0; border: 0; min-width: 0; width: auto !important; max-width: none !important; }
  .tabella-adattiva td.intero, .tabella-adattiva td.azioni { grid-column: 1 / -1; }
  .tabella-adattiva td[data-label]::before { content: attr(data-label); display: block; font-size: .72rem; font-weight: 600; color: var(--tm-testo-2); }
  .tabella-adattiva td.azioni { text-align: left; display: flex; flex-wrap: wrap; gap: .35rem; padding-top: .3rem; }
  .tabella-adattiva td.azioni .btn { flex: 1; min-height: 40px; margin: 0 !important; }
  .tabella-adattiva td.azioni .azioni-gara { flex: 1; display: flex; }
  .tabella-adattiva td.azioni .azioni-gara .btn { flex: 1; }
  .tabella-adattiva .text-end { text-align: left; }

  .dettaglio-griglia { grid-template-columns: 1fr; }
  .anteprima-fissa { position: static; }
  .tm .griglia-campi { grid-template-columns: 1fr; }
  .costruttore { grid-template-columns: 1fr; }
  .tavolozza { display: flex; flex-wrap: nowrap; gap: .25rem; overflow-x: auto; padding-bottom: .3rem; scrollbar-width: none; }
  .tavolozza h3, .tavolozza .gruppo-campi, .tavolozza p { display: none; }
  .elemento-tavolozza { flex: none; margin: 0; min-height: 32px; }
  .tm .form-control, .tm .form-select, .chat-casella textarea { font-size: 16px; }

  .chat-pagina { grid-template-columns: minmax(0, 1fr); }
  .chat-elenco { display: none; }
  .chat { padding-top: .5rem; }
  .chat-benvenuto h1 { font-size: 1.3rem; }
  .fumetto { max-width: 88%; }
  .chat-avviso { width: 100%; border-left: 0; }
  .tm-toasts { left: .75rem; right: .75rem; bottom: .75rem; width: auto; }
  .riepilogo-controllo { align-items: flex-start; font-size: .9rem; }
  .notifica-esiti { width: 100%; }
}

/* Voce Gestione (solo Admin): stessa resa delle altre, mai attiva nel prototipo */
.tm-nav .tm-gestione { display: inline-flex; align-items: center; gap: .35rem; padding: .9rem .75rem; color: var(--tm-testo-2); white-space: nowrap; border-bottom: 2px solid transparent; }
.radar-ai.in-pulsante { margin-right: .35rem; }
.tm .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@container tm (max-width: 700px) {
  .tm-nav .tm-gestione { padding: .65rem .6rem; border-bottom: 0; }
}
/* Fra 700 e 1200 px lo spazio è poco: l'indirizzo dell'utente si nasconde, come nell'app */
@container tm (min-width: 701px) and (max-width: 1200px) {
  .tm-utente { display: none; }
  .tm-nav > * { padding-left: .55rem; padding-right: .55rem; }
}
/* Solo nelle scene del racconto: sintesi su due righe, per vedere più gare */
.compatta .sintesi-ai { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
