/* Struttura comune delle pagine dell'intranet (vedi js/layout.js): barra in alto, menu laterale, contenuto, colonna
   di destra facoltativa (.app-layout-board), finestre "Le mie app" e "Profilo utente", assistenza IT. Colori ripresi
   dal logo Agrimontana. */
:root {
  --app-brand: #8c4f2f;
  --app-brand-dark: #5b301c;
  --app-brand-soft: #f5ebe3;
  --app-bg: #f5f3f0;
  --app-border: #ebe4de;
  --app-text: #2f241e;
  --app-text-muted: #7d6e65;
  --app-header-height: 68px;
  --app-gap: 1.5rem;
  --app-radius: 1rem;
  --app-shadow: 0 1px 3px rgba(47, 36, 30, .06), 0 1px 2px rgba(47, 36, 30, .04);
}

body.app {
  min-height: 100vh;
  background: var(--app-bg);
  color: var(--app-text);
}

/* Icone colorate delle applicazioni (tone del catalogo). */
.app-icon {
  display: inline-grid;
  flex-shrink: 0;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: .6rem;
  font-size: 1rem;
}

.app-icon-sm {
  width: 26px;
  height: 26px;
  border-radius: .5rem;
  font-size: .85rem;
}

.app-icon-lg {
  width: 44px;
  height: 44px;
  border-radius: .8rem;
  font-size: 1.3rem;
}

