/* ============================================================
   Resource Planner — Stylesheet
   ============================================================ */

:root {
  --bg: #f7f6f2;
  --surface: #f9f8f5;
  --surface-2: #fbfbf9;
  --surface-3: #f3f0ec;
  --border: #d4d1ca;
  --divider: #dcd9d5;
  --text: #28251d;
  --muted: #7a7974;
  --faint: #bab9b4;
  --primary: #208edd;
  --primary-soft: #dceefb;
  --success: #437a22;
  --warning: #964219;
  --danger: #a12c7b;
  --info: #006494;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow: 0 8px 24px rgba(32, 27, 24, 0.12);
  --row-header-width: 240px;
  --day-col-width: 180px;
  --gantt-col-width: 88px;
  --cell-height: 82px;
  --col-header-h: 52px;
  --footer-height: 60px;
  --font: 'Satoshi', Inter, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

body {
  padding: 24px;
  box-sizing: border-box;
  overflow: hidden; /* scrolling è interno a .planner-scroll */
}

/* ── Layout ── */
.page {
  display: grid;
  gap: 8px;
  height: 100%;
  grid-template-rows: auto auto 1fr;
}

.intro,
.notes,
.toolbar {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
}

.intro {
  padding: 5px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
}

.app-logo {
  height: 34px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}

.app-title {
  margin: 0;
  font-size: 17px;
  flex: 1;
}

.intro h1 {
  margin: 0;
  font-size: 17px;
}

.hide-empty-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  padding: 0 4px;
}

.hide-empty-toggle input[type="checkbox"] {
  width: 13px;
  height: 13px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* ── Toolbar ── */
.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 7px 12px;
}

.toolbar button,
.toolbar select {
  height: 30px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 0 10px;
  font: inherit;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.toolbar .primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.toolbar .legend {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
}

/* ── Toolbar actions (save + print, pushed to the right) ── */
.toolbar-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.toolbar-actions button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.toolbar-actions button svg {
  flex-shrink: 0;
}

/* ── File (Salva/Carica) Button states ── */
#fileBtn {
  font-weight: 500;
}

#fileBtn.dirty {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
  animation: savePulse 2s ease-in-out infinite;
}

#fileBtn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

@keyframes savePulse {

  0%,
  100% {
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
  }

  50% {
    box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.35);
  }
}


/* ── Week Navigation ── */
.week-nav {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-2);
}

.week-nav select {
  height: 38px;
  border: none !important;
  border-radius: 0 !important;
  border-left: 1px solid var(--border) !important;
  border-right: 1px solid var(--border) !important;
  background: var(--surface-2);
  color: var(--text);
  padding: 0 8px;
  font: inherit;
  cursor: pointer;
}

.week-nav button {
  height: 38px;
  width: 34px;
  border: none !important;
  border-radius: 0 !important;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  box-shadow: none !important;
}

.week-nav button:hover:not(:disabled) {
  background: var(--primary-soft);
  color: var(--primary);
}

.week-nav button:active:not(:disabled) {
  background: var(--primary);
  color: white;
}

