/* Stili ripresi dalla V1 (komanda-dashboard@9a6066ab): token HSL di src/index.css (shadcn), sidebar 16rem
   (components/ui/sidebar.tsx), header h-14, Card «rounded-lg border bg-card shadow-sm», font Tailwind di base. */
:root {
  --background: 0 0% 100%; --foreground: 222.2 84% 4.9%;
  --card: 0 0% 100%; --primary: 222.2 47.4% 11.2%; --primary-foreground: 210 40% 98%;
  --secondary: 210 40% 96.1%; --secondary-foreground: 222.2 47.4% 11.2%;
  --muted: 210 40% 96.1%; --muted-foreground: 215.4 16.3% 46.9%;
  --accent: 210 40% 96.1%; --destructive: 0 84.2% 60.2%;
  --border: 214.3 31.8% 91.4%; --ring: 222.2 84% 4.9%; --radius: .5rem;
  --sidebar-background: 0 0% 98%; --sidebar-foreground: 240 5.3% 26.1%;
  --sidebar-accent: 240 4.8% 95.9%; --sidebar-accent-foreground: 240 5.9% 10%; --sidebar-border: 220 13% 91%;
  --sidebar-width: 16rem; --sidebar-width-icon: 3rem;
}
* { box-sizing: border-box; border-color: hsl(var(--border)); }
html, body { margin: 0; height: 100%; }
body { font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  font-size: 16px; line-height: 1.5; color: hsl(var(--foreground)); background: hsl(var(--background)); }
svg.ic { width: 1rem; height: 1rem; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; }
h1, h2, p { margin: 0; }

.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar { width: var(--sidebar-width); flex-shrink: 0; display: flex; flex-direction: column;
  background: hsl(var(--sidebar-background)); color: hsl(var(--sidebar-foreground));
  border-right: 1px solid hsl(var(--sidebar-border)); position: sticky; top: 0; height: 100vh; transition: width .2s; }
.sb-header { padding: .5rem; border-bottom: 1px solid hsl(var(--sidebar-border)); }
.sb-header .logo { display: block; height: 4rem; width: 100%; object-fit: cover; }
.sb-content { flex: 1; overflow-y: auto; }
.sb-group { padding: .5rem; }
.sb-label { height: 2rem; display: flex; align-items: center; padding: 0 .5rem; font-size: .75rem; font-weight: 500;
  color: hsl(var(--sidebar-foreground) / .7); }
.sb-menu { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .25rem; }
.sb-item { display: flex; align-items: center; gap: .5rem; height: 2rem; padding: .5rem; border-radius: calc(var(--radius) - 2px);
  font-size: .875rem; color: inherit; text-decoration: none; white-space: nowrap; overflow: hidden; }
a.sb-item:hover { background: hsl(var(--sidebar-accent)); }
.sb-item.attivo { background: hsl(var(--sidebar-accent)); color: hsl(var(--sidebar-accent-foreground)); font-weight: 500; }
.sb-item.non-disponibile { color: hsl(var(--muted-foreground) / .75); cursor: not-allowed; }
.sb-footer { padding: .5rem; border-top: 1px solid hsl(var(--sidebar-border)); }
.sb-item.esci { color: hsl(var(--destructive)); border: 0; background: none; font: inherit; font-size: .875rem; width: 100%; cursor: pointer; }
button.sb-item.esci:hover:not(:disabled) { background: hsl(var(--sidebar-accent)); }
button.sb-item.esci:disabled { color: hsl(var(--destructive) / .55); cursor: not-allowed; }
button.sb-item:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; }
a.sb-item:focus-visible, .btn:focus-visible, .btn-icona:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; }
.app.compatta .sidebar { width: var(--sidebar-width-icon); }
.app.compatta .sb-header .logo, .app.compatta .sb-label, .app.compatta .sb-item > span { display: none; }