.tone-brand { background: var(--app-brand-soft); color: var(--app-brand); }
.tone-blue { background: #e7f0fd; color: #1f6feb; }
.tone-green { background: #e6f4ea; color: #1e7e34; }
.tone-orange { background: #fff1e0; color: #c25e00; }
.tone-purple { background: #f0eafb; color: #6f42c1; }
.tone-teal { background: #e3f5f3; color: #138078; }
.tone-red { background: #fdeaea; color: #c62828; }

.btn-brand {
  --bs-btn-bg: var(--app-brand);
  --bs-btn-border-color: var(--app-brand);
  --bs-btn-color: #fff;
  --bs-btn-hover-bg: var(--app-brand-dark);
  --bs-btn-hover-border-color: var(--app-brand-dark);
  --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: var(--app-brand-dark);
  --bs-btn-active-border-color: var(--app-brand-dark);
  --bs-btn-active-color: #fff;
  --bs-btn-disabled-bg: var(--app-brand);
  --bs-btn-disabled-border-color: var(--app-brand);
}

/* Barra in alto. Il contenitore resta alto quanto la barra anche prima che js/layout.js ci disegni lo scheletro. */
#app-header:empty {
  min-height: var(--app-header-height);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 1030;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: var(--app-header-height);
  padding: .5rem 1rem;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--app-border);
  backdrop-filter: blur(8px);
}

@media (min-width: 992px) {
  .app-header {
    padding: .5rem var(--app-gap);
  }
}

/* Loghi Agrimontana e AgriCacao affiancati, separati da un filetto. */
.app-header-brand {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: .75rem;
}

.app-header-brand .app-logo + .app-logo {
  padding-left: .75rem;
  border-left: 1px solid var(--app-border);
  box-sizing: content-box;
}

/* width/height dell'img (header.hbs) danno le proporzioni prima che l'immagine arrivi: la barra non si sposta al
   caricamento dei loghi e il trattino (.app-header-indicator) resta sotto la scheda. */
.app-logo {
  width: auto;
  height: 38px;
}

.app-icon-button {
  padding: .1rem .4rem;
  font-size: 1.5rem;
  line-height: 1;
}

/* Bottoni propri della pagina (templates/layout/header.hbs, vedi renderHeaderNav in js/layout.js): occupano lo spazio
   fra i loghi e il profilo, ms-auto porta un gruppo a destra. Alto quanto la barra, cosi' le schede
   (.app-header-tabs) arrivano fino al bordo inferiore; i bottoni restano centrati. */
.app-header-nav {
  display: flex;
  flex: 1 1 auto;
  align-self: stretch;
  align-items: center;
  gap: .35rem;
  min-width: 0;
}

.app-header-apps {
  align-items: center;
  gap: .25rem;
  min-width: 0;
}

/* Schede fra le pagine di un'applicazione (es. Qualita'): alte quanto la barra (il margine negativo annulla il
   padding verticale di .app-header), con icona e nome in una pillola che al passaggio del mouse prende lo sfondo come
   i bottoni della home. La pagina corrente e' nel colore del logo, sottolineata da .app-header-indicator. */
.app-header-tabs {
  display: none;
  align-self: stretch;
  min-width: 0;
  margin-block: -.5rem;
}

/* Le schede con le icone stanno nella barra da 1600px; sotto, un menu a tendina con la pagina corrente. */
@media (min-width: 1600px) {
  .app-header-tabs {
    display: flex;
  }

  .app-header-tabs-menu {
    display: none;
  }
}

/* Divisore verticale prima di una scheda (divider nelle pagine di templates/layout/header-nav.hbs). */
.app-header-divider {
  align-self: center;
  width: 1px;
  height: 1.5rem;
  margin-inline: .35rem;
  background: var(--app-border);
}

/* Menu di schede raggruppate (launchers di templates/layout/header-nav.hbs), aperto come il lanciatore delle app
   Microsoft della home: il bottone resta centrato nella fascia delle schede e prende il colore del logo e il trattino
   (.app-header-indicator) quando la pagina corrente e' fra le sue. */
.app-header-tabs-launcher {
  display: flex;
  align-items: center;
}

.app-header-nav .app-header-button.active {
  color: var(--app-brand);
}

.app-header-link {
  display: flex;
  align-items: center;
  padding: 0 .1rem;
  color: var(--app-text-muted);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.app-header-link-body {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .35rem .7rem .35rem .4rem;
  border-radius: 999px;
}

.app-header-link:hover {
  color: var(--app-text);
}

.app-header-link:hover .app-header-link-body {
  background: var(--app-bg);
}

.app-header-link.active {
  color: var(--app-brand);
}

/* Trattino sotto la scheda della pagina corrente: uno solo per la barra (templates/layout/header.hbs), posizionato da
   placeHeaderIndicator in js/layout.js, cosi' cambiando pagina scorre fino alla nuova scheda. */
.app-header-indicator {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--app-brand);
  opacity: 0;
  pointer-events: none;
  transition: transform .3s ease, width .3s ease, opacity .2s;
}

.app-header-indicator.visible {
  opacity: 1;
}

.app-header-indicator.instant {
  transition: none;
}

/* Voci dei menu nella barra in stampatello maiuscolo; il profilo utente e' fuori da .app-header-nav. */
.app-header-nav .app-header-app,
.app-header-nav .app-header-button,
.app-header-link {
  font-size: .75rem;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.app-header-menu .dropdown-item.active {
  background: var(--app-brand-soft);
  color: var(--app-brand);
}

.app-header-app {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .35rem .7rem .35rem .4rem;
  border-radius: 999px;
  color: var(--app-text);
  font-size: .875rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.app-header-app:hover,
.app-header-button:hover,
.app-header-button[aria-expanded="true"],
.app-user:hover {
  background: var(--app-bg);
  color: var(--app-text);
}

.app-header-button {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .45rem .8rem;
  border: 0;
  border-radius: 999px;
  color: var(--app-text);
  font-size: .875rem;
  font-weight: 500;
}

.app-header-button > .bi {
  color: var(--app-brand);
  font-size: 1.1rem;
}

.app-header-menu .dropdown-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .45rem 1rem;
}

.app-header-end {
  display: flex;
  align-items: center;
  gap: .35rem;
  margin-left: auto;
}

.app-launcher {
  width: 380px;
  padding: 1rem;
  border: 0;
  border-radius: var(--app-radius);
  box-shadow: 0 12px 32px rgba(47, 36, 30, .18);
}

.app-launcher-title {
  margin-bottom: .5rem;
  color: var(--app-text-muted);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.app-launcher-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .25rem;
}

.app-launcher-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  padding: .75rem .25rem;
  border-radius: .8rem;
  color: var(--app-text);
  font-size: .8rem;
  text-align: center;
  text-decoration: none;
}

.app-launcher-item:hover {
  background: var(--app-bg);
  color: var(--app-text);
}

.app-launcher-item.active {
  background: var(--app-brand-soft);
  color: var(--app-brand);
}

/* Lanciatore con poche voci: largo quanto le sue voci, tutte su una riga. */
.app-launcher-auto {
  width: auto;
}

.app-launcher-auto .app-launcher-grid {
  grid-auto-columns: 5.5rem;
  grid-auto-flow: column;
  grid-template-columns: none;
}

/* Bottone Aggiorna (vedi setPageRefresh in js/layout.js): l'icona gira finche' la pagina rilegge i dati. */
.app-header-refresh.refreshing > .bi {
  display: inline-block;
  animation: app-header-refresh-spin .8s linear infinite;
}

@keyframes app-header-refresh-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Segnaposto dell'utente nello scheletro della barra (vedi renderHeaderSkeleton in js/layout.js), finche' l'accesso
   non e' completato: alto come l'avatar cosi' la barra non cambia altezza. */
.app-header-loading {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
}

.app-user {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .25rem .75rem .25rem .25rem;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--app-text);
  font-weight: 600;
}

.app-user-text {
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
}

.app-user-name {
  font-size: .9rem;
  white-space: nowrap;
}

/* Riga facoltativa sotto il nome: il ruolo piu' alto dell'utente nell'applicazione (vedi setHeaderDetail in js/layout.js). */
.app-user-detail {
  color: var(--app-text-muted);
  font-size: .75rem;
  font-weight: 400;
  white-space: nowrap;
}

.app-avatar {
  display: inline-grid;
  flex-shrink: 0;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--app-brand) 0%, var(--app-brand-dark) 100%);
  color: #fff;
  font-size: .8rem;
  font-weight: 600;
}

.app-avatar-lg {
  width: 56px;
  height: 56px;
  font-size: 1.1rem;
}

/* Griglia della pagina: sotto lg solo il contenuto (il menu e' un pannello a scomparsa), da lg menu + contenuto, da
   xl anche la colonna di destra; fra lg e xl la colonna di destra scende sotto il contenuto. */
.app-layout {
  padding: 1rem;
}

.app-main {
  min-width: 0;
  container-type: inline-size;
}

@media (min-width: 992px) {
  .app-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: var(--app-gap);
    align-items: start;
    padding: var(--app-gap);
  }

  .app-sidebar {
    position: sticky;
    top: calc(var(--app-header-height) + var(--app-gap));
    max-height: calc(100vh - var(--app-header-height) - 2 * var(--app-gap));
    overflow-y: auto;
  }

  .app-menu {
    padding: .75rem;
    background: #fff;
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
  }

  .app-layout-board .app-board {
    grid-column: 2;
  }
}

