:root {
  --nero: #1a1a1a;
  --blu: #1e3a8a;
  --azzurro: #5bc8d6;
  --rosso: #9c1f1f;
  --verde: #1f7a3f;
  --giallo: #e0a800;
  --sfondo: #f4f5f7;
  --bordo: #dcdfe4;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--sfondo);
  color: var(--nero);
}

.topbar {
  background: var(--nero);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar img.logo {
  height: 40px;
}

.topbar h1 {
  font-size: 1.1rem;
  margin: 0;
  font-weight: 600;
}

.topbar .staff-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
}

.topbar form { margin: 0; }

.nav-tabs {
  background: #262626;
  display: flex;
  gap: 0.25rem;
  padding: 0 1.5rem;
}

.nav-tab {
  color: #ccc;
  text-decoration: none;
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
  border-bottom: 2px solid transparent;
}

.nav-tab.attivo {
  color: #fff;
  border-bottom-color: var(--azzurro);
  font-weight: 600;
}

.nav-tab:hover { color: #fff; }

.btn {
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
  display: inline-block;
}

.btn-primary { background: var(--blu); color: #fff; }
.btn-logout { background: transparent; color: #fff; border: 1px solid #555; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--nero);
}

.login-card {
  background: #fff;
  border-radius: 10px;
  padding: 2.5rem;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.login-card img.logo {
  height: 90px;
  margin-bottom: 1rem;
}

.login-card h1 {
  font-size: 1.1rem;
  margin: 0 0 1.5rem;
  color: #444;
}

.login-card input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.85rem;
  border: 1px solid var(--bordo);
  border-radius: 6px;
  font-size: 0.95rem;
}

.login-card .btn-primary {
  width: 100%;
  padding: 0.7rem;
  font-weight: 600;
}

.errore {
  background: #fdecea;
  color: var(--rosso);
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.stats {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--bordo);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  flex: 1;
  min-width: 140px;
}

.stat-card .numero {
  font-size: 1.8rem;
  font-weight: 700;
}

.stat-card .etichetta {
  font-size: 0.8rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-card.rossi .numero { color: var(--rosso); }
.stat-card.verdi .numero { color: var(--verde); }

.toolbar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar input[type="text"] {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--bordo);
  border-radius: 6px;
  font-size: 0.9rem;
  flex: 1;
  min-width: 180px;
}

.toolbar select {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--bordo);
  border-radius: 6px;
  font-size: 0.9rem;
  background: #fff;
}

.filtri { display: flex; gap: 0.5rem; }

.filtro-link {
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  border: 1px solid var(--bordo);
  color: #444;
  text-decoration: none;
  font-size: 0.85rem;
  background: #fff;
}

.filtro-link.attivo {
  background: var(--blu);
  color: #fff;
  border-color: var(--blu);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--bordo);
}

th, td {
  padding: 0.65rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--bordo);
  font-size: 0.9rem;
}

th {
  background: #fafafa;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: #666;
  letter-spacing: 0.03em;
}

tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
}

.badge-rosso { background: var(--rosso); }
.badge-giallo { background: var(--giallo); color: #3a2a00; }
.badge-verde { background: var(--verde); }

.sotto-stato {
  font-size: 0.78rem;
  color: #666;
  margin-top: 0.3rem;
}

.vuoto {
  text-align: center;
  padding: 2rem;
  color: #777;
}

.gruppo-titolo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1rem;
  color: #333;
  margin: 1.75rem 0 0.6rem;
}

.gruppo-titolo:first-of-type { margin-top: 0.5rem; }

