:root {
  --inchiostro: #1c2430;
  --testo: #33404f;
  --tenue: #6b7889;
  --linea: #dde3ea;
  --sfondo: #f4f6f9;
  --carta: #ffffff;
  --marchio: #14532d;
  --marchio-2: #1f7a44;
  --accento: #b45309;
  --ok: #15803d;
  --ko: #b91c1c;
  --ombra: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; line-height: 1.45;
  color: var(--testo); background: var(--sfondo);
}
a { color: #14532d; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--inchiostro); margin: 0 0 .6rem; font-weight: 600; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; margin-top: 1.2rem; }

/* ---------------------------------------------------------------- testata */
.testata {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(180deg, var(--marchio-2), var(--marchio));
  color: #fff; padding: .55rem 1.1rem;
}
.marchio { font-size: 1.05rem; font-weight: 700; letter-spacing: .2px; }
.marchio span { font-weight: 400; opacity: .75; font-size: .8rem; margin-left: .35rem; }
.utente { font-size: .8rem; opacity: .95; }
.utente a { color: #d9f2e3; }

/* ------------------------------------------------------------------ menu */
.menu {
  display: flex; align-items: stretch; gap: .1rem; flex-wrap: wrap;
  background: #fff; border-bottom: 1px solid var(--linea); padding: 0 .6rem;
  position: sticky; top: 0; z-index: 20; box-shadow: var(--ombra);
}
.menu > a, .menu .gruppo > span {
  display: block; padding: .62rem .8rem; font-size: .86rem; font-weight: 500;
  color: var(--testo); border-bottom: 2px solid transparent; cursor: pointer;
}
.menu > a:hover, .menu .gruppo:hover > span { color: var(--marchio-2); text-decoration: none; }
.menu > a.attivo { color: var(--marchio); border-bottom-color: var(--marchio-2); font-weight: 600; }
.menu .gruppo { position: relative; }
.menu .gruppo:hover > span { border-bottom-color: var(--linea); }
.tendina {
  display: none; position: absolute; top: 100%; left: 0; min-width: 210px;
  background: #fff; border: 1px solid var(--linea); border-radius: 0 0 6px 6px;
  box-shadow: 0 8px 20px rgba(16, 24, 40, .12); padding: .3rem 0; z-index: 30;
}
.menu .gruppo:hover .tendina { display: block; }
.tendina a { display: block; padding: .42rem .9rem; font-size: .85rem; color: var(--testo); }
.tendina a:hover { background: #eef4f0; text-decoration: none; color: var(--marchio); }

/* ------------------------------------------------------------------ corpo */
main { padding: 1.1rem 1.2rem 3rem; max-width: 1500px; margin: 0 auto; }
.piede { text-align: center; font-size: .76rem; color: var(--tenue); padding: 1.5rem 0; }

/* ---------------------------------------------------------------- filtri */
.barra {
  display: flex; gap: .5rem; align-items: center; flex-wrap: wrap;
  background: var(--carta); border: 1px solid var(--linea); border-radius: 6px;
  padding: .6rem .7rem; margin-bottom: .9rem; box-shadow: var(--ombra);
}
.barra input[type=text], .barra input[name=q], .barra input:not([type]) {
  flex: 1 1 260px; min-width: 180px;
}
input, select, textarea, button {
  font: inherit; color: var(--testo);
  padding: .38rem .5rem; border: 1px solid #c9d2dc; border-radius: 5px; background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(31, 122, 68, .25); border-color: var(--marchio-2);
}
textarea { min-height: 62px; resize: vertical; }
button, .bottone {
  display: inline-block; cursor: pointer; padding: .4rem .75rem;
  background: var(--marchio-2); color: #fff; border: 1px solid var(--marchio);
  border-radius: 5px; font-size: .85rem; font-weight: 500; text-decoration: none;
}
button:hover, .bottone:hover { background: var(--marchio); color: #fff; text-decoration: none; }
.bottone.secondario, button.secondario {
  background: #fff; color: var(--testo); border-color: #c9d2dc;
}
.bottone.secondario:hover, button.secondario:hover { background: #eef2f6; color: var(--inchiostro); }
.bottone.pericolo, button.pericolo { background: #fff; color: var(--ko); border-color: #f0c4c4; }
.bottone.pericolo:hover, button.pericolo:hover { background: #fdecec; }

/* --------------------------------------------------------------- griglia */
table.griglia {
  width: 100%; border-collapse: collapse; background: var(--carta);
  border: 1px solid var(--linea); border-radius: 6px; overflow: hidden;
  box-shadow: var(--ombra); font-size: .85rem;
}
table.griglia th, table.griglia td { padding: .45rem .6rem; text-align: left; border-bottom: 1px solid var(--linea); }
table.griglia th {
  background: #eef2f6; font-weight: 600; color: var(--inchiostro);
  font-size: .78rem; text-transform: uppercase; letter-spacing: .3px; white-space: nowrap;
}
table.griglia tbody tr:hover { background: #f7faf8; }
table.griglia tr.disattivo { opacity: .55; }
table.griglia td.num, table.griglia th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.griglia td.vuoto, td.vuoto { text-align: center; color: var(--tenue); padding: 1.4rem; }
table.griglia tfoot td { font-weight: 600; background: #f7f9fb; }
.conteggio {
  display: inline-block; background: #eef2f6; color: var(--tenue);
  border-radius: 20px; padding: .05rem .55rem; font-size: .78rem; font-weight: 600; vertical-align: middle;
}
.pagine { display: flex; gap: .6rem; align-items: center; margin-top: .8rem; font-size: .82rem; color: var(--tenue); }

/* ----------------------------------------------------------------- schede */
.scheda {
  background: var(--carta); border: 1px solid var(--linea); border-radius: 8px;
  padding: 1rem 1.1rem; box-shadow: var(--ombra); margin-bottom: 1rem;
}
.scheda > h3:first-child { margin-top: 0; }
.riga-campi { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .6rem .9rem; }
.campo { display: flex; flex-direction: column; gap: .18rem; }
.campo > span, .campo > label { font-size: .75rem; font-weight: 600; color: var(--tenue); text-transform: uppercase; letter-spacing: .3px; }
.campo input, .campo select, .campo textarea { width: 100%; }
.campo.largo { grid-column: 1 / -1; }
.azioni { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .9rem; }
.azioni form { display: inline; margin: 0; }

/* ------------------------------------------------------------------- tab */
.tab { display: flex; gap: .25rem; flex-wrap: wrap; border-bottom: 1px solid var(--linea); margin-bottom: .9rem; }
.tab a {
  padding: .45rem .8rem; font-size: .84rem; color: var(--testo);
  border: 1px solid transparent; border-bottom: 2px solid transparent; border-radius: 5px 5px 0 0;
}
.tab a:hover { background: #f2f5f8; text-decoration: none; }
.tab a.attivo { color: var(--marchio); border-bottom-color: var(--marchio-2); background: #fff; font-weight: 600; }

/* ----------------------------------------------------------------- totali */
.totali { display: flex; gap: 1.4rem; flex-wrap: wrap; margin: .8rem 0 0; font-size: .85rem; }
.totali div { min-width: 130px; }
.totali span { display: block; font-size: .72rem; text-transform: uppercase; color: var(--tenue); letter-spacing: .3px; }
.totali strong { font-size: 1.02rem; color: var(--inchiostro); font-variant-numeric: tabular-nums; }
.pos { color: var(--ok); }
.neg { color: var(--ko); }
.etichetta {
  display: inline-block; padding: .05rem .45rem; border-radius: 4px; font-size: .74rem;
  font-weight: 600; background: #eef2f6; color: var(--testo);
}
.etichetta.aperto { background: #e8f1ff; color: #1d4ed8; }
.etichetta.chiuso { background: #e8f5ec; color: var(--ok); }
.etichetta.annullata { background: #fdecec; color: var(--ko); }

/* ------------------------------------------------------------------ login */
.login { max-width: 360px; margin: 8vh auto; }
.login .scheda { padding: 1.4rem; }
.login h1 { font-size: 1.3rem; text-align: center; margin-bottom: 1.1rem; }
.login .campo { margin-bottom: .75rem; }
.login button { width: 100%; margin-top: .4rem; }
.avviso {
  background: #fff8ec; border: 1px solid #f3d9a8; color: #8a5a00;
  border-radius: 6px; padding: .55rem .8rem; font-size: .82rem; margin-bottom: .9rem;
}
.errore {
  background: #fdecec; border: 1px solid #f0c4c4; color: var(--ko);
  border-radius: 6px; padding: .55rem .8rem; font-size: .82rem; margin-bottom: .9rem;
}

/* ---------------------------------------------------------------- stampa */
body.stampa { background: #fff; }
body.stampa main { max-width: 820px; padding: 1.5rem; }
body.stampa .testata, body.stampa .menu, body.stampa .piede, body.stampa .no-stampa { display: none; }
.fattura-doc { border: 1px solid var(--linea); padding: 1.5rem; }
.fattura-doc .intestazione { display: flex; justify-content: space-between; gap: 2rem; margin-bottom: 1.4rem; }
.fattura-doc .intestazione strong { font-size: 1.05rem; color: var(--inchiostro); }
.fattura-doc .indirizzi { display: flex; justify-content: space-between; gap: 2rem; margin: 1rem 0 1.4rem; }
.fattura-doc .indirizzi div { flex: 1; }
.fattura-doc table { width: 100%; border-collapse: collapse; margin-top: .6rem; }
.fattura-doc th, .fattura-doc td { border-bottom: 1px solid var(--linea); padding: .45rem .5rem; text-align: left; font-size: .88rem; }
.fattura-doc td.num, .fattura-doc th.num { text-align: right; }
.totale-finale { text-align: right; margin-top: 1rem; font-size: 1rem; }
.totale-finale strong { font-size: 1.15rem; }
@media print { body.stampa main { padding: 0; } .fattura-doc { border: 0; } }