@media (min-width: 1200px) {
  .app-layout-board {
    grid-template-columns: 260px minmax(0, 1fr) 320px;
  }

  .app-layout-board .app-board {
    grid-column: 3;
    position: sticky;
    top: calc(var(--app-header-height) + var(--app-gap));
  }
}

/* Menu laterale creato dal click sul logo fuori dalla home (drawer overlay, non colonna sticky). */
#app-menu.app-menu-overlay {
  top: 0;
  height: 100%;
  z-index: 1045;
}

#app-menu .app-menu-back {
  display: inline-flex;
  align-items: center;
  padding: 0;
  border: 0;
  color: inherit;
  line-height: 1;
  font-size: 1.35rem;
  text-decoration: none;
}

#app-menu .app-menu-back:hover,
#app-menu .app-menu-back:focus-visible {
  color: var(--app-brand);
}

/* Sulla home a desktop la colonna e' sempre visibile: niente freccia/chiudi del drawer. */
@media (min-width: 992px) {
  .offcanvas-lg.app-sidebar > .offcanvas-header {
    display: none;
  }
}

/* Menu laterale */
.app-menu {
  width: 100%;
}

.app-menu-toggle {
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
  padding: .55rem .75rem;
  border: 0;
  border-radius: .6rem;
  background: none;
  color: var(--app-text);
  font-weight: 500;
  text-align: left;
  text-decoration: none;
}

.app-menu-toggle:hover {
  background: var(--app-brand-soft);
}

.app-menu-toggle > .bi:first-child {
  width: 1.25rem;
  color: var(--app-brand);
  font-size: 1.1rem;
}

/* E-commerce, in evidenza in cima al menu laterale al posto della Home (c'e' gia' il logo): si apre in una nuova scheda. */
.app-menu-shop {
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
  padding: .7rem .85rem;
  border-radius: .75rem;
  background: linear-gradient(135deg, var(--app-brand) 0%, var(--app-brand-dark) 100%);
  box-shadow: 0 4px 12px rgba(91, 48, 28, .25);
  color: #fff;
  text-decoration: none;
  transition: transform .15s, box-shadow .15s;
}

.app-menu-shop:hover,
.app-menu-shop:focus-visible {
  color: #fff;
  box-shadow: 0 6px 18px rgba(91, 48, 28, .35);
  transform: translateY(-1px);
}

.app-menu-shop-icon {
  display: inline-grid;
  flex-shrink: 0;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: .6rem;
  background: rgba(255, 255, 255, .18);
  font-size: 1.15rem;
}

.app-menu-shop-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.app-menu-shop-title {
  font-weight: 600;
}

.app-menu-shop-url {
  font-size: .78rem;
  opacity: .8;
}

.app-menu-shop-external {
  margin-left: auto;
  font-size: .85rem;
  opacity: .8;
}

.app-menu-chevron {
  margin-left: auto;
  color: var(--app-text-muted);
  font-size: .75rem;
  transition: transform .2s;
}

.app-menu-toggle:not(.collapsed) .app-menu-chevron {
  transform: rotate(180deg);
}

.app-menu-links {
  margin: 0 0 .35rem 1.35rem;
  padding: 0 0 0 .75rem;
  border-left: 1px solid var(--app-border);
  list-style: none;
}

.app-menu-links a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .35rem .6rem;
  border-radius: .5rem;
  color: var(--app-text-muted);
  font-size: .925rem;
  text-decoration: none;
}

.app-menu-links a:hover {
  background: var(--app-brand-soft);
  color: var(--app-text);
}

.app-menu-links a.active {
  color: var(--app-brand);
  font-weight: 600;
}

.app-menu-links .bi {
  font-size: .7rem;
  opacity: .6;
}

/* Le mie app, in cima al menu laterale. */
.app-menu-pinned {
  margin: .5rem 0 .75rem;
  padding: .75rem 0;
  border-top: 1px solid var(--app-border);
  border-bottom: 1px solid var(--app-border);
}

.app-menu-pinned-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 .75rem .4rem;
  color: var(--app-text-muted);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.app-menu-customize {
  display: flex;
  align-items: center;
  gap: .3rem;
  padding: .15rem .5rem;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--app-brand);
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.app-menu-customize:hover:not(:disabled) {
  background: var(--app-brand-soft);
}