.riepilogo-annate {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.chip-annata {
  background: #fff;
  border: 1px solid var(--bordo);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.8rem;
  color: #555;
}

.chip-annata strong { color: var(--nero); }

.gruppo-conteggio {
  background: var(--bordo);
  color: #444;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
}

.cella-documenti { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.btn-doc {
  border: 1px solid var(--bordo);
  background: #fff;
  color: var(--blu);
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  font-size: 0.78rem;
  text-decoration: none;
  white-space: nowrap;
}

.btn-doc:hover { background: #eef2ff; }

.btn-doc { border: 1px solid var(--bordo); cursor: pointer; font-family: inherit; }

.riga-form {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.riga-form input {
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--bordo);
  border-radius: 6px;
  font-size: 0.9rem;
}

.nota {
  font-size: 0.82rem;
  color: #666;
  margin-top: -0.5rem;
  margin-bottom: 0.75rem;
}

.nota-piccola {
  font-size: 0.8rem;
  color: #888;
  margin-top: 2rem;
}

.valore-calcolato {
  color: #666;
  font-style: italic;
  font-size: 0.9rem;
}

table.campi input[type="text"],
table.campi input[type="date"],
table.campi input[type="time"],
table.campi input[type="number"],
table.campi input[type="email"] {
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--bordo);
  border-radius: 5px;
  font-size: 0.88rem;
  width: 100%;
}

.riga-form label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
}

h3 {
  font-size: 0.95rem;
  color: #333;
  margin: 1.75rem 0 0.75rem;
}

@media (max-width: 640px) {
  .container { padding: 1rem; }
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tr { margin-bottom: 0.75rem; border: 1px solid var(--bordo); border-radius: 8px; overflow: hidden; }
  td { border-bottom: none; display: flex; justify-content: space-between; gap: 1rem; }
  td::before { content: attr(data-label); font-weight: 600; color: #666; }
}

.badge-grigio { background: #6b7280; }

.avviso-card {
  background: #fff;
  border: 1px solid var(--bordo);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  margin-bottom: 1.25rem;
}

.avviso-card .gruppo-titolo { margin-top: 0; flex-wrap: wrap; }

.avviso-testo {
  background: var(--sfondo);
  border-radius: 6px;
  padding: 0.75rem 0.9rem;
  font-family: inherit;
  font-size: 0.85rem;
  white-space: pre-wrap;
  margin: 0 0 0.6rem;
}

.avviso-card .riga-form { margin-bottom: 0.75rem; }

.badge[hidden] { display: none; }

/* pagamenti del mese prima squadra */
.filtri-mesi { flex-wrap: wrap; }
.filtri-mesi .filtro-link { text-transform: capitalize; padding: 0.4rem 0.7rem; }

.esito {
  background: #e8f5ec;
  color: var(--verde);
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  font-size: 0.88rem;
  margin-bottom: 1rem;
}

.avviso-riga {
  background: #fff8e1;
  border: 1px solid #f3dc8f;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
}

.negativo { color: var(--rosso); }
/* stesse larghezze in ogni sezione e nella riga del totale, così le colonne restano allineate */
.tabella-importi { table-layout: fixed; }
.tabella-importi td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabella-importi th, .tabella-importi td { padding-inline: 0.45rem; }
.tabella-importi th { font-size: 0.68rem; }
.tabella-importi th:first-child, .tabella-importi td:first-child { width: 20%; white-space: normal; padding-left: 0.9rem; }
.tabella-importi th:last-child, .tabella-importi td:last-child { width: 118px; white-space: normal; }
.solo-stampa { display: none; }
.badge { white-space: nowrap; }
.riga-totale { margin-top: 0.75rem; }
.riga-totale td { font-weight: 600; background: #fafafa; }

.blocco-form {
  background: #fff;
  border: 1px solid var(--bordo);
  border-radius: 8px;
  padding: 1rem 1.2rem;
}
.blocco-form .riga-form { margin-bottom: 0.75rem; }
.riga-form select {
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--bordo);
  border-radius: 6px;
  font-size: 0.9rem;
  background: #fff;
}

.elenco-spunta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.35rem 1rem;
  margin-bottom: 0.9rem;
  font-size: 0.88rem;
}
.elenco-spunta label { display: flex; gap: 0.4rem; align-items: baseline; }
.elenco-spunta .sotto-stato { margin: 0; }

@media print {
  body { background: #fff; }
  .topbar, .nav-tabs, .no-print { display: none !important; }
  .container { padding: 0; max-width: none; }
  a { color: inherit; text-decoration: none; }
  th, td { padding: 0.3rem 0.5rem; font-size: 0.78rem; }
  .tabella-importi th:last-child, .tabella-importi td:last-child { width: 0; padding: 0; }
  .tabella-importi th { font-size: 0.62rem; letter-spacing: 0; }
  .solo-stampa { display: block; font-size: 1.1rem; margin: 0 0 0.75rem; }
  .stat-card { padding: 0.5rem 0.8rem; }
  .stat-card .numero { font-size: 1.2rem; }
}

.zona-elimina { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--bordo); }
.zona-elimina .nota { margin: 0; }
.btn-pericolo { color: var(--rosso); border-color: #e7b9b9; }
.btn-pericolo:hover { background: #fdecea; }

.riga-paga { display: flex; gap: 0.35rem; align-items: center; }
.riga-paga input[type="date"] { padding: 0.25rem 0.4rem; border: 1px solid var(--bordo); border-radius: 5px; font-size: 0.78rem; }
.stats-compatte { gap: 0.6rem; }
.stats-compatte .stat-card { min-width: 120px; padding: 0.8rem 0.9rem; }
.stats-compatte .stat-card .numero { font-size: 1.45rem; }
.stats-compatte .stat-card .etichetta { font-size: 0.7rem; }

/* richiesta di accesso */
.login-card-larga { max-width: 440px; text-align: left; }
.login-card-larga .logo, .login-card-larga h1 { display: block; margin-left: auto; margin-right: auto; text-align: center; }
.modulo-richiesta label { display: block; font-size: 0.85rem; color: #444; font-weight: 600; }
.modulo-richiesta input, .modulo-richiesta select {
  display: block; width: 100%; margin-top: 0.25rem; padding: 0.6rem 0.7rem;
  border: 1px solid var(--bordo); border-radius: 6px; font-size: 0.95rem; font-weight: 400; background: #fff;
}
.modulo-richiesta select { margin-bottom: 0.3rem; }
.modulo-richiesta .facoltativo { font-weight: 400; color: #888; }
.descrizione-ruolo { display: block; font-weight: 400; font-size: 0.78rem; color: #666; margin-bottom: 0.85rem; min-height: 1em; }
.nota-login { font-size: 0.85rem; color: #555; }
.link-login { font-size: 0.85rem; margin: 1rem 0 0; }
.nav-tab .badge { padding: 0.05rem 0.45rem; font-size: 0.7rem; }

/* occhietto per mostrare/nascondere la password */
.campo-password { position: relative; display: block; }
.campo-password input { width: 100%; padding-right: 2.6rem !important; }
.campo-password .occhio {
  position: absolute; right: 0.35rem; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; padding: 0; border: none; border-radius: 6px;
  background: transparent; color: #777; cursor: pointer;
}
.campo-password .occhio:hover, .campo-password .occhio:focus-visible { color: var(--blu); background: #eef2ff; outline: none; }

/* configurazioni */
.indice-config { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1.25rem; }
.indice-config a { padding: 0.35rem 0.75rem; border: 1px solid var(--bordo); border-radius: 999px; background: #fff; color: #444; text-decoration: none; font-size: 0.82rem; }
.indice-config a:hover { border-color: var(--blu); color: var(--blu); }
.config-card { background: #fff; border: 1px solid var(--bordo); border-radius: 10px; padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; scroll-margin-top: 1rem; }
.config-testa { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.4rem; }
.config-testa h2 { font-size: 1.05rem; margin: 0; }
.config-card table.campi { border: none; }
.config-card table.campi td:first-child { width: 190px; font-weight: 600; color: #444; }
.config-azioni { margin: 0.9rem 0 0.4rem; }
.tabella-scorrevole { overflow-x: auto; }
.matrice-permessi th { font-size: 0.7rem; text-align: center; white-space: normal; }
.matrice-permessi th:first-child { text-align: left; }
.matrice-permessi td { vertical-align: middle; }
.cella-spunta { text-align: center; }
.cella-spunta input { width: 1.1rem; height: 1.1rem; }
.elenco-link { margin: 0; padding-left: 1.2rem; line-height: 1.9; font-size: 0.9rem; }
@media (max-width: 640px) {
  .matrice-permessi, .matrice-permessi thead, .matrice-permessi tbody, .matrice-permessi tr, .matrice-permessi th, .matrice-permessi td { display: revert; }
  .matrice-permessi thead { display: table-header-group; }
  .matrice-permessi td::before { content: none; }
  .config-card table.campi td:first-child { width: auto; }
}

.btn-doc:disabled { color: #9aa0a6; background: #f3f4f6; border-color: var(--bordo); cursor: not-allowed; }