.week-nav button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ── Gantt span control (numero di settimane, solo vista Gantt) ── */
.gantt-span-control {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.gantt-span-control input[type="number"] {
  width: 48px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: center;
  padding: 0 2px;
}

/* ── View Switcher (Tab Bar) ── */
.view-switcher {
  display: flex;
  background: var(--surface-3);
  padding: 4px;
  border-radius: var(--radius-md);
  gap: 4px;
  border: 1px solid var(--border);
}

.view-switcher button {
  border: none !important;
  background: transparent !important;
  padding: 0 20px !important;
  height: 32px !important;
  border-radius: calc(var(--radius-md) - 2px) !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.2s;
}

.view-switcher button.active {
  background: white !important;
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Risorse/Commesse + il loro toggle Timeline: quando attivo, il "pillola"
   bianca si estende a tutto il gruppo (bottone + toggle) invece che al solo
   bottone, così si vede che il toggle appartiene a quella vista. */
.view-group {
  display: flex;
  align-items: center;
  border-radius: calc(var(--radius-md) - 2px);
  transition: background 0.2s, box-shadow 0.2s;
}

.view-group.active {
  background: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.view-group button.active {
  background: transparent !important;
  box-shadow: none !important;
}

/* Toggle "Slot ⟷ Timeline" dentro Risorse/Commesse: sostituisce le due ex-tab
   dedicate, mostrato solo quando la relativa vista (a slot o Timeline) è attiva. */
.mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px 0 6px;
  cursor: pointer;
  user-select: none;
}

.mode-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.mode-switch-track {
  position: relative;
  width: 30px;
  height: 16px;
  background: var(--border);
  border-radius: 999px;
  flex-shrink: 0;
  transition: background 0.15s;
}

.mode-switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s;
}

.mode-switch input:checked ~ .mode-switch-track {
  background: var(--primary);
}

.mode-switch input:checked ~ .mode-switch-track::after {
  transform: translateX(14px);
}

.mode-switch-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.mode-switch input:checked ~ .mode-switch-label {
  color: var(--primary);
}

/* ── Day Selector (Matrix) ── */
.day-selector {
  display: none;
  gap: 8px;
  margin-left: 20px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.day-selector.visible {
  display: flex;
}

.day-btn {
  border: none;
  background: transparent;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
  white-space: nowrap;
}

.day-btn span {
  font-size: 11px;
  opacity: 0.7;
}

.day-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(32, 142, 221, 0.25);
}

.day-btn.active span {
  opacity: 1;
}

/* ── Planner Shell ── */
.planner-shell {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.planner-scroll {
  overflow: auto;
  flex: 1;
  min-height: 0;
  position: relative;
}

.planner-grid {
  display: grid;
  width: 100%;
  /* Un mousedown leggermente fuori bersaglio durante un drag (cella/card/row-header)
     seleziona il testo sottostante invece di avviare il trascinamento: poco
     professionale e fastidioso da "ripulire" con un click a vuoto. La griglia non ha
     testo che serva selezionare (nessun campo libero, solo etichette ed elenco dati). */
  user-select: none;
  -webkit-user-select: none;
}

/* ── Grid Cells ── */
.corner,
.col-header,
.row-header,
.cell {
  border-right: 1px solid var(--divider);
  border-bottom: 1px solid var(--divider);
}

.corner {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 5;
  background: var(--surface-2);
  padding: 8px 14px;
  min-height: var(--col-header-h);
  display: flex;
  flex-direction: column;
  justify-content: end;
  gap: 4px;
}

.col-header {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--surface-2);
  min-height: var(--col-header-h);
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  justify-content: end;
  gap: 4px;
}

.row-header {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--surface);
  min-height: 36px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.row-actions {
  display: flex;
  gap: 4px;
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity 0.2s;
}

.row-header:hover .row-actions {
  opacity: 1;
}

/* Dispositivi senza vero hover (touch): il pulsante non può comparire al
   passaggio del mouse che non esiste, quindi resta sempre visibile. */
@media (hover: none) {
  .row-actions {
    opacity: 1;
  }
}

/* Elementi trascinabili (drag & drop, vedi touch-dnd.js per il bridge touch):
   disabilita i gesti di default del browser (scroll/pan, doppio-tap-zoom) su
   questi elementi, altrimenti su touch il browser interpreterebbe il
   trascinamento come uno scroll della pagina invece che come un drag. */
.slot-card,
.gantt-block-badge,
.tl-bar,
.unassigned-tile {
  touch-action: none;
}

.btn-shift {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  color: var(--primary);
  transition: all 0.2s;
}

.btn-shift:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.corner strong,
.col-header strong,
.row-header strong {
  font-size: 14px;
}

.corner small,
.col-header small,
.row-header small {
  color: var(--muted);
  font-size: 12px;
}

.row-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid transparent;
}

.badge.team {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--muted);
}

.badge.mansione {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1d4ed8;
  font-size: 10px;
}

/* Riga requirements nel modal Gantt */
.req-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 4px;
}
.req-row select, .req-row input[type=text] { flex: 1; min-width: 0; }
.req-row input[type=number] { width: 56px; }