.app-menu-customize:disabled {
  opacity: .45;
  cursor: default;
}

.app-menu-pinned-links {
  margin: 0;
  padding: 0;
  list-style: none;
}

.app-menu-pinned-links a {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .35rem .75rem;
  border-radius: .6rem;
  color: var(--app-text);
  font-size: .925rem;
  font-weight: 500;
  text-decoration: none;
}

.app-menu-pinned-links a:hover,
.app-menu-pinned-links a.active {
  background: var(--app-brand-soft);
}

.app-menu-note {
  margin: 0;
  padding: .25rem .75rem;
  color: var(--app-text-muted);
  font-size: .85rem;
}

/* Finestra "Le mie app" */
.pinned-editor-heading {
  margin-bottom: .5rem;
  color: var(--app-text-muted);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.pinned-list {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pinned-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .5rem;
  border: 1px solid var(--app-border);
  border-radius: .75rem;
  background: #fff;
}

.pinned-item.dragging {
  opacity: .5;
}

.pinned-item-handle {
  color: var(--app-text-muted);
  cursor: grab;
}

.pinned-item-name {
  flex: 1;
  min-width: 0;
  font-weight: 500;
}

.pinned-item-button {
  --bs-btn-padding-x: .4rem;
  --bs-btn-padding-y: .15rem;
  color: var(--app-text-muted);
}

.pinned-item-button:hover {
  background: var(--app-bg);
}

.pinned-empty {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: 1.25rem;
  border: 1px dashed var(--app-border);
  border-radius: .75rem;
  color: var(--app-text-muted);
}

.pinned-editor-search {
  position: relative;
  margin-bottom: 1rem;
}

.pinned-editor-search > .bi {
  position: absolute;
  top: 50%;
  left: .9rem;
  transform: translateY(-50%);
  color: var(--app-text-muted);
}

.pinned-editor-search .form-control {
  padding-left: 2.4rem;
  border-radius: .75rem;
}

.pinned-catalog-section + .pinned-catalog-section {
  margin-top: 1rem;
}

.pinned-catalog-section-name {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .4rem;
  font-size: .85rem;
  font-weight: 600;
}

.pinned-catalog-section-name > .bi {
  color: var(--app-brand);
}

.pinned-catalog-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .4rem;
}

.pinned-catalog-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .6rem;
  border: 1px solid var(--app-border);
  border-radius: .75rem;
  background: #fff;
  color: var(--app-text);
  font-size: .9rem;
  text-align: left;
}

.pinned-catalog-item:hover {
  border-color: var(--app-brand);
}

.pinned-catalog-item.pinned {
  border-color: var(--app-brand);
  background: var(--app-brand-soft);
}

.pinned-catalog-name {
  flex: 1;
  min-width: 0;
}

.pinned-catalog-pin {
  color: var(--app-text-muted);
}

.pinned-catalog-item.pinned .pinned-catalog-pin {
  color: var(--app-brand);
}

/* Finestra "Profilo utente": a sinistra utente, bottone Esci e sezioni, a destra la sezione scelta e in basso il
   bottone Chiudi. Sotto md la finestra e' a schermo intero e le sezioni scorrono in orizzontale sopra il contenuto. */
.profile {
  flex-direction: row;
  height: min(680px, calc(100vh - 3.5rem));
  overflow: hidden;
}

.profile-sidebar {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: 280px;
  padding: 1.5rem 1rem;
  border-right: 1px solid var(--app-border);
  background: var(--app-bg);
}

.profile-identity {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: 0 .5rem;
}

.profile-name {
  font-size: 1.05rem;
  font-weight: 600;
}

.profile-username {
  color: var(--app-text-muted);
  font-size: .85rem;
}

/* Esci sotto il nome, allineato al testo accanto all'avatar. */
.profile-actions {
  display: flex;
  gap: .5rem;
  align-self: flex-start;
  margin: .6rem 0 0 calc(.5rem + 56px + .85rem);
}

.profile-nav {
  flex-direction: column;
  flex-grow: 1;
  gap: .25rem;
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--app-border);
}

.profile-nav .nav-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .6rem .75rem;
  border-radius: .75rem;
  color: var(--app-text);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

.profile-nav .nav-link .bi {
  color: var(--app-text-muted);
  font-size: 1.1rem;
}

.profile-nav .nav-link:hover {
  background: #fff;
  color: var(--app-text);
}

.profile-nav .nav-link.active {
  background: var(--app-brand-soft);
  color: var(--app-brand-dark);
  font-weight: 600;
}

.profile-nav .nav-link.active .bi {
  color: var(--app-brand);
}

/* Debug in fondo alla colonna delle sezioni, subito sopra il rilascio. */
.profile-nav .profile-nav-bottom {
  margin-top: auto;
}

/* Rilascio dell'ambiente in fondo alla colonna delle sezioni, sotto Debug: apre la sezione Versioni. */
.profile-nav .profile-release {
  display: block;
  color: var(--app-text-muted);
  font-size: .75rem;
  font-weight: 400;
}

