:root {
  /* Palette ASTRO — presa dal logo aziendale (rosso/nero su bianco) */
  --blue: #c73834;       /* rosso ASTRO: bottoni, link, numeri, tab attive */
  --blue-dark: #9b2b28;  /* rosso scuro: hover */
  --ink: #1a1919;        /* nero del logo: barra in alto */
  --orange: #d9782b;
  --bg: #f4f5f7;
  --card: #ffffff;
  --border: #dde1e6;
  --text: #1f2937;
  --text-muted: #6b7280;
  --green: #1a7f4f;
  --red: #b3261e;
  --rosso-torino: #7a1f30; /* "rosso Torino" (granata), richiesto per il paragrafo ATTENZIONE! */
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

.topbar {
  background: var(--ink);
  color: white;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 3px solid var(--blue);
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 0.55rem; color: white; text-decoration: none; font-weight: 700; letter-spacing: 0.02em; }
.brand-logo-wrap { background: white; border-radius: 8px; padding: 0.25rem 0.5rem; display: inline-flex; align-items: center; }
.brand-logo { display: block; height: 28px; width: auto; }
.brand span { font-weight: 400; opacity: 0.85; }
.nav { display: flex; gap: 0.25rem; flex-wrap: wrap; margin-left: auto; }
.navlink { color: rgba(255,255,255,0.85); text-decoration: none; padding: 0.4rem 0.7rem; border-radius: 6px; font-size: 0.95rem; }
.navlink:hover, .navlink.active { background: rgba(255,255,255,0.15); color: white; }
.logout-form { margin: 0; }
.linklike { background: none; border: none; color: rgba(255,255,255,0.75); cursor: pointer; font-size: 0.9rem; padding: 0.4rem 0.5rem; }
.linklike:hover { color: white; }

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

.flash {
  background: #eaf6ee; border: 1px solid #b8e0c4; color: var(--green);
  padding: 0.7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.95rem;
}

h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.75rem 0 0.75rem; }
h3 { font-size: 1rem; margin: 0 0 0.5rem; }
a { color: var(--blue); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}

