/* GIA Web — palette GDM, mobile prima di tutto */
@font-face { font-family: "Outfit GDM"; src: url("/gdm-outfit.woff2") format("woff2"); font-display: swap; }
:root {
  --sfondo: #f4f6f9; --superficie: #fff; --bordo: #dfe5ee; --testo: #1a2233; --tenue: #5d6879;
  --primario: #17416b; --primario-alto: #1d5488; --ok: #0b7a55; --allarme: #b42318; --allarme-fondo: #fdecea;
  --raggio: 10px; --ombra: 0 1px 2px rgba(16,32,64,.06), 0 2px 8px rgba(16,32,64,.05);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  color: var(--testo); background: var(--sfondo); -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { min-height: 100vh; background: var(--sfondo); font-size: 15px; line-height: 1.4; overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #f2b705; outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
a { color: var(--primario-alto); }

.testata { position: sticky; top: 0; z-index: 20; background: var(--primario); color: #fff; padding-top: env(safe-area-inset-top); box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.testata-riga { display: flex; align-items: center; gap: 12px; padding: 10px 16px 6px; max-width: 1400px; margin: 0 auto; }
.logo { height: 30px; width: auto; display: block; }
.titolo { flex: 1; min-width: 0; }
.titolo h1 { margin: 0; font-family: "Outfit GDM", inherit; font-size: 17px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sotto { margin: 1px 0 0; font-size: 12.5px; color: #d6e3f1; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.anno { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 6px; padding: 0 4px; font-size: 12.5px; }
.anno option { color: #000; }
.stato { display: inline-flex; align-items: center; gap: 5px; }
.punto { width: 8px; height: 8px; border-radius: 50%; background: #9fb3c8; display: inline-block; }
.stato.ok .punto { background: #3ddc97; } .stato.ko .punto { background: #ff6b6b; }
.icona { width: 40px; height: 40px; border-radius: 10px; border: 1px solid rgba(255,255,255,.3); background: transparent; color: #fff; display: grid; place-items: center; flex: none; }
.icona svg { width: 22px; height: 22px; }
.icona.scura { color: var(--testo); border-color: var(--bordo); }
.briciole { max-width: 1400px; margin: 0 auto; padding: 0 16px 8px; font-size: 13px; color: #d6e3f1; white-space: nowrap; overflow-x: auto; }
.briciole a { color: #fff; }
.pannello { position: fixed; right: 12px; top: 64px; z-index: 30; max-height: calc(100dvh - 76px); overflow-y: auto; background: var(--superficie); border: 1px solid var(--bordo); border-radius: var(--raggio); box-shadow: 0 8px 24px rgba(0,0,0,.18); display: flex; flex-direction: column; min-width: 230px; overflow: hidden; }
.pannello a { padding: 12px 16px; text-decoration: none; color: var(--testo); border-bottom: 1px solid var(--bordo); }
.pannello a:hover { background: #eef3f9; }
.pannello .esci { color: var(--allarme); }

main { max-width: 1400px; margin: 0 auto; padding: 14px 16px 40px; }
.caricamento, .vuoto { color: var(--tenue); padding: 24px 0; text-align: center; }
.errore { background: var(--allarme-fondo); color: var(--allarme); border-radius: var(--raggio); padding: 12px 14px; margin: 10px 0; }

/* home: moduli */
.moduli { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.modulo { background: var(--superficie); border-radius: var(--raggio); box-shadow: var(--ombra); border: 1px solid var(--bordo); overflow: hidden; }
.modulo > h2 { margin: 0; padding: 10px 14px; font-family: "Outfit GDM", inherit; font-size: 17px; color: #10233c; border-bottom: 1px solid rgba(0,0,0,.08); }
.modulo details { border-top: 1px solid var(--bordo); }
.modulo details:first-of-type { border-top: 0; }
.modulo summary { padding: 10px 14px; cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 8px; }
.modulo summary::after { content: "›"; color: var(--tenue); transition: transform .15s; }
.modulo details[open] summary::after { transform: rotate(90deg); }
.modulo ul { list-style: none; margin: 0; padding: 0 0 8px; }
.modulo li a { display: flex; justify-content: space-between; gap: 8px; padding: 8px 14px 8px 24px; text-decoration: none; color: var(--testo); font-size: 14.5px; }
.modulo li a:hover { background: #eef3f9; }
.etichetta { font-size: 11px; border-radius: 99px; padding: 1px 7px; background: #e8eef6; color: var(--tenue); align-self: center; white-space: nowrap; }
.etichetta.sap { background: #e3f1ff; color: #0b4f8a; } .etichetta.locale { background: #e5f5ee; color: var(--ok); } .etichetta.info { background: #f1f1f1; }
.cerca-globale { width: 100%; padding: 11px 14px; border-radius: var(--raggio); border: 1px solid var(--bordo); margin-bottom: 12px; background: #fff; }

/* scheda */
.scheda-testa { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.scheda-testa h2 { margin: 0; font-family: "Outfit GDM", inherit; font-size: 20px; }
.scheda-testa p { margin: 2px 0 0; color: var(--tenue); font-size: 13.5px; max-width: 70ch; }
.azioni { display: flex; flex-wrap: wrap; gap: 8px; }
.btn { border: 1px solid var(--bordo); background: #fff; border-radius: 9px; padding: 8px 12px; min-height: 40px; text-decoration: none; color: var(--testo); display: inline-flex; align-items: center; gap: 6px; }
.btn.primario { background: var(--primario); color: #fff; border-color: var(--primario); }
.btn.pericolo { color: var(--allarme); }
.filtri { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; background: var(--superficie); border: 1px solid var(--bordo); border-radius: var(--raggio); padding: 10px; margin-bottom: 10px; }
.filtri label { display: flex; flex-direction: column; font-size: 12px; color: var(--tenue); gap: 3px; min-width: 0; }
.filtri input, .filtri select { border: 1px solid var(--bordo); border-radius: 8px; padding: 8px; min-height: 40px; background: #fff; width: 100%; min-width: 0; }
.cerca-riga input { width: 100%; padding: 10px 12px; border: 1px solid var(--bordo); border-radius: var(--raggio); min-height: 44px; background: #fff; margin-bottom: 8px; }
.filtri-box { margin-bottom: 10px; }
.filtri-box > summary { cursor: pointer; padding: 8px 2px; font-weight: 600; color: var(--primario); list-style: none; display: flex; gap: 8px; align-items: center; }
.filtri-box > summary::before { content: "▸"; transition: transform .15s; } .filtri-box[open] > summary::before { transform: rotate(90deg); }
.filtri-box .filtri { margin-bottom: 0; }
.contatore { font-size: 13px; color: var(--tenue); margin: 4px 0 8px; }
.tabella-box { background: var(--superficie); border: 1px solid var(--bordo); border-radius: var(--raggio); overflow: auto; max-height: calc(100vh - 220px); box-shadow: var(--ombra); }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; }
th, td { padding: 7px 10px; border-bottom: 1px solid #edf1f6; text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; background: #e9eff7; z-index: 2; font-weight: 600; cursor: pointer; user-select: none; }
th.ord::after { content: " ▲"; font-size: 10px; } th.ord.desc::after { content: " ▼"; }
td:first-child, th:first-child { position: sticky; left: 0; background: inherit; z-index: 1; }
th:first-child { z-index: 3; background: #e9eff7; }
tbody tr { background: #fff; }
tbody tr:nth-child(even) { background: #fafbfd; }
tbody tr.cliccabile { cursor: pointer; }
tbody tr.cliccabile:hover { background: #eef3f9; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.neg { color: var(--allarme); }
td.testo-lungo { white-space: normal; min-width: 220px; }
tfoot td { position: sticky; bottom: 0; background: #e9eff7; font-weight: 650; }
.paginazione { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 10px 0; }
.info-box { background: var(--superficie); border: 1px solid var(--bordo); border-radius: var(--raggio); padding: 16px; line-height: 1.55; }

/* dettaglio */
.dettaglio { position: fixed; inset: 0; z-index: 40; background: rgba(10,20,35,.45); display: flex; justify-content: flex-end; }
.dett-box { background: var(--sfondo); width: min(900px, 100%); height: 100%; display: flex; flex-direction: column; }
.dett-testa { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--bordo); padding-top: calc(12px + env(safe-area-inset-top)); }
.dett-testa h2 { margin: 0; font-size: 17px; }
.dett-corpo { overflow: auto; padding: 14px 16px 40px; flex: 1; }
.campi { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 14px; }
.campo { background: #fff; border: 1px solid var(--bordo); border-radius: 8px; padding: 7px 10px; min-width: 0; }
.campo span { display: block; font-size: 11.5px; color: var(--tenue); }
.campo b, .campo input, .campo select, .campo textarea { display: block; font-weight: 600; overflow-wrap: anywhere; }
.campo input, .campo select, .campo textarea { width: 100%; border: 1px solid var(--bordo); border-radius: 6px; padding: 6px; font-weight: 500; margin-top: 2px; }
.sezione h3 { margin: 16px 0 8px; font-size: 15px; }
.sezione .tabella-box { max-height: none; }

/* strumenti */
.messaggi { display: flex; flex-direction: column; gap: 8px; }
.messaggio { background: #fff; border: 1px solid var(--bordo); border-radius: 8px; padding: 8px 12px; }
.messaggio small { color: var(--tenue); }
.form-riga { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.form-riga input, .form-riga textarea, .form-riga select { flex: 1 1 200px; min-width: 0; border: 1px solid var(--bordo); border-radius: 8px; padding: 9px; background: #fff; }
.pagina-messaggio { display: grid; place-items: center; min-height: 100vh; background: var(--primario); color: #fff; text-align: center; padding: 20px; }
.pagina-messaggio .btn { background: #fff; color: var(--primario); }

@media (max-width: 600px) {
  .testata-riga { padding: 8px 12px 4px; } main { padding: 10px 12px 40px; }
  .titolo h1 { font-size: 15.5px; } .scheda-testa h2 { font-size: 18px; }
  .tabella-box { max-height: calc(100vh - 260px); }
  .filtri { grid-template-columns: 1fr 1fr; }
}
@media (orientation: landscape) and (max-height: 500px) { .testata { position: static; } .tabella-box { max-height: none; } }

@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body { background: #fff; font-size: 10.5px; }
  .testata { position: static; box-shadow: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .icona, .briciole, .pannello, .azioni, .filtri, .paginazione, #anno { display: none !important; }
  main { max-width: none; padding: 6px 0; }
  .tabella-box { max-height: none; overflow: visible; border: 0; box-shadow: none; }
  th, td { padding: 3px 5px; position: static !important; white-space: normal; }
  tr { break-inside: avoid; }
  .dettaglio { position: static; background: none; } .dett-box { width: 100%; height: auto; }
  body.stampa-dettaglio main { display: none; }
}

.mod-contabilita h2 { background: #ffe14d; } .mod-vendite h2 { background: #c8f7c5; } .mod-magazzino h2 { background: #c9b6f2; }
.mod-agenti h2 { background: #d6f6ff; } .mod-scadenziario h2 { background: #ffc98a; } .mod-produzione h2 { background: #ff8fd0; }
.mod-personale h2 { background: #5fd3c4; } .mod-laboratorio h2 { background: #7ff3f3; } .mod-strumenti h2 { background: #e5e9f2; }
.campo.largo { grid-column: 1 / -1; }
.cf-esito { font-size: 22px; font-weight: 700; letter-spacing: 1px; }

th .ordina { all: unset; cursor: pointer; display: block; }
th .ordina:focus-visible { outline: 3px solid #f2b705; }
.btn.piccolo { min-height: 34px; padding: 4px 9px; }
.sez-mod td input { width: 100%; min-width: 120px; border: 1px solid var(--bordo); border-radius: 6px; padding: 5px 6px; background: #fff; }
.sez-mod td input.num { text-align: right; min-width: 70px; max-width: 110px; }
.sez-mod td input[data-k="des"] { min-width: 240px; }
.azioni-riga { white-space: nowrap; display: flex; gap: 4px; }