.profile-release-version {
  color: var(--app-text);
  font-weight: 600;
}

.profile-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.profile-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.75rem 2rem;
}

.profile-footer {
  display: flex;
  justify-content: flex-end;
  padding: .85rem 2rem;
  border-top: 1px solid var(--app-border);
}

.profile-section-title {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .25rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.profile-section-text {
  margin-bottom: 1.5rem;
  color: var(--app-text-muted);
  font-size: .9rem;
}

@media (max-width: 767.98px) {
  .profile {
    flex-direction: column;
    height: 100%;
  }

  .profile-sidebar {
    width: auto;
    padding: 1rem 1rem 0;
    border-right: 0;
    border-bottom: 1px solid var(--app-border);
  }

  .profile-identity {
    padding: 0;
  }

  .profile-actions {
    margin-left: calc(56px + .85rem);
  }

  .profile-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    margin-top: 1rem;
    padding: 0 0 .75rem;
    border-top: 0;
  }

  .profile-nav .profile-nav-bottom {
    margin-top: 0;
  }

  .profile-content {
    padding: 1.25rem 1rem;
  }

  .profile-nav .profile-release {
    white-space: nowrap;
  }

  .profile-nav .profile-release > :not(:first-child) {
    display: none;
  }

  .profile-footer {
    padding: .75rem 1rem;
  }
}