/* Righe assenza risorsa / indisponibilità commessa (modal anagrafica) */
.absence-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--divider);
}
.absence-row:last-of-type { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.absence-row input[type=date],
.absence-row input[type=time] { flex: 0 0 auto; width: 130px; }
.absence-row select { flex: 1 1 150px; min-width: 130px; }
.absence-row input[type=text] { flex: 1 1 140px; min-width: 100px; }
.absence-row .abs-sep { color: var(--muted); }
.absence-row .abs-repeat-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
/* Selettore con [type] per battere in specificità .form-group input (height:42px;
   width:100%), stesso pattern di .mansione-check input[type="checkbox"]. */
.absence-row .abs-repeat-toggle input[type="checkbox"] {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  margin: 0;
}
.absence-row .abs-repeat-options {
  display: none;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--muted);
}
.absence-row .abs-repeat-options input[type=number] { flex: 0 0 auto; width: 48px; }
.absence-row .abs-repeat-options select { flex: 0 0 auto; width: auto; min-width: 0; }
.absence-row .req-remove {
  background: none;
  border: none;
  color: var(--danger, #b85c5c);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  margin-left: auto;
}

/* Checkbox mansioni nel modal Risorsa */
.checkbox-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.mansione-check {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
}
/* Selettore con [type] per battere in specificità .form-group input (height:42px; width:100%),
   che altrimenti vince perché dichiarato dopo a parità di specificità. */
.mansione-check input[type="checkbox"] {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  margin: 0;
}
.req-row .req-remove {
  background: none;
  border: none;
  color: var(--danger, #b85c5c);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
}

.badge.free {
  background: #d4dfcc;
  color: var(--success);
}

.badge.busy {
  background: #ddcfc6;
  color: var(--warning);
}

/* ── Data Cells ── */
.cell {
  min-height: 36px;
  padding: 8px;
  position: relative;
  cursor: pointer;
  background: white;
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: auto;
}

.cell:hover {
  background: #f3f8f7;
}

.cell.selected {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  z-index: 2;
}

.cell.drop-target {
  background: #ecf5f5;
  box-shadow: inset 0 0 0 2px var(--primary);
}

/* Evidenzia, senza inibire, le celle risorsa compatibili col task in trascinamento.
   Un badge a check nell'angolo (non un retino: quello, in questa UI, significa già
   "bloccato/disabilitato" — vedi .locked / .disabled-matrix). Verde pisello saturo +
   anello bianco: resta leggibile e ben visibile anche sopra le card colorate già
   presenti nella cella.
   z-index basso APPOSTA: il .cell che lo porta non è mai sticky, ma durante
   l'auto-scroll può scorrere "sotto" alla riga "Task da assegnare" (sticky,
   z-index 2) o alla row-header (sticky, z-index 3). Un z-index troppo alto qui
   farebbe ridipingere il badge SOPRA lo sfondo di quegli elementi sticky mentre
   la cella reale gli scorre dietro — badge "fantasma" nella riga sbagliata. */
.cell.drag-compatible::after,
.tl-track.drag-compatible::after {
  content: '✓';
  position: absolute;
  top: 3px;
  right: 5px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #7cb342;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35), 0 0 0 2px rgba(255, 255, 255, 0.95);
  pointer-events: none;
  z-index: 1;
}

.cell.blocked-cell {
  background: var(--surface-2);
}

/* Disabled cell in Matrix view */
.cell.disabled-matrix {
  background-image: repeating-linear-gradient(45deg,
      #f5f4f0,
      #f5f4f0 10px,
      #efeeea 10px,
      #efeeea 20px);
  opacity: 0.8;
  cursor: not-allowed !important;
}

/* ── Slot Cards ── */
.slot-card {
  min-height: 24px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  color: white;
  font-size: 12px;
  font-weight: 700;
  user-select: none;
}

.slot-card small {
  color: rgba(255, 255, 255, 0.82);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.slot-card[data-color="primary"] {
  background: var(--primary);
}

.slot-card[data-color="warning"] {
  background: var(--warning);
}

.slot-card[data-color="info"] {
  background: var(--info);
}

.slot-card.dragging {
  opacity: 0.45;
  transform: scale(0.98);
}

/* ── Unassigned task tiles ── */
.unassigned-tile {
  border: 1.5px dashed var(--warning) !important;
  background: rgba(196, 154, 58, 0.13) !important;
  color: var(--warning) !important;
  cursor: grab;
  scroll-snap-align: start;
}
.unassigned-tile:active { cursor: grabbing; }
.unassigned-tile em { font-style: normal; opacity: 0.7; font-size: 11px; }
.unassigned-tile span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Assenza parziale (mattino/pomeriggio/orario) — vista Risorse/Matrice: stesso
   retino diagonale di .blocked-label/.blocked, ma non a piena cella perché il
   resto della giornata può comunque avere attività assegnate. */
.absence-chip {
  border: 1px dashed var(--border) !important;
  background: repeating-linear-gradient(135deg, var(--surface-3), var(--surface-3) 8px, #e6e4df 8px, #e6e4df 16px) !important;
  color: var(--muted) !important;
  cursor: default !important;
  font-size: 11px;
}

.unassigned-slot-card {
  border: 1.5px dashed #b85c5c;
  background: rgba(184, 92, 92, 0.13) !important;
  color: #e07070 !important;
  cursor: default;
}

.assign-btn {
  margin-left: auto;
  flex-shrink: 0;
  background: var(--accent, #3a6fb0);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
}
.assign-btn:hover { opacity: 0.85; }

.unassigned-row-header {
  position: sticky;
  top: var(--col-header-h);
  z-index: 4;
  background: var(--surface-2);
  border-bottom: 2px solid var(--divider);
  display: flex;
  align-items: center;
  padding: 0 12px;
  max-height: 130px;
}
.unassigned-row-label {
  font-style: italic;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.unassigned-row-cell {
  position: sticky;
  top: var(--col-header-h);
  z-index: 2;
  background: var(--surface-2);
  border-bottom: 2px solid var(--divider);
  min-height: 36px;
  max-height: 130px;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
}

/* Toggle per collassare/riaprire la riga "Task da assegnare" (slot e Timeline):
   tutto il bottone (icona + scritta) è l'area cliccabile, non solo l'icona. */
.unassigned-row-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 4px;
  text-align: left;
}
.unassigned-row-toggle-icon {
  font-size: 17px;
  line-height: 1;
  color: var(--muted);
  flex-shrink: 0;
}
.unassigned-row-toggle:hover .unassigned-row-toggle-icon,
.unassigned-row-toggle:hover .unassigned-row-label {
  color: var(--text);
}

.unassigned-row-header.collapsed,
.unassigned-row-cell.collapsed {
  min-height: 0;
  max-height: 28px;
  overflow: hidden;
}

/* ── Gantt Specific Styles ── */
.cell.gantt-mode {
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
    padding-left: 6px;
    padding-right: 6px;
}

/* Un rettangolo per blocco orario, impilati verticalmente: la cella/riga cresce
   già in altezza da sola (.cell base è flex-direction:column, height:auto, nessun
   max-height), nessun'altra modifica di layout necessaria.
   padding-bottom: lascia sempre un minimo di sfondo cliccabile sotto l'ultimo
   rettangolo, anche quando la cella è piena di attività, per poterne aggiungere
   un'altra senza dover scovare un pixel libero. */
.gantt-blocks-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    padding-bottom: 10px;
}

.gantt-block-badge {
    background: var(--primary);
    color: white;
    border-radius: 6px;
    padding: 4px 6px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    font-size: 12px;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(32, 142, 221, 0.3);
    position: relative;
    cursor: grab;
}

.gantt-block-count { font-size: 14px; line-height: 1.1; }
.gantt-block-time  { font-size: 10px; font-weight: 500; opacity: 0.85; white-space: nowrap; line-height: 1.1; }

.cell.locked {
    background: var(--surface-3) !important;
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(0, 0, 0, 0.05) 10px,
        rgba(0, 0, 0, 0.05) 20px
    ) !important;
    cursor: not-allowed !important;
    position: relative;
    overflow: hidden;
}

/* Il badge ha un proprio cursor: grab che altrimenti vince su quello (not-allowed)
   della cella — un'attività passata non è più né trascinabile né editabile
   (vedi renderGanttCell in app.js), il cursore deve dirlo. */
.cell.locked .gantt-block-badge {
    cursor: not-allowed;
}

/* ── Celle/intestazioni di date passate ── */
.cell.past-cell {
    opacity: 0.52;
    cursor: default;
    filter: saturate(0.45) brightness(0.82);
}
/* Past + bloccata (risorsa assente, cantiere chiuso): le strisce rimangono visibili
   sotto il filtro — aspetto diverso da una futura bloccata (piena opacità, strisce vivide) */
.cell.past-cell.locked {
    cursor: default;
}
/* In cella passata le card non sono interactive: nessun cursore grab */
.cell.past-cell .slot-card {
    cursor: default;
}
/* Intestazioni colonne di date passate */
.col-header.past-header {
    opacity: 0.52;
    filter: saturate(0.45) brightness(0.82);
}
/* Angolo della griglia quando la giornata Matrix è passata */
.corner.past-corner {
    opacity: 0.7;
    position: relative;
}
.corner.past-corner::after {
    content: 'solo lettura';
    position: absolute;
    bottom: 4px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 10px;
    color: var(--muted);
    font-style: italic;
    letter-spacing: 0.03em;
}

.blocked-label {
    color: var(--danger);
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    width: 100%;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.6);
    padding: 2px 0;
}

/* ── Error Hints (Contextual Notifications) ── */
.error-hint {
    position: absolute;
    z-index: 1000;
    background: #ef4444e0; /* Red-500 semi-transparent */
    color: white;
    padding: 6px 10px;
    border-radius: var(--radius-md);
    font-size: 11px;
    font-weight: 600;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    animation: hintFadeIn 0.3s ease-out forwards;
}

@keyframes hintFadeIn {
    0% { opacity: 0; transform: translate(-50%, 10px); }
    100% { opacity: 1; transform: translate(-50%, -10px); }
}

.error-hint.fade-out {
    animation: hintFadeOut 0.4s ease-in forwards;
}

@keyframes hintFadeOut {
    0% { opacity: 1; transform: translate(-50%, -10px); }
    100% { opacity: 0; transform: translate(-50%, -20px); }
}

/* Tooltip attivabile al click (card/tile attività): stesso aspetto e stessa logica
   di sparizione automatica del tooltip nativo (title) mostrato in hover — niente
   click-fuori da capire, sparisce da solo dopo un paio di secondi. */
.info-hint {
    position: absolute;
    z-index: 1000;
    background: rgba(20, 20, 20, 0.92);
    color: white;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.6;
    white-space: pre-line;
    max-width: 260px;
    pointer-events: none;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.15), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
    animation: infoHintFadeIn 0.15s ease-out forwards;
}

@keyframes infoHintFadeIn {
    0% { opacity: 0; transform: translateY(4px); }
    100% { opacity: 1; transform: translateY(0); }
}

.info-hint.fade-out {
    animation: infoHintFadeOut 0.35s ease-in forwards;
}

@keyframes infoHintFadeOut {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(4px); }
}

/* ── Footer Rows (Summary) ── */
/* Riga elastica fra le commesse e i footer Richieste/Disponibili: assorbe lo
   spazio residuo del viewport quando le commesse sono poche o zero, così i
   footer non restano incollati subito sotto l'header (vedi renderGrid). */
.gantt-footer-spacer {
    grid-column: 1 / -1;
}

.row-header.footer-row {
    position: sticky;
    bottom: 0;
    z-index: 10;
    background: var(--surface-2);
    border-top: 2px solid var(--divider);
    min-height: var(--footer-height);
    height: var(--footer-height);
}

.cell.footer-row {
    position: sticky;
    bottom: 0;
    z-index: 9;
    background: white;
    border-top: 2px solid var(--divider);
    min-height: var(--footer-height);
    height: var(--footer-height);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-weight: 700;
}

/* Stack the two footers */
.row-header.footer-row.avail-row, .cell.footer-row.avail-row {
    bottom: 0;
}
.row-header.footer-row.req-row, .cell.footer-row.req-row {
    bottom: var(--footer-height);
}

.footer-val {
    font-size: 16px;
}
.footer-label {
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
}

.footer-row.over-capacity {
    background: #fff5f5 !important;
    color: var(--danger);
}
.footer-row.over-capacity .footer-val {
    color: var(--danger);
}

.cell.gantt-highlight {
    background: rgba(245, 158, 11, 0.18) !important;
    box-shadow: inset 0 0 0 2px #f59e0b;
    transition: background 0.15s, box-shadow 0.15s;
}

/* Quick Site Tag (in-card link) */
.site-tag {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  padding: 0 4px;
  border-radius: 4px;
  transition: background 0.2s;
}

.site-tag:hover {
  background: rgba(255, 255, 255, 0.2);
  text-decoration-style: solid;
}

/* ── Availability / Blocked Placeholders ── */
.availability {
  border: 1px dashed var(--border);
  color: var(--faint);
  background: var(--surface-2);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 5px 10px;
  font-size: 12px;
}

.blocked {
  color: var(--muted);
  background: repeating-linear-gradient(135deg, var(--surface-3), var(--surface-3) 10px, #e6e4df 10px, #e6e4df 20px);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
}

/* ── Capacity Indicator ── */
.capacity-indicator {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
  font-weight: 500;
  padding-top: 4px;
  border-top: 1px dashed var(--divider);
}

.capacity-indicator.full {
  color: var(--danger);
  font-weight: 700;
}

/* ── Popover ── */
.popover {
  position: fixed;
  width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0, 0, 0, 0.05);
  padding: 14px;
  z-index: 1002;
  animation: popIn 0.15s ease-out;
  pointer-events: auto;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(4px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.popover h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.popover p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.popover .actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.popover button {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-md);
  min-height: 36px;
  padding: 0 10px;
  font: inherit;
}

.popover .wide {
  grid-column: 1 / -1;
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ── Quick Picker ── */
.quick-picker {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0, 0, 0, 0.05);
  z-index: 1001;
  min-width: 180px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: popIn 0.15s ease-out;
}

.picker-option {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: background 0.1s;
}

.picker-option:hover {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 500;
}

.picker-option.selected {
  background: var(--primary);
  color: white;
}

/* Suffisso mansioni/squadra/carico nelle opzioni risorsa */
.picker-option .opt-meta {
  font-size: 11px;
  opacity: 0.85;
  font-weight: 400;
  white-space: nowrap;
}

/* Searchable Picker */
.search-container {
  padding: 8px;
  border-bottom: 1px solid var(--divider);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 10;
}

.search-container input {
  width: 100%;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 8px;
  font-size: 12px;
}

.picker-results {
  max-height: 240px;
  overflow-y: auto;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

/* Aperti "annidati" da un altro modal (Gantt o Risorsa): devono stare sopra
   a prescindere dall'ordine nel DOM, che altrimenti decide lo stacking a
   parità di z-index e fa vincere il modal genitore quando viene dopo nel markup. */
#phaseManagerModal,
#mansioneManagerModal {
  z-index: 1001;
}

.modal-content {
  background: var(--surface);
  width: 100%;
  max-width: 440px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  animation: modalSlide 0.3s ease-out;
}

@keyframes modalSlide {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Titolo dentro il form Webix di login (#loginFormArea) */
.login-title {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  padding-top: 12px;
}

/* ── Pagina di login (login.html) ──
   Pagina dedicata, non un modal sopra il resto della UI: sfondo pieno
   (niente rgba/backdrop-filter come .modal-overlay, che qui darebbe
   l'effetto "finestra semi-trasparente" non voluto), card centrata. */
.login-page {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, var(--primary) 0%, #123a5c 100%);
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 36px 32px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.login-logo {
  height: 48px;
  width: auto;
  object-fit: contain;
}

.login-brand-text {
  font-family: var(--font);
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
}

.login-card #loginFormArea {
  width: 100%;
}

.modal-header {
  padding: 20px 24px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--divider);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  padding: 24px;
  display: grid;
  gap: 16px;
}

.form-group {
  display: grid;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.form-group input,
.form-group select {
  height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 12px;
  font: inherit;
  background: var(--surface-2);
  width: 100%;
}

.form-group input:disabled {
  background: var(--surface-3);
  cursor: not-allowed;
  color: var(--faint);
}

.modal-footer {
  padding: 16px 24px;
  background: var(--surface-2);
  border-top: 1px solid var(--divider);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.modal-footer button {
  height: 40px;
  padding: 0 20px;
  border-radius: var(--radius-md);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: white;
}

.modal-footer .btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.modal-footer .btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
  margin-right: auto;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-footer .btn-danger.confirming {
  background: #8b2361;
  border-color: #721c4e;
  transform: scale(1.05);
  font-weight: 700;
  box-shadow: 0 0 0 4px rgba(161, 44, 123, 0.2);
}

/* ── Modal Salva & Carica ── */
.approve-save-btn {
  width: 100%;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--primary);
  background: var(--primary);
  color: white;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.approve-save-btn:hover { opacity: 0.9; }
.approve-save-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.sim-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}

.sim-empty {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  padding: 6px 0;
}

.sim-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.sim-info { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.sim-info strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sim-info small { font-size: 11px; color: var(--muted); }

.sim-actions { display: flex; gap: 6px; flex-shrink: 0; }

.sim-actions button {
  height: 26px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: white;
}

.sim-actions button:hover { background: var(--surface-3); }
.sim-load-btn { color: var(--primary); border-color: var(--primary); }
.sim-delete-btn { color: var(--danger); }

.sim-delete-btn.confirming {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.add-sim-btn {
  width: 100%;
  margin-top: 8px;
  height: 32px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border);
  background: white;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.add-sim-btn:hover { background: var(--surface-2); color: var(--text); }

/* ── Notes ── */
.notes {
  padding: 16px 18px;
}

.notes code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  color: var(--text);
}

/* ── Help Button (nella barra del titolo) ── */

#helpBtn,
#logoutBtn {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(32, 142, 221, 0.28);
  transition: background 0.15s, transform 0.15s;
}

#helpBtn:hover,
#logoutBtn:hover {
  background: #1b79bc;
  transform: scale(1.1);
}

#logoutBtn {
  display: none;
}

.intro-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.lang-btn {
  height: 30px;
  padding: 0 10px;
  border-radius: 15px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

.lang-btn:hover {
  background: var(--surface-3);
}

.lang-picker .picker-option {
  white-space: nowrap;
}

/* ── Tour: Backdrop (blocca interazioni con l'UI, clic = avanza) ── */

.tour-bd {
  position: fixed;
  inset: 0;
  z-index: 1299;
  cursor: pointer;
}

/* ── Tour: Spotlight ── */

.tour-hl {
  position: fixed;
  z-index: 1300;
  pointer-events: none;
  border-radius: var(--radius-sm);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.62);
  outline: 2px solid rgba(255, 255, 255, 0.45);
  outline-offset: 2px;
  opacity: 0;
  transition: top 0.28s ease, left 0.28s ease,
              width 0.28s ease, height 0.28s ease,
              opacity 0.2s ease;
}

/* ── Tour: Tooltip ── */

.tour-tip {
  position: fixed;
  z-index: 1301;
  width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow), 0 0 0 1px rgba(0, 0, 0, 0.04);
  padding: 20px 20px 18px;
  pointer-events: auto;
  animation: tourPop 0.18s ease;
}

@keyframes tourPop {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.tour-x {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background 0.12s, color 0.12s;
  padding: 0;
}
.tour-x:hover { background: var(--surface-3); color: var(--text); }

/* Puntini di progresso */
.tour-dots {
  display: flex;
  gap: 5px;
  margin-bottom: 12px;
}
.tour-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--divider);
  transition: background 0.2s, transform 0.2s;
}
.tour-dot.on {
  background: var(--primary);
  transform: scale(1.2);
}