/* Colonna principale e barra superiore */
.principale { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 3.5rem; border-bottom: 1px solid hsl(var(--border)); background: hsl(var(--background));
  padding: 0 1rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.tb-sinistra, .tb-destra { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.tb-locale { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-icona { width: 2.25rem; height: 2.25rem; display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: hsl(var(--foreground)); border-radius: calc(var(--radius) - 2px); cursor: pointer; }
.btn-icona:hover:not(:disabled) { background: hsl(var(--accent)); }
.btn-icona svg.ic { width: 1.25rem; height: 1.25rem; }
#apri-chiudi-menu svg.ic { width: 1rem; height: 1rem; }
.btn-icona:disabled { color: hsl(var(--muted-foreground) / .45); cursor: not-allowed; }
.pillola { display: inline-flex; align-items: center; gap: .25rem; border-radius: 9999px; padding: .125rem .625rem;
  font-size: .75rem; font-weight: 600; }
.pillola svg.ic { width: .75rem; height: .75rem; }
.pillola.non-disponibile { border: 1px dashed hsl(var(--muted-foreground) / .5); color: hsl(var(--muted-foreground)); font-weight: 500; }
.utente { display: inline-flex; align-items: center; gap: .5rem; padding: 0 .5rem; font-size: .875rem; }
.avatar { width: 1.75rem; height: 1.75rem; border-radius: 9999px; background: hsl(var(--muted)); display: inline-flex;
  align-items: center; justify-content: center; font-size: .75rem; }
.utente-testo { display: flex; flex-direction: column; line-height: 1.15; }
.utente-testo small { font-size: .7rem; color: hsl(var(--muted-foreground)); }

/* Contenuto */
.contenuto { flex: 1; padding: 1.5rem; display: flex; flex-direction: column; gap: 1.5rem; }
.titolo { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem; }
.titolo-azioni { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
.titolo h1 { font-size: 1.5rem; line-height: 2rem; font-weight: 700; }
.sottotitolo { color: hsl(var(--muted-foreground)); }
.griglia { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; }
@media (max-width: 1023px) { .griglia { grid-template-columns: 1fr; } }

.card { border: 1px solid hsl(var(--border)); border-radius: var(--radius); background: hsl(var(--card));
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / .05); padding: 1.5rem; display: flex; flex-direction: column; gap: .75rem; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.card-titolo { display: flex; align-items: center; gap: .75rem; }
.card h2 { font-size: 1.125rem; font-weight: 600; letter-spacing: -.01em; }
.icona-tonda { width: 2.5rem; height: 2.5rem; border-radius: 9999px; background: hsl(var(--muted)); flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; color: hsl(var(--muted-foreground)); }
.icona-tonda svg.ic { width: 1.25rem; height: 1.25rem; }
.valore { font-size: 2.25rem; line-height: 2.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.unita { font-size: 1rem; font-weight: 500; color: hsl(var(--muted-foreground)); }
.periodo, .esito, .stato { font-size: .875rem; color: hsl(var(--muted-foreground)); }
.esito:empty, .periodo:empty, .zero:empty, .non-aggiornato:empty { display: none; }
.non-aggiornato { font-size: .875rem; font-weight: 500; color: hsl(32 95% 35%); }
.card[aria-busy="true"] .valore { opacity: .55; }
.banner-errore { flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap;
  border-color: hsl(var(--destructive) / .5); background: hsl(var(--destructive) / .06); }
.banner-errore h2 { font-size: 1rem; font-weight: 600; color: hsl(var(--destructive)); }
.card-piede:not(:has(:not([hidden]))) { display: none; }
.zero { font-size: .875rem; color: hsl(var(--muted-foreground)); }
.card[data-stato="indisponibile"] .esito, .card[data-stato="errore"] .esito { color: hsl(var(--destructive)); }
.card-piede { display: flex; align-items: center; gap: .75rem; margin-top: auto; }
.stato { min-height: 1.25rem; }

.badge { display: inline-flex; align-items: center; border-radius: 9999px; padding: .125rem .625rem; font-size: .75rem;
  font-weight: 600; white-space: nowrap; }
.badge.secondario { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.badge.contorno { border: 1px solid hsl(var(--border)); color: hsl(var(--muted-foreground)); font-weight: 500; }
.badge.tratteggiato { border: 1px dashed hsl(var(--muted-foreground) / .5); color: hsl(var(--muted-foreground)); font-weight: 500; }

.btn { display: inline-flex; align-items: center; gap: .5rem; height: 2.25rem; padding: 0 .75rem; font: inherit;
  font-size: .875rem; font-weight: 500; border-radius: calc(var(--radius) - 2px); cursor: pointer; }
.btn.contorno { border: 1px solid hsl(var(--border)); background: hsl(var(--background)); color: hsl(var(--foreground)); }
.btn.contorno:hover { background: hsl(var(--accent)); }
.btn[aria-busy="true"] svg.ic { animation: gira 1s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }

/* Riquadri non collegati: si vedono, ma è chiaro che sono vuoti di proposito. */
.card.non-collegato { background: hsl(var(--muted) / .35); border-style: dashed; box-shadow: none; }
.card.non-collegato h2 { color: hsl(var(--muted-foreground)); }
.card.non-collegato .icona-tonda { opacity: .6; }
.nc-testo { font-size: .875rem; color: hsl(var(--muted-foreground)); }

/* Pannelli a tutta larghezza (identità di prova, stato vuoto) */
.pannello h2 { font-size: 1.125rem; font-weight: 600; }
.lista-operatori { display: flex; flex-wrap: wrap; gap: .5rem; }
.btn-testo { border: 0; background: none; padding: 0 .25rem; font: inherit; font-size: .75rem; color: hsl(var(--muted-foreground));
  text-decoration: underline; cursor: pointer; }
.btn-testo:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; }
.app.senza-locale .griglia, .app.senza-locale .titolo .sottotitolo { display: none; }

[hidden] { display: none !important; }

/* Selettore del locale (D05): bottone outline della V1 con la freccia */
.solo-lettori { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.selettore { position: relative; display: inline-flex; }
.selettore select { appearance: none; font: inherit; font-size: .875rem; font-weight: 500; height: 2.5rem;
  padding: 0 2.25rem 0 1rem; border: 1px solid hsl(var(--border)); border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--background)); color: hsl(var(--foreground)); cursor: pointer; max-width: 22rem; }
.selettore select:hover { background: hsl(var(--accent)); }
.selettore select:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; }
.selettore::after { content: ""; position: absolute; right: .9rem; top: 50%; width: .45rem; height: .45rem; margin-top: -.35rem;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); pointer-events: none; }
.avviso { margin-top: .25rem; font-size: .875rem; color: hsl(var(--warning, 38 92% 50%)); color: hsl(32 95% 35%); }
.app.con-selettore .tb-locale { display: none; }

/* Login Neon Auth */
.form-login { display: grid; gap: .5rem; max-width: 22rem; }
.form-login label { font-size: .875rem; font-weight: 500; }
.form-login input { font: inherit; height: 2.5rem; padding: 0 .75rem; border: 1px solid hsl(var(--border)); border-radius: calc(var(--radius) - 2px); }
.form-login input:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 1px; }
.errore-login { font-size: .875rem; color: hsl(var(--destructive)); }
.btn.primario { border: 0; background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); justify-content: center; margin-top: .25rem; }
.btn.primario:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; }