.profile-heading {
  margin: 1.25rem 0 .5rem;
  color: var(--app-text-muted);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.profile-section-text + .profile-heading {
  margin-top: 0;
}

.profile-badges {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.profile-badge {
  padding: .3rem .7rem;
  border-radius: 999px;
  background: var(--app-brand-soft);
  color: var(--app-brand-dark);
  font-size: .8rem;
  font-weight: 600;
}

.profile-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.profile-list li {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .3rem 0;
}

.profile-list .bi {
  color: var(--app-brand);
}

.profile-group + .profile-group {
  margin-top: .75rem;
}

.profile-group-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: var(--app-text);
  font-size: .9rem;
  font-weight: 600;
}

.profile-group-title .bi {
  color: var(--app-text-muted);
}

.profile-group .profile-list {
  padding-left: 1.5rem;
}

.profile-empty {
  margin: 0;
  color: var(--app-text-muted);
  font-size: .9rem;
}

/* Ruoli e permessi: applicazione con il tag del ruolo (pill, apre il grafo) o dell'abilitazione della vecchia intranet
   (tag di tipo, bordo sinistro), grafo dei ruoli compresi sotto la riga. */
.profile-access-list li {
  flex-wrap: wrap;
}

.profile-access-name {
  flex: 1 1 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.profile-role-tag {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .25em .65em;
  border: 1px solid var(--app-brand);
  border-radius: 50rem;
  background: var(--app-brand-soft);
  color: var(--app-brand-dark);
  font-size: .75rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
}

.profile-role-tag:hover,
.profile-role-tag[aria-expanded="true"] {
  background: var(--app-brand);
  color: #fff;
}

.profile-list .profile-role-tag .bi {
  color: inherit;
}

.profile-grant-tag {
  padding: .2em .6em;
  border: 1px solid var(--app-border);
  border-left: 4px solid var(--app-text-muted);
  border-radius: .5rem;
  background: var(--app-bg);
  color: var(--app-text-muted);
  font-size: .75rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.profile-role-graph {
  flex-basis: 100%;
  margin: .25rem 0 .5rem;
  padding: .6rem .75rem;
  border: 1px solid var(--app-border);
  border-radius: .5rem;
}

.profile-role-tree,
.profile-role-tree ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.profile-role-tree ul {
  margin-left: .75rem;
  padding-left: 1rem;
  border-left: 1px solid var(--app-border);
}

.profile-list .profile-role-tree li {
  display: block;
  position: relative;
  padding: .2rem 0;
}

.profile-role-tree ul > li::before {
  content: '';
  position: absolute;
  top: 1.1rem;
  left: -1rem;
  width: .75rem;
  border-top: 1px solid var(--app-border);
}

.profile-role-node {
  display: inline-flex;
  flex-direction: column;
  padding: .25rem .6rem;
  border: 1px solid var(--app-border);
  border-radius: .4rem;
  background: var(--app-brand-soft);
  color: var(--app-brand-dark);
  font-size: .8rem;
  line-height: 1.25;
}

.profile-role-node small {
  color: var(--app-text-muted);
  font-family: var(--bs-font-monospace);
  font-size: .7rem;
}

.profile-links {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.profile-links a {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem .85rem;
  border: 1px solid var(--app-border);
  border-radius: .75rem;
  color: var(--app-text);
  text-decoration: none;
}

.profile-links a:hover {
  border-color: var(--app-brand);
  background: var(--app-brand-soft);
}

.profile-links a > .bi:first-child {
  color: var(--app-brand);
  font-size: 1.2rem;
}

.profile-links a > span {
  display: flex;
  flex: 1;
  flex-direction: column;
}

.profile-links small {
  color: var(--app-text-muted);
}

.profile-links a > .bi:last-child {
  color: var(--app-text-muted);
  font-size: .75rem;
}

.min-w-0 {
  min-width: 0;
}

/* Notifiche in alto a destra sotto l'intestazione, per lasciare libero l'angolo dell'assistenza IT. */
.app-toasts {
  top: var(--app-header-height);
}

/* Assistenza IT: bottone fisso in basso a destra su tutte le pagine (templates/layout/support.hbs). Al caricamento un
   fumetto con una freccia lo indica e il bottone pulsa, finche' l'utente non chiude il fumetto (js/layout.js). */
.support {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 1040;
}

.support-button {
  display: flex;
  align-items: center;
  gap: .55rem;
  height: 56px;
  padding: 0 1.4rem;
  border: 0;
  border-radius: 999px;
  background: var(--app-brand);
  box-shadow: 0 8px 24px rgba(60, 35, 20, .3);
  color: #fff;
  font-weight: 600;
}

.support-button:hover,
.support-button[aria-expanded="true"] {
  background: var(--app-brand-dark);
}

.support-button:focus-visible {
  outline: 3px solid var(--app-brand-soft);
  outline-offset: 2px;
}

.support-button .bi {
  font-size: 1.4rem;
}

.support-highlight .support-button {
  animation: support-pulse 1.6s ease-out infinite;
}

.support-hint {
  position: absolute;
  right: 0;
  bottom: calc(100% + 3rem);
  width: min(300px, calc(100vw - 3rem));
  padding: 1rem 1.25rem;
  border-radius: var(--app-radius);
  background: var(--app-text);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .25);
  color: #fff;
  animation: support-hint-in .45s ease-out;
}

.support-hint-close,
.tour-close {
  position: absolute;
  top: .75rem;
  right: .75rem;
  font-size: .7rem;
}

.support-hint-title,
.tour-title {
  margin-bottom: .35rem;
  font-weight: 600;
}

.support-hint-text,
.tour-text {
  margin-bottom: .75rem;
  font-size: .9rem;
  opacity: .85;
}

/* Freccia fra il fumetto e il bottone. */
.support-hint-arrow {
  position: absolute;
  top: calc(100% + .35rem);
  right: 2.6rem;
  color: var(--app-brand);
  font-size: 2rem;
  line-height: 1;
  filter: drop-shadow(0 0 3px #fff);
  animation: support-arrow 1s ease-in-out infinite;
}

.support-menu {
  min-width: 290px;
  padding: .5rem;
  border: 0;
  border-radius: .9rem;
  box-shadow: 0 12px 32px rgba(47, 36, 30, .18);
}

.support-link {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .6rem .75rem;
  border-radius: .6rem;
  white-space: normal;
}

.support-link > .bi {
  color: var(--app-brand);
  font-size: 1.25rem;
}

/* Applicazione del catalogo aperta sopra la pagina in un iframe (templates/layout/embedded.hbs), es. il form Monday dei ticket. */
.embedded-body {
  padding: 0;
}

.embedded-frame {
  display: block;
  width: 100%;
  height: min(80vh, 760px);
  border: 0;
  border-radius: 0 0 var(--bs-modal-inner-border-radius) var(--bs-modal-inner-border-radius);
}

/* Scelta fra riprendere il modulo lasciato aperto e ricominciare: copre l'iframe, che resta caricato sotto. */
.embedded-resume:not([hidden]) {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  border-radius: 0 0 var(--bs-modal-inner-border-radius) var(--bs-modal-inner-border-radius);
  background: var(--bs-modal-bg);
  text-align: center;
}

.embedded-resume-icon {
  margin-bottom: .75rem;
  color: var(--app-brand);
  font-size: 2.5rem;
}

.embedded-resume-title {
  margin-bottom: .35rem;
  font-size: 1.15rem;
  font-weight: 600;
}

.embedded-resume-text {
  max-width: 420px;
  margin-bottom: 1.25rem;
  color: var(--bs-secondary-color);
}

/* Finestra "I miei ticket" dell'assistenza IT (templates/layout/tickets.hbs, js/tickets.js): schede dei ticket, la
   pagina successiva arriva quando si scorre fino alla riga invisibile .tickets-sentinel. */
.tickets-body {
  min-height: min(60vh, 480px);
  background: var(--app-bg);
}

.tickets-list {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.ticket-card {
  padding: 1rem 1.25rem;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: #fff;
  box-shadow: var(--app-shadow);
}

.ticket-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
}

.ticket-title {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.ticket-status {
  flex-shrink: 0;
  font-weight: 600;
}

.ticket-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem 1rem;
  margin-top: .35rem;
  color: var(--app-text-muted);
  font-size: .85rem;
}

.ticket-meta .bi {
  margin-right: .3rem;
}

/* Descrizione ridotta a tre righe; un clic la mostra per intera. */
.ticket-description {
  display: -webkit-box;
  margin: .6rem 0 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  white-space: pre-line;
  overflow-wrap: anywhere;
  font-size: .9rem;
  cursor: pointer;
}

.ticket-description.expanded {
  display: block;
  overflow: visible;
  -webkit-line-clamp: unset;
}

.tickets-sentinel {
  height: 1px;
}

.tickets-state {
  padding: 1.25rem 0 .5rem;
  color: var(--app-text-muted);
  text-align: center;
}

.tickets-empty {
  padding-top: 3rem;
}

.tickets-empty-icon {
  display: block;
  margin-bottom: .5rem;
  color: var(--app-brand);
  font-size: 2.5rem;
}

@media (max-width: 767.98px) {
  .embedded-resume:not([hidden]) {
    border-radius: 0;
  }

  .embedded-frame {
    height: 100%;
    border-radius: 0;
  }
}

@media (max-width: 575.98px) {
  .support {
    right: 1rem;
    bottom: 1rem;
  }

  .support-button {
    justify-content: center;
    width: 56px;
    padding: 0;
  }

  .support-button-label {
    display: none;
  }

  .support-hint-arrow {
    right: .9rem;
  }
}

@keyframes support-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(140, 79, 47, .55), 0 8px 24px rgba(60, 35, 20, .3);
  }

  100% {
    box-shadow: 0 0 0 18px rgba(140, 79, 47, 0), 0 8px 24px rgba(60, 35, 20, .3);
  }
}

@keyframes support-hint-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes support-arrow {
  0%, 100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(8px);
  }
}

/* Finestra di benvenuto della nuova intranet (templates/layout/welcome.hbs, vedi showWelcome in js/layout.js). */
.welcome {
  overflow: hidden;
  border: 0;
  border-radius: var(--app-radius);
}

.welcome-hero {
  position: relative;
  padding: 2rem 2rem 1.75rem;
  background: linear-gradient(135deg, #f4f0e7, #dfe2d5);
  color: #454a37;
}

.welcome-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
}

.welcome-badge {
  display: inline-block;
  margin-bottom: .75rem;
  padding: .2rem .7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, .7);
  color: #74764f;
  font-size: .8rem;
  font-weight: 600;
}