.tour-h {
  margin: 0 24px 10px 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.tour-txt {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 16px;
}
.tour-txt strong { color: var(--text); font-weight: 600; }

/* Barra navigazione */
.tour-nav {
  display: flex;
  gap: 8px;
  align-items: center;
  border-top: 1px solid var(--divider);
  padding-top: 12px;
}

.tour-prev,
.tour-next {
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.tour-prev:disabled { opacity: 0.35; cursor: not-allowed; }
.tour-prev:not(:disabled):hover { background: var(--surface-3); }

.tour-next {
  margin-left: auto;
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.tour-next:hover { background: #1b79bc; }

.tour-manual-link {
  display: block;
  text-align: center;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--primary);
  text-decoration: none;
}
.tour-manual-link:hover { text-decoration: underline; }

/* ── Responsive ── */
@media (max-width: 900px) {
  body {
    padding: 12px;
  }

  :root {
    --row-header-width: 180px;
    --day-col-width: 150px;
  }

  .toolbar .legend {
    width: 100%;
    margin-left: 0;
  }
}

/* ── Print Header (hidden on screen) ── */
.print-header {
  display: none;
}

/* ── Print Styles ── */
@media print {
  @page {
    size: landscape;
    margin: 10mm;
  }

  /* Force colors on print */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  /* Hide UI chrome */
  .intro,
  .toolbar,
  .notes,
  .modal-overlay,
  .popover,
  .quick-picker,
  .tour-bd,
  .tour-hl,
  .tour-tip {
    display: none !important;
  }

  /* Show print header */
  .print-header {
    display: block !important;
    padding: 12px 0 8px;
    border-bottom: 2px solid var(--text);
    margin-bottom: 8px;
  }

  .print-header h1 {
    margin: 0 0 2px;
    font-size: 18px;
    color: var(--text);
  }

  .print-header p {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
  }

  /* Reset body */
  body {
    padding: 0;
    background: white;
  }

  .page {
    gap: 0;
  }

  /* Expand the grid — remove scroll constraints */
  .planner-shell {
    border: none;
    border-radius: 0;
    overflow: visible !important;
  }

  .planner-scroll {
    overflow: visible !important;
    max-height: none !important;
  }

  .planner-grid {
    width: 100% !important;
    min-width: 0 !important;
    display: grid !important;
  }

  /* Compressione della griglia per far stare tutti i 28 giorni (passato + futuro) in un A4 landscape */
  .planner-grid[data-view="gantt"] {
    grid-template-columns: 100px repeat(28, 1fr) !important;
    zoom: 0.65 !important;
  }

  /* Sticky positioning off (breaks print) */
  .corner,
  .col-header,
  .row-header {
    position: static !important;
  }

  /* Compact cells for print */
  .cell {
    min-height: 28px;
    padding: 4px 6px;
    gap: 3px;
  }

  .slot-card {
    min-height: 18px;
    padding: 3px 6px;
    font-size: 10px;
    border-radius: 4px;
  }

  .slot-card small {
    font-size: 9px;
  }

  .corner,
  .col-header {
    min-height: 48px;
    padding: 6px 8px;
  }

  .row-header {
    min-height: 28px;
    padding: 6px 8px;
  }

  .corner strong,
  .col-header strong,
  .row-header strong {
    font-size: 11px;
  }

  .corner small,
  .col-header small,
  .row-header small {
    font-size: 10px;
  }

  .badge {
    height: 16px;
    padding: 0 5px;
    font-size: 9px;
  }

  .capacity-indicator {
    font-size: 9px;
    padding-top: 2px;
  }

  .availability {
    font-size: 10px;
    padding: 3px 6px;
  }

  .blocked {
    font-size: 10px;
    padding: 3px 6px;
  }

  /* Remove interactive styles */
  .cell:hover {
    background: white;
  }

  .cell.selected {
    outline: none;
  }

  /* ── Timeline print ── */
  /* Riduci larghezza colonne per far stare 7 giorni in A4 landscape (297mm - 20mm margini ≈ 277mm) */
  /* 277mm / (240px header + 7 col) ≈ 115px/col — !important vince sull'inline style del wrap */
  .timeline-wrap {
    --tl-col-width: 115px !important;
    width: 100%;
    overflow: visible;
  }

  /* Rimuovi sticky (rompe il layout di stampa) */
  .tl-header,
  .tl-row-stub,
  .tl-row-header,
  .tl-unassigned-row {
    position: static !important;
  }

  /* Nascondi i bottoni zoom */
  .tl-zoom-bar {
    display: none !important;
  }

  /* Riduci altezza barre e font per stampa compatta */
  .tl-track {
    height: 36px;
  }

  .tl-bar {
    font-size: 8px;
    top: 5px;
    bottom: 5px;
    padding: 0 3px;
  }

  .tl-day-label {
    padding: 3px 6px 2px;
    font-size: 10px;
  }

  .tl-row-header {
    padding: 4px 8px;
  }

  .tl-row-header strong { font-size: 11px; }
  .tl-row-header small  { font-size: 9px; }
}

/* ── Vista Timeline ── */
:root {
  --tl-col-width: 240px;
  --tls-col-width: 240px;
}

.timeline-wrap {
  display: flex;
  flex-direction: column;
}

/* ── Header (sticky top) ── */
.tl-header {
  display: flex;
  align-items: stretch;
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--surface-2);
  border-bottom: 2px solid var(--divider);
}

/* Angolo e stub label colonna sinistra */
.tl-row-stub {
  width: var(--row-header-width);
  flex-shrink: 0;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
  border-right: 1px solid var(--divider);
  position: sticky;
  left: 0;
  background: var(--surface-2);
  z-index: 5;
}

/* Header giorno: etichetta + asse ore */
.tl-day-header {
  flex: 0 0 var(--tl-col-width);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--divider);
  min-width: 0;
}

.tl-day-header.past-header {
  opacity: 0.52;
  filter: saturate(0.45) brightness(0.82);
}

.tl-day-label {
  padding: 5px 8px 3px;
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-size: 12px;
  border-bottom: 1px solid var(--divider);
}

.tl-day-label strong { font-weight: 700; color: var(--text); }
.tl-day-label span   { font-size: 10px; color: var(--muted); }

/* Asse ore dentro ogni colonna giorno */
.tl-axis {
  flex: 1;
  position: relative;
  height: 18px;
  overflow: hidden;
}

.tl-hour-label {
  position: absolute;
  top: 2px;
  font-size: 9px;
  color: var(--muted);
  font-weight: 500;
  transform: translateX(3px); /* lieve offset per non sovrapporre la linea */
  white-space: nowrap;
  user-select: none;
}

/* ── Righe risorse ── */
.tl-row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--divider);
}

