/* GAJA — interfaccia v0.1 (livello di presentazione del runtime AFS 0.4.0)
   Regole applicate dal Manuale di Corporate e Visual Identity v1.1:
   - solo 6 colori; sfumature solo per trasparenza (testo secondario = teal 68%, bordi = teal 16%)
   - due sole eccezioni, entrambe DICHIARATE in tavolozza: --errore, usato solo per gli
     errori bloccanti, e --oro-scuro, tinta derivata dell'oro usata solo dove l'oro di
     marca non raggiungerebbe il contrasto (decisione del committente, 2026-09-30)
   - niente gradienti, niente bianco puro; oro mai oltre un decimo della superficie
   - rosso #B4462E solo per gli errori; il colore non e' mai l'unico segnale
   - Poppins (marca e interfaccia) · Lora (editoriale) */

:root {
  --teal: #0E2A2A;          /* teal profondo: primario, navigazione, testi */
  --teal-2: #1B5E5A;        /* teal medio: completato, link */
  --blu: #2B5FA8;           /* blu cobalto: dati, in corso */
  --notte: #0B1E29;         /* blu-notte */
  --oro: #C79A44;           /* oro antico: nuovo, match, opportunita' */
  --bianco: #FAF7F0;        /* bianco caldo */
  --errore: #B4462E;        /* eccezione dichiarata: solo errori bloccanti */
  --oro-scuro: #8A6A2A;     /* eccezione dichiarata: tinta derivata dell'oro, usata solo
                               dove l'oro di marca non tiene il contrasto (icone su velo
                               d'oro). NON e' un settimo colore di marca: non compare mai
                               su superfici, solo su segni. */

  --txt: #0E2A2A;
  --txt-2: rgba(14, 42, 42, .68);
  --txt-3: rgba(14, 42, 42, .52);
  --bordo: rgba(14, 42, 42, .16);
  --bordo-forte: rgba(14, 42, 42, .28);
  --velo: rgba(14, 42, 42, .04);
  --velo-2: rgba(14, 42, 42, .07);
  --oro-velo: rgba(199, 154, 68, .16);
  --blu-velo: rgba(43, 95, 168, .12);
  --teal2-velo: rgba(27, 94, 90, .12);
  --err-velo: rgba(180, 70, 46, .10);
  --su-scuro: rgba(250, 247, 240, .72);
  --su-scuro-2: rgba(250, 247, 240, .52);

  --r-card: 12px;
  --r-ctl: 8px;
  --f-brand: 'Poppins', 'Helvetica Neue', Arial, sans-serif;
  --f-edit: 'Lora', Georgia, 'Times New Roman', serif;
  --f-mono: 'SFMono-Regular', Menlo, Consolas, monospace;
  --side: 248px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--f-brand); font-weight: 400; font-size: 14px; line-height: 1.5;
  color: var(--txt); background: var(--bianco);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--teal-2); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blu); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--teal); color: var(--bianco);
  padding: 8px 14px; border-radius: var(--r-ctl); z-index: 99; }
.skip:focus { left: 12px; }

/* ---------------------------------------------------------------- shell */
.app { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side {
  background: var(--teal); color: var(--bianco); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 28px 16px 20px;
}
.side .logo { display: block; padding: 0 12px 28px; }
.side .logo img { width: 132px; height: auto; display: block; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--su-scuro-2); padding: 18px 12px 6px; margin: 0; font-weight: 500; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-ctl);
  color: var(--su-scuro); text-decoration: none; font-size: 14px; border-left: 3px solid transparent;
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav a:hover { background: rgba(250, 247, 240, .06); color: var(--bianco); }
.nav a[aria-current="page"] { background: rgba(250, 247, 240, .09); color: var(--bianco);
  border-left-color: var(--oro); }
.nav .sub a { padding-left: 42px; font-size: 13px; }
.side-foot { margin-top: auto; padding: 16px 12px 0; border-top: 1px solid rgba(250, 247, 240, .12);
  font-size: 12px; color: var(--su-scuro-2); }
.side-foot strong { color: var(--su-scuro); font-weight: 500; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 40px; border-bottom: 1px solid var(--bordo); background: var(--bianco);
  position: sticky; top: 0; z-index: 5;
}
.crumbs { font-size: 13px; color: var(--txt-2); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.crumbs a { color: var(--txt-2); text-decoration: none; }
.crumbs a:hover { color: var(--txt); }
.crumbs .sep { color: var(--txt-3); }
.top-right { display: flex; align-items: center; gap: 12px; }
.pill-env { font-size: 12px; color: var(--txt-2); border: 1px solid var(--bordo); border-radius: 999px;
  padding: 4px 12px; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.pill-env .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--teal-2); }
.who { display: inline-flex; align-items: center; gap: 10px; background: none; border: 1px solid var(--bordo);
  border-radius: 999px; padding: 4px 12px 4px 4px; cursor: pointer; }