.welcome-title {
  margin-bottom: 0;
  font-size: 1.75rem;
  font-weight: 700;
}

.welcome-body {
  display: grid;
  gap: 1.25rem;
  padding: 1.75rem 2rem;
}

.welcome-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.welcome-item h3 {
  margin-bottom: .25rem;
  font-size: 1rem;
  font-weight: 600;
}

.welcome-item p {
  margin: 0;
  color: var(--app-text-muted);
}

.welcome-footer {
  padding: 1rem 2rem;
  border-color: var(--app-border);
}

/* Tour delle novita' (templates/layout/tour.hbs e tour-step.hbs, vedi startTour in js/layout.js): sopra a tutto, la
   pagina oscurata tranne l'elemento indicato, con un fumetto e una freccia come quelli dell'assistenza IT. Posizioni
   e dimensioni le calcola placeTourStep. */
.tour {
  position: fixed;
  inset: 0;
  z-index: 1070;
}

.tour-spotlight {
  position: absolute;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .9), 0 0 0 9999px rgba(30, 20, 15, .6);
  pointer-events: none;
  transition: left .3s ease, top .3s ease, width .3s ease, height .3s ease, border-radius .3s ease;
}

.tour-bubble {
  position: absolute;
  width: min(320px, calc(100vw - 24px));
  padding: 1rem 1.25rem;
  border-radius: var(--app-radius);
  background: var(--app-text);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .3);
  color: #fff;
}

.tour-bubble-in {
  animation: support-hint-in .45s ease-out;
}

.tour-footer {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.tour-count {
  margin-right: auto;
  font-size: .8rem;
  opacity: .7;
}

/* Freccia fra il fumetto e l'elemento indicato, che rimbalza verso l'elemento. */
.tour-arrow {
  --tour-arrow-shift: 8px;
  position: absolute;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  animation: tour-arrow 1s ease-in-out infinite;
}

.tour-arrow-up {
  --tour-arrow-shift: -8px;
}

@keyframes tour-arrow {
  0%, 100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(var(--tour-arrow-shift));
  }
}

@media (prefers-reduced-motion: reduce) {
  .support-highlight .support-button,
  .support-hint,
  .support-hint-arrow,
  .tour-bubble-in,
  .tour-arrow {
    animation: none;
  }

  .app-header-indicator,
  .tour-spotlight {
    transition: none;
  }
}

/* Switch "Mostra tutte le app" della finestra "Le mie app". */
.pinned-editor-switch {
  margin-top: 1.25rem;
}

.pinned-editor-switch .form-check-input:checked {
  border-color: var(--app-brand);
  background-color: var(--app-brand);
}

.pinned-editor-switch .form-check-input:focus {
  border-color: var(--app-brand);
  box-shadow: 0 0 0 .25rem rgba(140, 79, 47, .2);
}

/* Sezione "Debug" della finestra "Profilo utente": lettore NFC e token. */
/* Blocchi della sezione Debug (Ripristina dati del browser, Lettore NFC, Token), separati da una linea. */
.profile-debug-block + .profile-debug-block {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--app-border);
}