.grid { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

.stat { display: flex; flex-direction: column; gap: 0.2rem; }
.stat .n { font-size: 1.6rem; font-weight: 700; color: var(--blue); }
.stat .l { color: var(--text-muted); font-size: 0.85rem; }

table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
th, td { text-align: left; padding: 0.55rem 0.5rem; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

.list-link { display: block; padding: 0.85rem 0; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.list-link:last-child { border-bottom: none; }
.list-link:hover { background: #fafbfc; }
.list-title { font-weight: 600; }
.list-sub { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.15rem; }

.badge { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600; }
.badge-progress { background: #fdecd8; color: var(--orange); }
.badge-done { background: #e2f3e8; color: var(--green); }
.badge-suspended { background: #f2e2e2; color: var(--red); }
.badge-potenziale { background: #e3edfb; color: var(--blue); }

form.inline { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: end; }

label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.25rem; color: var(--text-muted); }
input, select, textarea {
  width: 100%; padding: 0.55rem 0.65rem; border: 1px solid var(--border); border-radius: 8px;
  font-size: 0.95rem; font-family: inherit; background: white; color: var(--text);
}
textarea { resize: vertical; min-height: 4.5em; }
.field { margin-bottom: 0.8rem; }
.field-row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 150px; }

/* Suggerimenti di acquisto storico nel form Materiali (richiesto
   esplicitamente il 2026-10-27): elenco cliccabile sotto il campo
   Descrizione, con fornitore e prezzo già visti per quel materiale. */
.suggerimenti-lista {
  position: absolute; z-index: 20; top: 100%; left: 0; right: 0; margin-top: 2px;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.12); max-height: 230px; overflow-y: auto;
}
.suggerimento-voce { padding: 0.5rem 0.7rem; cursor: pointer; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.suggerimento-voce:last-child { border-bottom: none; }
.suggerimento-voce:hover { background: var(--bg); }
.suggerimento-dettaglio { color: var(--text-muted); font-size: 0.82rem; margin-top: 0.1rem; }

button, .btn {
  display: inline-block; background: var(--blue); color: white; border: none;
  padding: 0.6rem 1.1rem; border-radius: 8px; font-size: 0.95rem; font-weight: 600;
  cursor: pointer; text-decoration: none; text-align: center;
}
button:hover, .btn:hover { background: var(--blue-dark); }
.btn-secondary { background: white; color: var(--blue); border: 1px solid var(--blue); }
.btn-secondary:hover { background: #eef3f8; }
.btn-danger { background: white; color: var(--red); border: 1px solid var(--red); }
.btn-danger:hover { background: #fbeceb; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.85rem; }

.auth-wrap { max-width: 380px; margin: 3rem auto; }
.auth-wrap h1 { text-align: center; }
.auth-hint { color: var(--text-muted); font-size: 0.85rem; text-align: center; margin-top: 1rem; }

.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin: 1.25rem 0 1rem; flex-wrap: wrap; }
.tab { padding: 0.55rem 0.9rem; text-decoration: none; color: var(--text-muted); font-size: 0.9rem; font-weight: 600; border-bottom: 2px solid transparent; }
.tab.active { color: var(--blue); border-color: var(--blue); }

.empty { color: var(--text-muted); font-size: 0.9rem; padding: 1rem 0; }

.gantt-wrap { overflow-x: auto; }
.gantt { border-collapse: collapse; font-size: 0.82rem; }
.gantt th { position: sticky; top: 0; background: var(--card); }
.gantt-bar { height: 1.4rem; border-radius: 4px; background: var(--blue); position: relative; }
.gantt-bar-fill { height: 100%; border-radius: 4px; background: var(--orange); }
.gantt-row-label { white-space: nowrap; padding-right: 0.75rem; font-weight: 600; }

.actions-row { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }

.top-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 0.5rem; }

.muted { color: var(--text-muted); }
.error-text { color: var(--red); font-size: 0.85rem; margin-top: 0.4rem; }

/* Calendario (sezione Anno corrente / Archivio) */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.4rem; margin-bottom: 1.5rem; }
.cal-giorno-label { text-align: center; font-weight: 600; color: var(--text-muted); font-size: 0.8rem; }
.cal-cella {
  display: block; text-decoration: none; color: var(--text); background: var(--card);
  border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem; min-height: 3.4rem;
}
.cal-cella:hover { background: #fafbfc; border-color: var(--blue); }
.cal-cella-num { font-weight: 700; }
.cal-cella.cal-oggi { border: 2px solid var(--blue); }
.cal-cella.cal-vuota { background: transparent; border: none; }
.cal-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-top: 0.3rem; }
.mese-card { display: block; text-decoration: none; color: var(--text); }
.mese-card:hover .card { border-color: var(--blue); }
.doc-item { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.doc-item:last-child { border-bottom: none; }
.doc-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* Paragrafo "ATTENZIONE!" (Report giorno + Panoramica cantiere) */
.box-attenzione {
  background: #fbecef; border: 1px solid var(--rosso-torino); border-radius: var(--radius);
  padding: 1rem 1.1rem; margin-bottom: 1rem;
}
.box-attenzione h3 { color: var(--rosso-torino); margin-top: 0; }
.attenzione-item {
  display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0; border-bottom: 1px solid rgba(122, 31, 48, 0.25);
}
.attenzione-item:last-child { border-bottom: none; }
.attenzione-data { font-size: 0.8rem; font-weight: 600; color: var(--rosso-torino); }
.attenzione-testo { color: var(--rosso-torino); font-weight: 600; }

/* Opere non preventivate nel Report giorno (richiesto il 2026-09-29): testo
   scritto dall'utente mostrato in rosso, per distinguerlo a colpo d'occhio
   dalle opere svolte previste dal preventivo. */
.testo-rosso, .testo-rosso:focus { color: var(--red); }
.resoconto-giorno { border-bottom: 1px solid var(--border); padding: 0.9rem 0; }
.resoconto-giorno:last-child { border-bottom: none; }
.resoconto-data { font-weight: 700; color: var(--blue); margin-bottom: 0.3rem; }
.resoconto-extra { color: var(--red); margin-top: 0.2rem; }

@media (max-width: 640px) {
  .topbar-inner { gap: 0.5rem; }
  .nav { gap: 0; }
  .navlink { padding: 0.35rem 0.5rem; font-size: 0.88rem; }
}

/* Menu laterale a scomparsa per le sezioni secondarie (richiesto
   esplicitamente il 2026-10-14) — stesso elemento <details>/<summary> già
   usato altrove nel gestionale per i toggle senza JavaScript (Decisione
   architetturale 3): chiuso, è solo il bottone agganciato al bordo destro
   dello schermo, centrato in verticale; aperto, <details> stesso diventa
   il pannello (position: fixed, selettore [open]) — nessuno stato nascosto
   da sincronizzare a parte, lo stato è l'attributo "open" nativo. */
.side-menu-wrap {
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  z-index: 30;
}
.side-menu-wrap > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: white;
  border: 1px solid var(--blue);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  padding: 1rem 0.55rem;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: -2px 2px 10px rgba(0,0,0,0.18);
  transition: background 0.15s ease, padding 0.15s ease;
}
.side-menu-wrap > summary::-webkit-details-marker { display: none; }
.side-menu-wrap > summary::marker { content: ''; }
.side-menu-wrap > summary:hover { background: var(--blue-dark); padding-right: 0.8rem; }

.side-menu-panel { display: none; }

.side-menu-wrap[open] {
  top: 0;
  right: 0;
  transform: none;
  width: 280px;
  max-width: 85vw;
  height: 100%;
  background: var(--card);
  border-left: 1px solid var(--border);
  box-shadow: -6px 0 20px rgba(0,0,0,0.18);
  overflow-y: auto;
}
.side-menu-wrap[open] > summary {
  width: 100%;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--border);
  justify-content: flex-start;
  padding: 0.9rem 1rem;
  font-size: 0.95rem;
}
.side-menu-wrap[open] .side-menu-panel { display: block; }

/* Icona ☰ da chiuso, "Altre sezioni ✕" da aperto — un solo <summary>,
   si mostra/nasconde l'uno o l'altro in base all'attributo [open]. */
.side-menu-icon-open { display: none; }
.side-menu-wrap[open] .side-menu-icon-closed { display: none; }
.side-menu-wrap[open] .side-menu-icon-open { display: inline; }

.side-menu-link {
  display: block;
  padding: 0.7rem 1rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--border);
}
.side-menu-link:last-child { border-bottom: none; }
.side-menu-link:hover, .side-menu-link.active { background: var(--bg); color: var(--blue); }

@media (max-width: 640px) {
  .side-menu-wrap > summary { padding: 0.85rem 0.45rem; font-size: 1rem; }
}