/* Riga "Task da assegnare": sticky subito sotto l'header (top impostato
   inline in JS, dato che l'altezza dell'header non è un valore fisso). */
.tl-unassigned-row {
  position: sticky;
  z-index: 4;
  background: var(--surface-2);
  border-bottom: 2px solid var(--divider);
}

.tl-row-header {
  width: var(--row-header-width);
  flex-shrink: 0;
  padding: 6px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  border-right: 1px solid var(--divider);
  position: sticky;
  left: 0;
  background: var(--surface-2);
  z-index: 3;
}

.tl-row-header strong { font-size: 13px; line-height: 1.2; }
.tl-row-header small  { font-size: 11px; color: var(--muted); }

/* ── Track (area ore per giorno) ── */
.tl-track {
  flex: 0 0 var(--tl-col-width);
  position: relative;
  min-height: 46px;
  /* altezza auto: si allunga con il row-header per riempire tutta la riga
     (evita la striscia senza righe verticali sotto le barre) */
  background: var(--surface-2);
  /* background-image settato inline in JS per rispettare TL_SPAN dinamico */
  border-right: 1px solid var(--divider);
  overflow: visible;
}

.tl-track.drop-target {
  background-color: rgba(32, 142, 221, 0.08) !important;
}

.tl-track-past {
  opacity: 0.52;
  filter: saturate(0.45) brightness(0.82);
}