.profile-debug-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: 0 0 .5rem;
  font-size: .95rem;
  font-weight: 600;
}

.profile-nfc-status {
  padding: .1rem .5rem;
  border: 1px solid var(--bs-danger-border-subtle);
  border-radius: 999px;
  background: var(--bs-danger-bg-subtle);
  color: var(--bs-danger-text-emphasis);
  font-size: .75rem;
  font-weight: 500;
}

.profile-nfc-status.connected {
  border-color: var(--bs-success-border-subtle);
  background: var(--bs-success-bg-subtle);
  color: var(--bs-success-text-emphasis);
}

.profile-nfc-status.warning {
  border-color: var(--bs-warning-border-subtle);
  background: var(--bs-warning-bg-subtle);
  color: var(--bs-warning-text-emphasis);
}

.profile-setting > [data-nfc-simulator] {
  flex: 0 0 auto;
  width: 22rem;
  max-width: 55%;
}

.profile-token-expiry {
  padding: .1rem .5rem;
  border-radius: 999px;
  background: #e6f4ea;
  color: #1e7e34;
  font-size: .75rem;
  font-weight: 500;
}

.profile-token-expiry.expired {
  background: #fdeaea;
  color: #c62828;
}

.profile-token {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: .35rem 1rem;
  margin-bottom: .75rem;
  font-size: .85rem;
}

.profile-token dt {
  color: var(--app-text-muted);
  font-weight: 500;
}

.profile-token dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.profile-versions-table {
  min-width: 36rem;
  table-layout: fixed;
  font-size: .85rem;
}

.profile-versions-table td {
  overflow-wrap: anywhere;
}

/* Impostazioni del profilo: descrizione a sinistra, controllo a destra. */
.profile-setting {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .85rem 1rem;
  border: 1px solid var(--app-border);
  border-radius: .75rem;
}

.profile-setting + .profile-setting {
  margin-top: 1rem;
}

.profile-setting > span {
  flex: 1;
  min-width: 0;
}

.profile-setting strong,
.profile-setting small {
  display: block;
}

.profile-setting small {
  color: var(--app-text-muted);
}

.profile-setting-select {
  flex: 0 0 auto;
  width: 10.5rem;
  max-width: 42%;
}

.profile-setting-confirm {
  width: 280px;
}

.profile-versions-detail {
  margin-top: .25rem;
  color: var(--app-text-muted);
  font-size: .75rem;
}

/* Filigrana ambiente non-production (staging/dev/local): stile "documento in bozza", non intercetta i click. */
.env-draft-mark {
  position: fixed;
  inset: -20vh -20vw;
  z-index: 1080;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(4, 1fr);
  place-items: center;
  gap: 8vh 6vw;
  pointer-events: none;
  transform: rotate(-28deg);
  user-select: none;
  overflow: hidden;
}

.env-draft-mark span {
  font-size: clamp(2.2rem, 6vw, 4.6rem);
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: rgba(140, 79, 47, .18);
  white-space: nowrap;
  line-height: 1;
}

/* Schermo bloccato delle postazioni con un utente generico, finche' non si appoggia un badge al lettore NFC (vedi
   renderWorkstationLock in js/layout.js): sopra a tutto, finestre comprese. */
.workstation-lock {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(255, 255, 255, .97);
}

.workstation-lock-panel {
  max-width: 34rem;
  text-align: center;
}

.workstation-lock-icon {
  font-size: 4.5rem;
  color: var(--app-brand);
}

.workstation-lock-title {
  margin: .75rem 0 .5rem;
  font-size: 1.6rem;
  font-weight: 600;
}

.workstation-lock-text {
  color: var(--app-text-muted);
}

.workstation-lock-status {
  font-weight: 500;
}

.workstation-lock-reader {
  display: inline-flex;
  align-items: center;
  padding: .25rem .75rem;
  border: 1px solid var(--bs-danger-border-subtle);
  border-radius: 999px;
  background: var(--bs-danger-bg-subtle);
  color: var(--bs-danger-text-emphasis);
  font-size: .85rem;
}

.workstation-lock-reader.connected {
  border-color: var(--bs-success-border-subtle);
  background: var(--bs-success-bg-subtle);
  color: var(--bs-success-text-emphasis);
}

/* Bottone del badge nella barra in alto delle pagine con il lettore NFC (vedi renderNfcIndicator in js/layout.js): verde
   con il lettore collegato, rosso senza lettore fuori da production. */
.app-nfc-button.connected {
  color: var(--bs-success);
}

.app-nfc-button.offline {
  color: var(--bs-danger);
}

.nfc-simulator {
  margin-bottom: .75rem;
  padding: .5rem;
  border: 1px dashed var(--bs-border-color);
  border-radius: .5rem;
  text-align: left;
}

.nfc-simulator-title {
  margin-bottom: .35rem;
  font-size: .8rem;
  font-weight: 500;
}

.workstation-lock-simulator {
  max-width: 24rem;
  margin: 1.5rem auto 0;
}