.who:hover { border-color: var(--bordo-forte); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--blu); color: var(--bianco);
  display: grid; place-items: center; font-size: 12px; font-weight: 500; }
.who span.nm { font-size: 13px; }

.content { padding: 36px 40px 64px; max-width: 1180px; width: 100%; }

/* ---------------------------------------------------------- tipografia */
.eyebrow { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--oro);
  font-weight: 500; margin: 0 0 8px; }
h1.hero { font-family: var(--f-brand); font-weight: 400; font-size: 30px; line-height: 1.25;
  margin: 0 0 28px; letter-spacing: -.01em; }
h1.hero .hl { color: var(--oro); font-weight: 500; }
h1.page { font-family: var(--f-edit); font-weight: 400; font-size: 30px; line-height: 1.2; margin: 0 0 6px; }
.lead { color: var(--txt-2); margin: 0 0 28px; max-width: 70ch; }
h2 { font-size: 17px; font-weight: 500; margin: 36px 0 14px; }
h2:first-child { margin-top: 0; }
h3 { font-size: 15px; font-weight: 500; margin: 0; }
.muted { color: var(--txt-2); }
.small { font-size: 12px; }
.mono { font-family: var(--f-mono); font-size: 12px; overflow-wrap: anywhere; }
.quote { font-family: var(--f-edit); font-style: italic; color: var(--teal-2); }

/* -------------------------------------------------------------- blocchi */
.grid { display: grid; gap: 16px; }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--bianco); border: 1px solid var(--bordo); border-radius: var(--r-card); padding: 20px 22px; }
.card.flat { background: var(--velo); border-color: transparent; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }

.kpi { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.kpi .n { font-size: 34px; font-weight: 500; line-height: 1.1; letter-spacing: -.02em; }
.kpi .l { color: var(--txt-2); font-size: 13px; margin-top: 4px; }
.kpi .ic { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.kpi .ic svg { width: 20px; height: 20px; }
.ic.oro { background: var(--oro-velo); color: var(--oro-scuro); }
.ic.blu { background: var(--blu-velo); color: var(--blu); }
.ic.teal { background: var(--teal2-velo); color: var(--teal-2); }
.ic.err { background: var(--err-velo); color: var(--errore); }
.ic.neutro { background: var(--velo-2); color: var(--txt-2); }

/* badge semantici: sempre con etichetta testuale */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 500;
  letter-spacing: .1em; text-transform: uppercase; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.b-nuovo { background: var(--oro); color: var(--teal); }
.b-corso { background: var(--blu); color: var(--bianco); }
.b-ok { background: var(--teal-2); color: var(--bianco); }
.b-err { background: var(--errore); color: var(--bianco); }
.b-neutro { background: var(--velo-2); color: var(--txt-2); }
.b-linea { border: 1px solid var(--bordo-forte); color: var(--txt-2); background: transparent; }

/* liste di righe (stile "Bandi in evidenza") */
.rows { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: grid; grid-template-columns: 130px minmax(0, 1fr) auto auto; gap: 18px; align-items: center;
  border: 1px solid var(--bordo); border-radius: var(--r-card); padding: 14px 18px; background: var(--bianco);
  text-decoration: none; color: inherit;
}
a.row:hover, button.row:hover { border-color: var(--bordo-forte); background: var(--velo); }
button.row { width: 100%; text-align: left; cursor: pointer; font: inherit; }
.row .t { font-weight: 500; display: block; }
.row .s { display: block; color: var(--txt-2); font-size: 12px; margin-top: 2px; }
.row .meta { font-size: 12px; color: var(--txt-2); text-align: right; white-space: nowrap; }
.row .meta b { display: block; color: var(--txt); font-weight: 400; font-size: 13px; }
.row .go { color: var(--blu); }
.row .go svg { width: 18px; height: 18px; display: block; }

.bar { height: 6px; background: var(--velo-2); border-radius: 999px; overflow: hidden; min-width: 120px; }
.bar > i { display: block; height: 100%; background: var(--blu); border-radius: 999px; }
.bar.ok > i { background: var(--teal-2); }

/* percorso della pratica */
.journey { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0; margin: 4px 0 8px; }
.step { position: relative; padding: 0 10px 0 0; }
.step .dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 500; border: 2px solid var(--bordo-forte); background: var(--bianco);
  color: var(--txt-2); position: relative; z-index: 1; }
.step::before { content: ""; position: absolute; top: 14px; left: 30px; right: 0; height: 2px; background: var(--bordo); }
.step:last-child::before { display: none; }
.step .nm { font-weight: 500; font-size: 13px; margin-top: 10px; }
.step .ds { font-size: 12px; color: var(--txt-2); margin-top: 2px; padding-right: 8px; }
.step.done .dot { background: var(--teal-2); border-color: var(--teal-2); color: var(--bianco); }
.step.done::before { background: var(--teal-2); }
.step.now .dot { background: var(--blu); border-color: var(--blu); color: var(--bianco); }
.step.off .dot { border-style: dashed; }
.step .st { margin-top: 8px; }

/* tabelle */
.tablewrap { overflow-x: auto; border: 1px solid var(--bordo); border-radius: var(--r-card); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--txt-2); padding: 12px 16px; border-bottom: 1px solid var(--bordo); background: var(--velo); }
td { padding: 12px 16px; border-bottom: 1px solid var(--bordo); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; font-size: 13px; }
dl.kv dt { color: var(--txt-2); }
dl.kv dd { margin: 0; }