/* Risorsa bloccata / assente */
.tl-blocked {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    135deg,
    var(--surface-3), var(--surface-3) 10px,
    #e6e4df 10px, #e6e4df 20px
  );
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--muted);
}

/* ── Barre task ── */
.tl-bar {
  position: absolute;
  top: 6px;
  bottom: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 10px;
  padding: 0 5px;
  display: flex;
  align-items: center;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
  transition: box-shadow 0.15s, opacity 0.15s;
  min-width: 3px;
  z-index: 1;
}

.tl-bar:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  z-index: 2;
}

/* Assenza parziale in Timeline Risorse: stesso retino usato altrove per le
   assenze, non trascinabile (niente drag, il gate già impedisce sovrapposizioni). */
.tl-bar-absence {
  border-color: var(--border);
  background: repeating-linear-gradient(135deg, var(--surface-3), var(--surface-3) 8px, #e6e4df 8px, #e6e4df 16px);
  color: var(--muted);
  cursor: default;
}

.tl-bar:active { cursor: grabbing; }

.tl-bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}


/* ── Controlli zoom timeline ── */
.tl-zoom-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 7px;
}

.tl-zoom-btn {
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--text);
  border-radius: 4px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}

.tl-zoom-btn:hover:not(:disabled) {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.tl-zoom-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.tl-zoom-lbl {
  font-size: 10px;
  color: var(--muted);
  min-width: 32px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ── Vista Timeline Commesse ──────────────────────────────
   Riusa le classi .tl-* della Timeline Risorse (stesso "look"); le barre hanno
   però geometria a corsie (top/height inline) invece di top/bottom fissi, perché
   più risorse in parallelo sullo stesso blocco orario sono qui la norma. */
.stl-wrap {
  --tl-col-width: var(--tls-col-width);
}

.stl-bar {
  bottom: auto;
}

/* Stesso stile (bordo/sfondo/colore) di .unassigned-slot-card nella vista
   Commesse, più lo stesso bottone "Assegna" (.assign-btn, riusato as-is) per
   staccare il buco anche quando il colore da solo non basta. L'intera barra
   resta comunque cliccabile (non solo il bottone). */
.stl-gap {
  border: 1.5px dashed #b85c5c;
  background: rgba(184, 92, 92, 0.13) !important;
  color: #e07070 !important;
  cursor: pointer;
  gap: 4px;
}

.stl-gap:hover {
  background: rgba(184, 92, 92, 0.22) !important;
}

.stl-gap .tl-bar-label {
  font-weight: 700;
  flex: 1 1 auto;
  min-width: 0;
}

/* Badge più compatto qui rispetto alla vista Commesse: le barre orarie sono
   spesso più strette di una cella della griglia settimanale. */
.stl-gap .assign-btn {
  font-size: 9px;
  padding: 1px 5px;
}

.stl-bar .site-tag {
  cursor: pointer;
}

/* ── Selezione rettangolare Gantt ───────────────────────── */

.gantt-selection-rect {
  position: fixed;
  border: 2px dashed var(--primary, #208edd);
  background: rgba(32, 142, 221, 0.08);
  pointer-events: none;
  z-index: 1000;
  border-radius: 3px;
}

.gantt-block-badge.gantt-selected {
  outline: 2px solid #f97316;
  outline-offset: 2px;
}

.gantt-selection-toolbar {
  position: fixed;
  display: none;
  align-items: center;
  gap: 10px;
  background: var(--surface-1, #fff);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
  z-index: 9998;
  font-size: 13px;
  white-space: nowrap;
}

/* ── Periodicità Gantt ──────────────────────────────────── */

.gantt-recurrence-group {
  display: grid;
  gap: 8px;
}

.gantt-recurrence-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.gantt-recurrence-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  flex-shrink: 0;
  cursor: pointer;
}

.gantt-recurrence-toggle label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

#ganttRecurrenceOptions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-left: 24px;
}

#ganttRecurrenceOptions > span {
  font-size: 13px;
  color: var(--muted);
}

#ganttRecurrenceOptions input[type="number"] {
  width: 60px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 8px;
  font: inherit;
  font-size: 13px;
  background: var(--surface-2);
}

#ganttRecurrenceOptions select {
  height: 34px;
  width: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 8px;
  font: inherit;
  font-size: 13px;
  background: var(--surface-2);
}

#ganttRecurrenceInfo {
  flex-basis: 100%;
  font-size: 11px;
  color: var(--muted);
}

.gantt-periodic-icon {
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 10px;
  opacity: 0.8;
  line-height: 1;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--primary, #208edd);
  color: #fff;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  opacity: 0;
  transition: opacity .22s ease, transform .22s ease;
  pointer-events: none;
  z-index: 9999;
  max-width: min(90vw, 420px);
  text-align: center;
}

.toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}