/* controlli */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: var(--r-ctl);
  padding: 9px 16px; font-size: 13px; font-weight: 500; cursor: pointer; border: 1px solid transparent;
  text-decoration: none; white-space: nowrap; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--teal); color: var(--bianco); }
.btn-primary:hover { background: var(--notte); }
.btn-oro { background: var(--oro); color: var(--teal); }
.btn-oro:hover { filter: brightness(.96); }
.btn-ghost { background: transparent; border-color: var(--bordo-forte); color: var(--txt); }
.btn-ghost:hover { background: var(--velo); }
.btn-link { background: none; border: 0; color: var(--blu); padding: 0; font-weight: 500; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 500; color: var(--txt-2); }
.field .hint { font-size: 12px; color: var(--txt-3); }
input[type=text], input[type=number], select, textarea {
  border: 1px solid var(--bordo-forte); border-radius: var(--r-ctl); padding: 9px 12px; background: var(--bianco);
  width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--blu); outline: none; box-shadow: 0 0 0 3px var(--blu-velo); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }

.drop { display: block; border: 1.5px dashed var(--bordo-forte); border-radius: var(--r-card); padding: 28px; text-align: center;
  color: var(--txt-2); background: var(--velo); cursor: pointer; }
.drop.over { border-color: var(--blu); background: var(--blu-velo); color: var(--txt); }
.drop strong { color: var(--txt); font-weight: 500; }

/* stati: vuoto, caricamento, avvisi */
.empty { border: 1px dashed var(--bordo-forte); border-radius: var(--r-card); padding: 28px; text-align: center; color: var(--txt-2); }
.empty .quote { display: block; margin-bottom: 6px; font-size: 15px; }
.loading { display: flex; align-items: center; gap: 12px; color: var(--txt-2); padding: 18px 0; }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--bordo); border-top-color: var(--blu);
  animation: gira .9s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

.note { display: flex; gap: 12px; align-items: flex-start; border-radius: var(--r-card); padding: 14px 16px;
  background: var(--velo); border-left: 3px solid var(--oro); font-size: 13px; }
.note.info { border-left-color: var(--blu); }
.note.err { border-left-color: var(--errore); background: var(--err-velo); }
.note.ok { border-left-color: var(--teal-2); }
.note svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.note b { font-weight: 500; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--bordo); margin: 0 0 28px; overflow-x: auto; }
.tabs a { padding: 10px 14px; font-size: 13px; color: var(--txt-2); text-decoration: none; border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--txt); }
.tabs a[aria-current="page"] { color: var(--txt); border-bottom-color: var(--oro); font-weight: 500; }

.pratica-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.pratica-head .id { font-family: var(--f-mono); font-size: 12px; color: var(--txt-2); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 150px 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--bordo); font-size: 13px; }
.timeline li:last-child { border-bottom: 0; }

/* avvisi temporanei */
.toast-wrap { position: fixed; right: 24px; bottom: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--teal); color: var(--bianco); padding: 12px 16px; border-radius: var(--r-ctl); font-size: 13px;
  max-width: 420px; box-shadow: 0 8px 24px rgba(11, 30, 41, .18); border-left: 3px solid var(--teal-2); }
.toast.err { border-left-color: var(--errore); }

/* finestra di dialogo */
dialog { border: 0; border-radius: var(--r-card); padding: 0; width: min(520px, calc(100vw - 32px));
  background: var(--bianco); color: var(--txt); box-shadow: 0 24px 64px rgba(11, 30, 41, .28); }
dialog::backdrop { background: rgba(11, 30, 41, .45); }
dialog form { padding: 24px; }
dialog h3 { font-size: 17px; margin-bottom: 6px; }
dialog p { margin: 0 0 16px; color: var(--txt-2); font-size: 13px; }

.foot { margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--bordo); font-size: 12px; color: var(--txt-3);
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.foot .payoff b { color: var(--oro); font-weight: 700; }

/* --------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .journey { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 24px; }
  .step:nth-child(3)::before { display: none; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: 16px; }
  .side .logo { padding-bottom: 12px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-group, .side-foot, .nav .sub { display: none; }
  .top, .content { padding-left: 16px; padding-right: 16px; }
  .g3, .g2, .g4, .form-grid { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1fr; gap: 8px; }
  .row .meta { text-align: left; }
  .journey { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .step::before { display: none; }
  .timeline li { grid-template-columns: 1fr; gap: 4px; }
  .pill-env { display: none; }
}
