/* ============================================================
   TALARYS — Design System
   Tema: "ink & tide" — sidebar inchiostro, topbar chiara, blu marea
   Font: Plus Jakarta Sans (UI) · IBM Plex Mono (numeri)

   I nomi delle classi/variabili sono quelli storici (--navy, .card,
   .badge-*, .checker-*): le pagine li usano ovunque, quindi qui si
   cambiano i VALORI, non i nomi, e tutta l'app si riallinea da sola.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  /* Brand — blu "marea": più vivo del navy vecchio, stessa famiglia */
  --navy:       #2456C4;
  --navy-dark:  #1B3F97;
  --navy-light: #4C7BE0;
  --navy-tint:  #EEF3FE;   /* fondo tenue per stati attivi/selezionati */
  --steel:      #3E8FB0;
  --steel-light:#6FB6D2;

  /* Inchiostro e superfici */
  --ink:        #0F1729;   /* sidebar, testi forti */
  --ink-soft:   #1B2740;
  --text:       #1F2A3C;
  --grey:       #5B6478;
  --grey-light: #8B93A7;
  --grey-text:  #5B6478;
  --grey-bg:    #F4F6FB;   /* fondo pagina */
  --grey-border:#E4E8F1;
  --white:      #FFFFFF;

  /* Semantici */
  --success: #0E9F6E;
  --warning: #D97706;
  --danger:  #E02424;
  --info:    #0891B2;

  --sidebar-w: 236px;
  --sidebar-collapsed-w: 60px;
  --topbar-h:  64px;

  --radius:    10px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --shadow-xs: 0 1px 2px rgba(15,23,41,.06);
  --shadow:    0 1px 2px rgba(15,23,41,.05), 0 6px 16px -8px rgba(15,23,41,.14);
  --shadow-lg: 0 12px 32px -12px rgba(15,23,41,.28);
  --ring:      0 0 0 3px rgba(36,86,196,.18);

  --t-fast: .12s ease;
  --t:      .2s cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

html, body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--grey-bg);
  height: 100%;
  -webkit-font-smoothing: antialiased;
}

/* Nessun scroll orizzontale della pagina: le tabelle larghe scrollano dentro la loro card */
body { overflow-x: hidden; }

h1, h2, h3, h4 { letter-spacing: -.015em; color: var(--ink); font-weight: 700; }

::selection { background: rgba(36,86,196,.18); }

/* Focus visibile e coerente su tutta l'app (accessibilità da tastiera) */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--radius);
}

/* ── LAYOUT ────────────────────────────────────────────────── */
.talarys-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── TOPBAR ───────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: rgba(255,255,255,.88);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  color: var(--text);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  z-index: 1000;
  border-bottom: 1px solid var(--grey-border);
}

.topbar-logo-wrap {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: var(--radius);
}

.topbar-logo { height: 40px; width: auto; display: block; }

.topbar-brand {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--ink);
  text-decoration: none;
}

.topbar-spacer { flex: 1; }

.topbar-actions { display: flex; align-items: center; gap: 4px; }

/* Il nome utente porta anche .btn-icon (40x40 fissi): senza width auto il nome
   viene tagliato via e resta un quadratino vuoto. */
.topbar-user {
  width: auto !important;
  height: auto !important;
  min-height: 36px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text) !important;
  padding: 6px 12px !important;
  border-radius: var(--radius-pill) !important;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--grey);
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast), color var(--t-fast);
}
.btn-icon:hover { background: var(--grey-bg); color: var(--navy); }

/* Hamburger: solo mobile — su desktop la sidebar si fissa/riduce col pin */
.topbar-hamburger { display: none; }

.notification-badge { position: relative; display: inline-flex; }

.notification-count {
  position: absolute;
  top: 4px; right: 4px;
  background: var(--danger);
  color: #fff;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  min-width: 17px;
  height: 17px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--white);
}

/* ── LANGUAGE SELECTOR ────────────────────────────────────── */
.lang-overlay { position: fixed; inset: 0; z-index: 1100; }
.lang-selector { position: relative; z-index: 1101; }

.lang-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--white);
  border: 1px solid var(--grey-border);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-pill);
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.lang-btn:hover { border-color: var(--navy-light); box-shadow: var(--shadow-xs); }
.lang-btn img { border-radius: 2px; display: block; }

.lang-chevron { font-size: 10px; color: var(--grey-light); }

.lang-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--white);
  border: 1px solid var(--grey-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 150px;
  overflow: hidden;
  padding: 4px;
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.lang-option:hover  { background: var(--grey-bg); }
.lang-option.active { background: var(--navy-tint); font-weight: 600; color: var(--navy); }
.lang-option img    { border-radius: 2px; flex-shrink: 0; }

/* ── SIDEBAR ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--ink);
  color: #A9B3C7;
  border-right: 1px solid rgba(255,255,255,.06);
  overflow-x: hidden;
  overflow-y: auto;
  z-index: 900;
  padding: 10px 8px 0;
  display: flex;
  flex-direction: column;
  transition: width var(--t), transform var(--t);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.18) transparent;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 8px; }

.sidebar-section { padding: 4px 0; }

.sidebar-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: #6B7690;
  padding: 12px 12px 6px;
  white-space: nowrap;
}

.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,.07);
  margin: 6px 10px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 42px;
  padding: 9px 12px;
  margin: 1px 0;
  color: #A9B3C7;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: var(--radius);
  transition: background var(--t-fast), color var(--t-fast);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  white-space: nowrap;
}

.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }

/* Attivo: pillola blu piena — leggibile anche a colpo d'occhio sul dark */
.nav-link.active {
  background: var(--navy);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 6px 16px -8px rgba(36,86,196,.9);
}
.nav-link.active:hover { background: var(--navy-light); }

.nav-link .nav-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: inherit;
}

.sidebar-pin {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  background: var(--ink);
  border-top: 1px solid rgba(255,255,255,.07);
  padding: 6px 0;
}
.sidebar-pin-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  width: 100%;
  background: none;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: #7C879E;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-pin-btn:hover { color: #fff; background: rgba(255,255,255,.06); }

/* Sidebar ridotta: icone sole, si espande in hover */
.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed-w); }
.sidebar-collapsed .sidebar:hover {
  width: var(--sidebar-w);
  box-shadow: var(--shadow-lg);
  z-index: 950;
}
.sidebar-collapsed .sidebar:not(:hover) .nav-text,
.sidebar-collapsed .sidebar:not(:hover) .sidebar-label { display: none; }
.sidebar-collapsed .sidebar:not(:hover) .nav-link,
.sidebar-collapsed .sidebar:not(:hover) .sidebar-pin-btn { justify-content: center; padding: 9px 0; }
.sidebar-collapsed .main-content,
.sidebar-collapsed .app-footer { margin-left: var(--sidebar-collapsed-w); }

/* Impersonazione: la banda arancione sta sopra tutto, quindi topbar e sidebar
   scendono di 40px — altrimenti la topbar ci finisce sotto e sparisce. */
.impersonating .topbar  { top: 40px; }
.impersonating .sidebar { top: calc(var(--topbar-h) + 40px); }

/* Velo scuro dietro il drawer su mobile */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,41,.45);
  backdrop-filter: blur(2px);
  z-index: 890;
  border: none;
  cursor: pointer;
  animation: fade-in .18s ease;
}

/* ── MAIN + FOOTER ────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 24px 28px;
  flex: 1 0 auto;
  min-width: 0;
  /* Solo opacita', niente transform: un'animazione di transform rende il contenitore il
     riferimento dei position:fixed che ha dentro. La barra azioni del timesheet su telefono
     (.ts-actions) finiva cosi' in fondo alla pagina invece che in fondo allo schermo, e con
     lei il tasto «Chiudi mese»; lo stesso per il cronometro. */
  animation: fade-in .28s ease both;
}

/* In un contenitore flex il testo e lo <strong> diventano due elementi separati e lo
   spazio fra loro sparisce ("Powered byTalarys"): la distanza la dà il gap, non uno
   spazio nel markup che il flex butterebbe via. */
.app-footer {
  margin-left: var(--sidebar-w);
  flex-shrink: 0;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .3em;
  font-size: 12px;
  color: var(--grey-light);
  border-top: 1px solid var(--grey-border);
  background: var(--white);
}

@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ── CARDS ────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--grey-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 18px;
  min-width: 0;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--grey-border);
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--ink);
}

/* ── STAT CARDS ───────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  position: relative;
  background: var(--white);
  border: 1px solid var(--grey-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 16px 18px 16px 20px;
  overflow: hidden;
  transition: transform var(--t), box-shadow var(--t);
}
.stat-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--navy);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card.success::before { background: var(--success); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.danger::before  { background: var(--danger); }
.stat-card.info::before    { background: var(--info); }

.stat-label {
  font-size: 11px;
  color: var(--grey-light);
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 700;
}

.stat-value {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--ink);
  margin-top: 6px;
}

/* ── BUTTONS ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }

.btn-primary   { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-dark); border-color: var(--navy-dark); }
.btn-secondary { background: var(--white); color: var(--navy); border-color: var(--grey-border); }
.btn-secondary:hover { background: var(--navy-tint); border-color: var(--navy-light); }
.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-success   { background: var(--success); color: #fff; border-color: var(--success); }
.btn-sm        { min-height: 30px; padding: 5px 11px; font-size: 12px; }

.btn-link {
  font-family: inherit;
}

/* ── BADGES ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-draft     { background: #F1F3F8; color: #59627A; border-color: #E4E8F1; }
.badge-submitted { background: #E8F0FE; color: #1B3F97; border-color: #CFE0FC; }
.badge-approved  { background: #E3F7EF; color: #076C4B; border-color: #C4EEDD; }
.badge-rejected  { background: #FDE8E8; color: #9B1C1C; border-color: #FACDCD; }
.badge-purple    { background: #F0EBFE; color: #5B21B6; border-color: #DDD1FB; }
.badge-pending   { background: #FDF3DA; color: #92400E; border-color: #FBE3AE; }

/* ── TABELLE (le pagine usano <table> "nude") ─────────────── */
.card table { border-collapse: collapse; width: 100%; }
.card table thead th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--grey-light);
  background: transparent;
}
.card table tbody tr { transition: background var(--t-fast); }
.card table tbody tr:hover { background: var(--navy-tint); }

/* ── CHECKERBOARD GRID (timesheet/risorse) ────────────────── */
.checker-grid { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.checker-table {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  width: 100%;
  min-width: 800px;
}

.checker-table th {
  background: var(--ink);
  color: #fff;
  padding: 9px 10px;
  text-align: center;
  font-weight: 600;
  font-size: 11px;
  position: sticky;
  top: 0;
  z-index: 3;
}

.checker-table th.user-col {
  text-align: left;
  min-width: 170px;
  position: sticky;
  left: 0;
  z-index: 4;
}

.checker-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--grey-border);
  border-right: 1px solid var(--grey-border);
  text-align: center;
  vertical-align: middle;
}

.checker-table td.user-col {
  text-align: left;
  font-weight: 600;
  position: sticky;
  left: 0;
  background: var(--white);
  z-index: 1;
}

.checker-table tr:hover td { background: var(--navy-tint); }

.checker-cell {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  cursor: pointer;
}

.checker-cell.has-hours { background: var(--navy-tint); color: var(--navy-dark); font-weight: 600; }
.checker-cell.holiday   { background: #FDF3DA; color: var(--warning); }
.checker-cell.weekend   { background: var(--grey-bg); color: var(--grey-light); }
.checker-cell.leave     { background: #E3F7EF; color: var(--success); }

.checker-cell.missing-hours { animation: blink-missing 1.4s ease-in-out infinite; color: #7F1D1D; font-weight: 700; }
.checker-cell.partial-hours { animation: blink-partial 1.8s ease-in-out infinite; color: #78350F; font-weight: 700; }

@keyframes blink-missing { 0%,100% { background: #FDE8E8; } 50% { background: #F8B4B4; } }
@keyframes blink-partial { 0%,100% { background: #FDF3DA; } 50% { background: #FCE96A; } }

/* ══════════════════════════════════════════════════════════════════════════
   MACRO PLANNING (/pm/macro-planning) — corsie × settimane
   Le corsie sono le macro-fasi di progetto (ProjectStage): una riga ciascuna.
   UNA sola riga per corsia, con le due celle di sinistra (nome + backlog) in
   position:sticky. Con due riquadri affiancati le righe si disallineerebbero
   appena una cella contiene più cartellini delle altre.
   Le larghezze stanno in variabili perché la cella "backlog" deve stare
   incollata a `left: <larghezza della cella nome>`: due valori da tenere in sync.
   ══════════════════════════════════════════════════════════════════════════ */

.macro-grid {
  --lane-w: 172px;
  --backlog-w: 196px;
  --week-w: 158px;
  overflow: auto;
  max-height: 72vh;
  border: 1px solid var(--grey-border);
  border-radius: 10px;
  background: var(--white);
}

.macro-inner { width: max-content; min-width: 100%; }

.macro-row {
  display: flex;
  align-items: stretch;
  min-height: 92px;
  background: var(--white);
  border-bottom: 1px solid var(--grey-border);
}
/* L'intestazione è il primo figlio: le corsie partono da nth-child(2). */
.macro-row:nth-child(even) { background: #FAFBFE; }

.macro-head {
  position: sticky;
  top: 0;
  z-index: 4;
  min-height: 44px;
  background: var(--navy);
  color: var(--white);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}

/* ── Celle congelate ─────────────────────────────────────────────────────── */
/* `background: inherit` prende il fondo della riga (bianco, zebrato o navy):
   senza, i cartellini scorrerebbero sotto le celle trasparenti. */

.macro-c-lane {
  position: sticky;
  left: 0;
  z-index: 2;
  flex: 0 0 var(--lane-w);
  padding: 10px 10px;
  display: flex;
  align-items: center;
  gap: 7px;
  background: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: .03em;
  line-height: 1.25;
  overflow: hidden;
}

.macro-c-backlog {
  position: sticky;
  left: var(--lane-w);
  z-index: 2;
  flex: 0 0 var(--backlog-w);
  padding: 8px 8px;
  background: inherit;
  border-right: 2px solid var(--grey-border);
  display: block;
}

.macro-head .macro-c-lane,
.macro-head .macro-c-backlog { z-index: 5; color: var(--white); }

.macro-lane-dot {
  width: 10px; height: 10px;
  flex: 0 0 auto;
  border-radius: 3px;
  background: var(--stage-color, #94a3b8);
}

.macro-c-backlog > .macro-card { margin-bottom: 6px; }
.macro-empty { font-size: 11px; color: var(--grey-light); }

/* ── Settimane ───────────────────────────────────────────────────────────── */

.macro-week-head {
  flex: 0 0 var(--week-w);
  padding: 6px 8px;
  border-right: 1px solid rgba(255,255,255,.18);
}
.macro-week-head.current { background: rgba(255,255,255,.14); }
.macro-month  { font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.macro-weekno { font-size: 10.5px; font-weight: 400; text-transform: none; opacity: .85; }

.macro-cell {
  flex: 0 0 var(--week-w);
  padding: 8px 6px;
  border-right: 1px solid var(--grey-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.macro-cell.current { background: #EFF6FF; }

/* ── Cartellino ──────────────────────────────────────────────────────────── */

.macro-card {
  position: relative;
  background: white;
  border: 1px solid var(--grey-border);
  border-left: 4px solid var(--stage-color, var(--navy));
  border-radius: 8px;
  padding: 8px 20px 8px 10px;      /* spazio a destra per il pallino di stato */
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  transition: box-shadow .15s ease;
}
.macro-card:hover { box-shadow: 0 3px 10px rgba(0,0,0,0.14); }

.macro-card-proj  { font-size: 10px; font-weight: 700; color: var(--grey-light); letter-spacing: .02em; }
.macro-card-title { font-size: 11.5px; font-weight: 700; color: var(--navy); line-height: 1.3; margin: 2px 0; }
.macro-card-sub   { font-size: 10.5px; color: var(--grey); line-height: 1.35; }

.macro-card-gate {
  border-top: 1px dashed var(--grey-border);
  padding-top: 5px;
  margin-top: 5px;
  font-size: 10.5px;
  line-height: 1.35;
}

.macro-dot {
  position: absolute;
  top: 9px; right: 8px;
  width: 9px; height: 9px;
  border-radius: 50%;
}

.macro-card-overdue { animation: macro-overdue 1.3s ease-in-out infinite; }
@keyframes macro-overdue {
  0%,100% { background: #FDE8E8; }
  50%     { background: #F8B4B4; }
}
.macro-swatch { display: inline-block; width: 11px; height: 11px; border-radius: 3px; vertical-align: middle; margin-right: 3px; }

/* Modo Progetti: niente corsie (una macro-fase qualifica un'attività, non una
   commessa), quindi la cella backlog torna incollata al bordo sinistro. */
.macro-grid.no-lanes { --lane-w: 0px; }

/* Su schermo stretto le celle congelate mangerebbero tutta la pagina. */
@media (max-width: 900px) {
  .macro-grid { --lane-w: 116px; --backlog-w: 140px; --week-w: 140px; }
  .macro-grid.no-lanes { --lane-w: 0px; }
}

.checker-legend { display: inline-block; padding: 3px 9px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 600; }
.checker-legend.has-hours            { background: var(--navy-tint); color: var(--navy); }
.checker-legend.missing-hours-legend { background: #FDE8E8; color: #7F1D1D; }
.checker-legend.partial-hours-legend { background: #FDF3DA; color: #78350F; }

.grid-row-user { background: var(--ink); }
.grid-row-user td.user-col { background: var(--ink) !important; color: #fff !important; }
.grid-row-user td.mono { color: #fff; }
.grid-row-user .checker-cell { color: rgba(255,255,255,.5); }
/* (sfondo delle ore: vedi più sotto, pieno) */
.grid-row-user .checker-cell.missing-hours { color: #7F1D1D; }
.grid-row-user .checker-cell.partial-hours { color: #78350F; }
.grid-row-user:hover td.user-col { background: var(--ink-soft) !important; }
/* Riga utente al passaggio del mouse: resta scura. La regola generale (.checker-table tr:hover)
   la schiariva e il testo bianco delle ore spariva. */
.checker-table tr.grid-row-user:hover td { background: var(--ink-soft); }
/* Sfondi PIENI, non trasparenti: con rgba si vedeva la riga sotto, che la regola generale
   .card table tbody tr:hover schiariva — cella chiara e ore bianche invisibili. */
.card table tbody tr.grid-row-user:hover { background: var(--ink-soft); }
.grid-row-user .checker-cell.has-hours { background: #2A3550; color: #fff; }
.checker-table tr.grid-row-user:hover td.checker-cell.has-hours { background: #3A4766; color: #fff; }
/* La cella puntata si distingue dalle altre della riga. */
.checker-table td.checker-cell:hover { box-shadow: inset 0 0 0 2px var(--navy); }
.checker-table tr.grid-row-user td.checker-cell:hover { box-shadow: inset 0 0 0 2px #93B4F5; }

.grid-row-project    { background: var(--navy-tint); }
.grid-row-project td { color: var(--navy-dark); }
.grid-row-project:hover { background: #E1EAFD; }

.grid-row-phase    { background: var(--white); }
.grid-row-phase td { color: var(--grey); }
.grid-row-phase:hover { background: var(--grey-bg); }

/* ── CALENDARIO ───────────────────────────────────────────── */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }

.cal-day-header {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  color: var(--grey-light);
  padding: 4px;
  text-transform: uppercase;
}

.cal-cell {
  position: relative;
  background: var(--white);
  border: 1px solid var(--grey-border);
  border-radius: var(--radius);
  padding: 7px;
  min-height: 68px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}

.cal-cell:hover { border-color: var(--navy-light); box-shadow: var(--shadow-xs); transform: translateY(-1px); }
.cal-cell.today { border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }
.cal-cell.selected { border-color: var(--navy); background: var(--navy-tint); box-shadow: var(--ring); }
.cal-cell.other-month { opacity: .38; }
.cal-cell.weekend { background: var(--grey-bg); }
.cal-cell.holiday { background: #FFFBEB; }

/* Pallino di quadratura: centrato in orizzontale nella cella, sulla riga del
   numero del giorno. In alto a destra finiva sopra al numero/totale ore. */
.cal-status-dot {
  position: absolute;
  left: 50%;
  top: 8px;
  transform: translateX(-50%);
  width: 8px; height: 8px;
  border-radius: 50%;
}
.cal-status-dot.dot-ok      { background: var(--success); }
.cal-status-dot.dot-partial { background: var(--warning); }
.cal-status-dot.dot-missing { background: var(--danger); animation: blink-missing 1.4s ease-in-out infinite; }
.cal-expense-dot { display: inline-block; font-size: 10px; font-weight: 700; color: #076C4B; background: #E3F7EF; border-radius: 4px; padding: 0 4px; margin-top: 2px; }

.cal-date { font-size: 12px; font-weight: 700; color: var(--grey); margin-bottom: 4px; }

.cal-entry {
  background: var(--navy-tint);
  border-left: 3px solid var(--navy);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 11px;
  margin-top: 3px;
  color: var(--navy-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-hours-total {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  text-align: right;
}

/* ============================================================
   CALENDARIO STILE iOS — mese, settimana, giorno
   Mese: celle senza bordi, numero del giorno, chip colorate per attività.
   Settimana/Giorno: griglia oraria con banda "tutto il giorno" per le voci
   dichiarate a ore senza orario, blocchi posizionati per le voci con fascia
   oraria, linea rossa dell'ora corrente.
   Il colore della chip viene dal progetto: --evt (accento), --evt-bg (tinta chiara)
   e --evt-fg (testo) arrivano inline da ProjectColors.CssVars — colore del progetto
   o della sua categoria (cliente / interno / assenze). Stesso progetto, stesso colore
   in tutte e tre le viste.
   ============================================================ */

/* ── Mese ─────────────────────────────────────────────────── */
.ios-month .cal-cell {
  border: none;
  border-top: 1px solid var(--grey-border);
  border-radius: 0;
  background: transparent;
  padding: 4px 5px 5px;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ios-month .cal-cell:hover { background: var(--grey-bg); box-shadow: none; transform: none; }
.ios-month .cal-cell.today { border-top-color: var(--grey-border); box-shadow: none; }
.ios-month .cal-cell.selected { background: var(--navy-tint); box-shadow: inset 0 0 0 2px var(--navy); border-radius: 10px; }
.ios-month .cal-cell.weekend { background: transparent; }
.ios-month .cal-cell.weekend .cal-daynum { color: var(--grey-light); }

.cal-daynum {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}
/* Oggi: pastiglia rossa piena, come iOS */
.cal-cell.today .cal-daynum { background: var(--danger); color: #fff; font-weight: 700; }

.cal-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--evt-bg, var(--navy-tint));
  color: var(--evt-fg, var(--navy-dark));
  border-radius: 5px;
  padding: 2px 5px;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.cal-chip::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--evt, var(--navy));
  flex-shrink: 0;
}
.cal-chip .chip-h { font-family: 'IBM Plex Mono', monospace; opacity: .85; }
.cal-chip-more { font-size: 10px; font-weight: 600; color: var(--grey-light); padding-left: 3px; }
.cal-chip.chip-exp { background: #FDF3DA; color: #92400E; }
.cal-chip.chip-exp::before { background: var(--warning); }

/* Assenze: approvate = colore del progetto Assenze (categoria «assenze», inline),
   richiesta in attesa = rossa "da approvare". */
.cal-chip.chip-leave-pending { --evt: #E02424; --evt-bg: #FDE8E8; --evt-fg: #9B1C1C; font-style: italic; }

/* ── Griglia oraria (settimana + giorno) ──────────────────── */
.ios-grid {
  --gutter: 56px;
  background: var(--white);
  border: 1px solid var(--grey-border);
  border-radius: var(--radius-lg);
  /* clip, NON hidden: overflow:hidden rende la griglia il contenitore di scorrimento della
     testata sticky, che allora stava sempre 64px (--topbar-h) più in basso del dovuto e
     copriva la banda "tutto il giorno" e la prima ora — le voci senza orario sparivano. */
  overflow: clip;
}

.ios-head {
  display: grid;
  grid-template-columns: var(--gutter) repeat(var(--cols, 7), minmax(0, 1fr));
  border-bottom: 1px solid var(--grey-border);
  position: sticky;
  top: var(--topbar-h);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  z-index: 2;
}
.ios-head-day { padding: 8px 4px; text-align: center; border-left: 1px solid var(--grey-border); }
.ios-head-day:first-child { border-left: none; }
.ios-head-dow {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--grey-light);
}
.ios-head-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px; height: 28px;
  border-radius: var(--radius-pill);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 2px;
}
.ios-head-day.today .ios-head-dow { color: var(--danger); }
.ios-head-day.today .ios-head-num { background: var(--danger); color: #fff; }
.ios-head-day.off .ios-head-num { color: var(--grey-light); font-weight: 600; }
.ios-head-tot { font-family: 'IBM Plex Mono', monospace; font-size: 11px; font-weight: 600; color: var(--success); }
.ios-head-missing { font-size: 10px; font-weight: 600; color: var(--danger); }
/* Assenza in attesa di approvazione: etichetta sul cartellino finche' non viene approvata. */
.chip-pending { font-size: 9px; font-weight: 700; color: #92400e; background: #fef3c7; border-radius: 4px; padding: 0 4px; margin-left: 4px; white-space: nowrap; }
/* Totale ore del giorno: verde = pari alle previste, giallo = sotto o sopra (mese, settimana, giorno). */
.ios-head-tot.hours-ok, .cal-hours-total.hours-ok { color: var(--success); }
.ios-head-tot.hours-off, .cal-hours-total.hours-off { color: #b45309; background: #fef3c7; border-radius: 6px; padding: 0 5px; }

/* Banda "tutto il giorno": voci a ore senza fascia oraria + spese */
.ios-allday {
  display: grid;
  grid-template-columns: var(--gutter) repeat(var(--cols, 7), minmax(0, 1fr));
  border-bottom: 1px solid var(--grey-border);
  background: var(--grey-bg);
  min-height: 34px;
}
.ios-allday-label {
  font-size: 10px;
  color: var(--grey-light);
  text-align: right;
  padding: 6px 6px 0 0;
  line-height: 1.2;
}
.ios-allday-col { border-left: 1px solid var(--grey-border); padding: 4px; display: flex; flex-direction: column; gap: 3px; }

.ios-body {
  display: grid;
  grid-template-columns: var(--gutter) repeat(var(--cols, 7), minmax(0, 1fr));
  position: relative;
}

.ios-hours { border-right: 1px solid var(--grey-border); background: var(--white); }
.ios-hour-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  color: var(--grey-light);
  text-align: right;
  padding: 2px 6px 0 0;
  box-sizing: border-box;
  transform: translateY(-6px);
}

.ios-col {
  position: relative;
  border-left: 1px solid var(--grey-border);
  background:
    repeating-linear-gradient(to bottom,
      transparent, transparent calc(var(--hpx) - 1px),
      var(--grey-border) calc(var(--hpx) - 1px), var(--grey-border) var(--hpx));
}
.ios-col.off { background-color: #FAFBFE; }
.ios-slot { cursor: pointer; transition: background var(--t-fast); }
.ios-slot:hover { background: rgba(36,86,196,.06); }

.ios-event {
  position: absolute;
  left: 3px; right: 3px;
  background: var(--evt-bg, var(--navy-tint));
  border-left: 3px solid var(--evt, var(--navy));
  border-radius: 6px;
  padding: 3px 6px;
  overflow: hidden;
  cursor: pointer;
  box-sizing: border-box;
  box-shadow: var(--shadow-xs);
  transition: filter var(--t-fast);
}
.ios-event:hover { filter: brightness(.97); }
.ios-event .evt-time { font-family: 'IBM Plex Mono', monospace; font-size: 10px; font-weight: 600; color: var(--evt-fg, var(--navy-dark)); }
.ios-event .evt-title { font-size: 11px; font-weight: 600; color: var(--evt-fg, var(--navy-dark)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ios-event .evt-sub { font-size: 10px; color: var(--grey); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ios-event .evt-act { font-size: 10px; color: var(--evt-fg, var(--navy-dark)); opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Cliente nei cartellini del calendario: sta davanti al progetto ma non gli ruba il peso
   visivo, che resta all'attività. Si accorcia per primo quando lo spazio manca. */
.cal-chip .chip-client {
  font-weight: 500;
  opacity: .72;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 2;
}

/* Linea dell'ora corrente */
.ios-now { position: absolute; left: 0; right: 0; height: 0; border-top: 1.5px solid var(--danger); z-index: 3; pointer-events: none; }
.ios-now::before {
  content: "";
  position: absolute;
  left: -4px; top: -4px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger);
}
.ios-now-label {
  position: absolute;
  right: 4px; top: -8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  color: var(--danger);
  background: var(--white);
  padding: 0 3px;
  border-radius: 3px;
}

/* ── Drag & drop delle attività (solo desktop) ─────────────
   Trascinando il blocco si sposta la fascia oraria; trascinando la maniglia
   (le tre righe in basso) se ne cambia la durata. Passo: 15 minuti. */
.ios-event.draggable { cursor: grab; touch-action: none; }
.ios-event.dragging {
  cursor: grabbing;
  z-index: 4;
  box-shadow: var(--shadow-lg);
  filter: brightness(1.02);
  user-select: none;
}

/* Maniglia: striscia a tutta larghezza sul bordo inferiore, con tre righe al centro.
   Prima era un rettangolino centrato in basso, nella stessa fascia dei tasti spesa/duplica/
   elimina: si coprivano a vicenda e sui blocchi stretti il clic finiva sul tasto sbagliato.
   Ora i tasti stanno in alto a destra e il bordo inferiore è tutto della maniglia. */
.evt-handle {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 10px;
  cursor: ns-resize;
  opacity: 0;
  transition: opacity var(--t-fast);
  background-image: repeating-linear-gradient(
    to bottom,
    var(--evt, var(--navy)) 0 1px,
    transparent 1px 3px);
  background-size: 24px 7px;
  background-position: center 2px;
  background-repeat: no-repeat;
}
.ios-event:hover .evt-handle,
.ios-event.dragging .evt-handle { opacity: .8; }

/* Su telefono/tablet e su touch niente trascinamento: si modifica dal dialog */
@media (max-width: 900px), (pointer: coarse) {
  .ios-event.draggable { cursor: pointer; touch-action: auto; }
  .evt-handle { display: none; }
}

/* Tasto spese nella testata del giorno (settimana): "+ spesa" o il totale già speso */
.ios-exp-btn {
  margin-top: 4px;
  width: 100%;
  border: 1px dashed var(--grey-border);
  border-radius: var(--radius-pill);
  background: none;
  color: var(--grey-light);
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  cursor: pointer;
  white-space: nowrap;
}
.ios-exp-btn:hover:not(:disabled) { border-color: var(--warning); color: #92400E; background: #FDF3DA; }
.ios-exp-btn:disabled { opacity: .45; cursor: default; }
.ios-exp-btn.has-exp { border-style: solid; border-color: #FBE3AE; background: #FDF3DA; color: #92400E; }

/* Spese del giorno per progetto (DayExpensesSummary): verde = collegate a un'attività del
   giorno, rosso = non collegate. «+ Spesa» (.ios-exp-btn) sempre sotto. */
.exp-sum { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; width: 100%; }
.exp-row {
  display: flex; align-items: center; gap: 4px; width: 100%;
  border: 1px solid; border-radius: 6px; padding: 2px 6px;
  font-size: 10.5px; font-weight: 600; cursor: pointer; line-height: 1.3;
}
.exp-row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; font-weight: 500; }
.exp-row.ok { background: #E3F7EF; border-color: #A7E3CB; color: #076C4B; }
.exp-row.ko { background: #FDE8E8; border-color: #F8B4B4; color: #9B1C1C; }
.exp-row:hover { filter: brightness(.97); }
.cal-chip.chip-exp-ok { --evt: #0E9F6E; --evt-bg: #E3F7EF; --evt-fg: #076C4B; }
.cal-chip.chip-exp-ko { --evt: #E02424; --evt-bg: #FDE8E8; --evt-fg: #9B1C1C; }

/* Dettaglio spese del giorno (DayExpensesDialog): gruppi per progetto, badge di collegamento */
.dexp-group { border: 1px solid var(--grey-border); border-radius: 10px; padding: 6px 10px; margin-bottom: 10px; }
.dexp-group.ko { border-color: #F8B4B4; background: #FFF7F7; }
.dexp-head { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; color: var(--navy); padding-bottom: 4px; border-bottom: 1px solid var(--grey-border); }
.dexp-group.ko .dexp-head { color: #9B1C1C; }
.dexp-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid; }
.dexp-badge.client { background: #E3F7EF; border-color: #A7E3CB; color: #076C4B; }
.dexp-badge.own    { background: #F1F5F9; border-color: #CBD5E1; color: #334155; }
.dexp-badge.ko     { background: #FDE8E8; border-color: #F8B4B4; color: #9B1C1C; }

/* Spesa su una singola attività: eredita progetto e fase di quel blocco */
.evt-exp {
  border: 1px solid var(--evt, var(--navy));
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,.85);
  color: var(--evt-fg, var(--navy-dark));
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 5px;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--t-fast);
}
.ios-event:hover .evt-exp,
.evt-exp:focus-visible { opacity: 1; }
.evt-exp:hover { background: #fff; }

/* Elimina: come gli altri due tasti del blocco, ancora piu' a sinistra e in rosso, perche'
   e' l'unico irreversibile dei tre. */
.evt-del {
  border: 1px solid var(--danger);
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,.85);
  color: var(--danger);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 5px;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--t-fast);
}
.ios-event:hover .evt-del,
.evt-del:focus-visible { opacity: 1; }
.evt-del:hover { background: #fff; }

/* Elimina sul cartellino: compare passandoci sopra, per non affollare una riga che di
   suo contiene gia' ore, cliente e attivita'. */
.cal-chip .chip-del {
  margin-left: auto;
  flex-shrink: 0;
  border: none;
  background: none;
  color: var(--danger);
  font-size: 11px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--t-fast);
}
.cal-chip:hover .chip-del,
.cal-chip .chip-del:focus-visible { opacity: 1; }

/* Duplica: stessa pastiglia del tasto spesa, affiancata a sinistra. */
.evt-dup {
  border: 1px solid var(--evt, var(--navy));
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,.85);
  color: var(--evt-fg, var(--navy-dark));
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 5px;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--t-fast);
}
.ios-event:hover .evt-dup,
.evt-dup:focus-visible { opacity: 1; }
/* Barra dei tasti del blocco: in alto a destra, va a capo sui blocchi stretti (attività
   affiancate) invece di sovrapporre i tasti fra loro o alla maniglia della durata in basso. */
.evt-actions {
  position: absolute;
  top: 2px;
  right: 2px;
  left: 2px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 2px;
  z-index: 2;
  pointer-events: none;   /* lo spazio vuoto della barra lascia passare clic e trascinamento */
}
.evt-actions > button { pointer-events: auto; flex-shrink: 0; }
.evt-dup:hover { background: #fff; }

/* Su touch non c'è hover: i tasti restano sempre visibili */
@media (hover: none) {
  .evt-exp { opacity: 1; }
  .evt-dup { opacity: 1; }
  .evt-del { opacity: 1; }
  .cal-chip .chip-del { opacity: .7; }
}

.ios-add {
  width: 100%;
  border: 1px dashed var(--grey-border);
  border-radius: 6px;
  background: none;
  color: var(--grey-light);
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  padding: 4px;
  cursor: pointer;
}
.ios-add:hover { border-color: var(--navy-light); color: var(--navy); background: var(--navy-tint); }

/* ── SATURATION BAR ───────────────────────────────────────── */
.sat-bar-wrap { background: var(--grey-border); border-radius: var(--radius-pill); height: 8px; overflow: hidden; width: 100%; }
.sat-bar-fill { height: 100%; border-radius: var(--radius-pill); transition: width .4s cubic-bezier(.4,0,.2,1); }
.sat-bar-fill.ok   { background: var(--success); }
.sat-bar-fill.warn { background: var(--warning); }
.sat-bar-fill.over { background: var(--danger); }

/* ── NOTIFICHE ────────────────────────────────────────────── */
.notif-panel {
  position: fixed;
  top: var(--topbar-h);
  right: 12px;
  width: 370px;
  max-width: calc(100vw - 24px);
  background: var(--white);
  border: 1px solid var(--grey-border);
  box-shadow: var(--shadow-lg);
  z-index: 1100;
  max-height: calc(100vh - var(--topbar-h) - 16px);
  overflow-y: auto;
  border-radius: var(--radius-lg);
  animation: page-in .18s ease both;
}

.notif-item { padding: 12px 16px; border-bottom: 1px solid var(--grey-border); cursor: pointer; transition: background var(--t-fast); }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--grey-bg); }
.notif-item.unread { background: var(--navy-tint); }
.notif-item.unread .notif-title { font-weight: 700; }

.notif-title { font-size: 13px; color: var(--text); }
.notif-body  { font-size: 12px; color: var(--grey); margin-top: 2px; }
.notif-time  { font-size: 11px; color: var(--grey-light); margin-top: 4px; }

/* ── LOGIN ────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(76,123,224,.35), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(62,143,176,.35), transparent 55%),
    var(--ink);
}

.login-card {
  background: var(--white);
  border-radius: 20px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,.5);
  text-align: center;
  animation: page-in .35s ease both;
}

.login-logo { height: 60px; margin-bottom: 10px; }
.login-brand { font-size: 22px; font-weight: 800; letter-spacing: -.02em; color: var(--ink); margin-bottom: 26px; }

/* ── RADZEN ───────────────────────────────────────────────── */
.rz-button {
  font-family: inherit !important;
  font-weight: 600 !important;
  border-radius: var(--radius) !important;
}
.rz-button.rz-primary { background: var(--navy) !important; border-color: var(--navy) !important; }
.rz-button.rz-primary:hover { background: var(--navy-dark) !important; }

/* Input, dropdown, textarea, datepicker: stessa forma dei bottoni */
.rz-textbox, .rz-textarea, .rz-dropdown, .rz-numeric, .rz-datepicker,
.rz-inputtext, .rz-multiselect, .rz-lookup {
  font-family: inherit !important;
  border-radius: var(--radius) !important;
  border-color: var(--grey-border) !important;
  min-height: 38px;
}
.rz-textbox:focus, .rz-textarea:focus, .rz-inputtext:focus,
.rz-dropdown.rz-state-focused, .rz-numeric.rz-state-focused {
  box-shadow: var(--ring) !important;
  border-color: var(--navy-light) !important;
}
.rz-dropdown-panel, .rz-popup, .rz-autocomplete-panel {
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-lg) !important;
}
.rz-state-highlight, .rz-multiselect-item.rz-state-highlight { background: var(--navy-tint) !important; color: var(--navy-dark) !important; }

/* DataGrid */
.rz-grid-table th,
.rz-grid-table th .rz-column-title,
.rz-grid-table th .rz-column-header-title,
.rz-grid-table th span:not(.rz-sortable-column-icon),
.rz-grid-table thead tr th { background: var(--ink) !important; color: #fff !important; font-weight: 600 !important; }
.rz-grid-table th .rz-sortable-column-icon,
.rz-grid-table th i { color: rgba(255,255,255,.75) !important; }
.rz-datatable tbody tr:hover { background: var(--navy-tint) !important; }

/* Dialog */
.rz-dialog { border-radius: var(--radius-lg) !important; box-shadow: var(--shadow-lg) !important; overflow: hidden; }
.rz-dialog-titlebar { border-bottom: 1px solid var(--grey-border) !important; }
.rz-dialog-title { font-weight: 700 !important; letter-spacing: -.01em; }

/* Switch/checkbox: acceso nel blu di brand, spento grigio chiaro. I due stati vanno
   dichiarati entrambi: col solo "acceso" lo spento prendeva il colore del tema e i due
   si confondevano. Il pallino resta bianco in tutti e due. */
.rz-switch .rz-switch-circle { background: #CBD5E1 !important; border-color: #CBD5E1 !important; }
.rz-switch .rz-switch-circle::before { background: #fff !important; box-shadow: 0 1px 2px rgba(15,23,42,.25); }
.rz-switch.rz-switch-checked .rz-switch-circle,
.rz-chkbox-box.rz-state-active { background: var(--navy) !important; border-color: var(--navy) !important; }
.rz-switch.rz-switch-checked .rz-switch-circle::before { background: #fff !important; }
.rz-switch.rz-state-disabled { opacity: .5; }

/* ── UTILITY ──────────────────────────────────────────────── */
.mono { font-family: 'IBM Plex Mono', monospace; font-variant-numeric: tabular-nums; }
.text-navy { color: var(--navy); }
.text-grey { color: var(--grey); }
.text-muted { color: var(--grey-light); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.w-100 { width: 100%; }

/* Queste erano usate in decine di pagine ma non erano mai state definite: le toolbar non
   andavano a capo (e con overflow-x nascosto il contenuto in eccesso spariva) e i gruppi
   di bottoni azione restavano attaccati. */
.flex-wrap { flex-wrap: wrap; }
.flex-column { flex-direction: column; }
.gap-1 { gap: 4px; }
.gap-4 { gap: 24px; }
.mb-1 { margin-bottom: 4px; }

/* ============================================================
   RESPONSIVE
   Le pagine hanno molti stili inline (griglie a colonne fisse,
   min-width sui dialog): sotto i 900px vanno forzati a colonna
   singola, altrimenti su telefono sfondano lo schermo.
   ============================================================ */

/* Tablet */
@media (max-width: 1100px) {
  .main-content { padding: 20px; }
  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

/* Mobile */
@media (max-width: 900px) {
  :root { --topbar-h: 58px; }

  html, body { font-size: 15px; }

  /* La sidebar diventa un drawer a scomparsa */
  .sidebar {
    width: min(84vw, 300px) !important;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar-mobile-open .sidebar { transform: translateX(0); }
  .sidebar-collapsed .sidebar:hover { width: min(84vw, 300px) !important; }
  .sidebar-collapsed .sidebar:not(:hover) .nav-text,
  .sidebar-collapsed .sidebar:not(:hover) .sidebar-label { display: revert; }
  .sidebar-collapsed .sidebar:not(:hover) .nav-link { justify-content: flex-start; padding: 9px 12px; }
  .sidebar-pin { display: none; }          /* niente pin su mobile: c'è l'hamburger */
  .topbar-hamburger { display: inline-flex; }

  .main-content,
  .sidebar-collapsed .main-content { margin-left: 0; padding: 16px 12px; }
  .app-footer,
  .sidebar-collapsed .app-footer { margin-left: 0; }

  .topbar { padding: 0 8px; gap: 4px; }
  .topbar-logo { height: 32px; }
  .topbar-user { max-width: 96px; }

  .card { padding: 16px 14px; border-radius: 14px; overflow-x: auto; }
  .card-header { flex-wrap: wrap; }

  /* Griglie inline delle pagine (parametri, form, filtri) → una colonna.
     Restano fuori: i calendari (repeat(7,…): le settimane devono restare a 7 giorni)
     e le griglie già fluide (auto-fill/auto-fit), che si adattano da sole. */
  [style*="grid-template-columns"]:not([style*="repeat(7"]):not([style*="auto-fill"]):not([style*="auto-fit"]) {
    grid-template-columns: 1fr !important;
  }
  .cal-grid { gap: 3px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 12px; }

  .cal-cell { min-height: 54px; padding: 4px; }
  .cal-entry { display: none; }            /* su telefono resta il totale ore + pallino */

  /* Timesheet: le azioni (chiudi mese / aggiungi ore / aggiungi spesa) vanno in una barra
     fissa in fondo, così il calendario si prende tutta la larghezza dello schermo. */
  .ts-actions {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 800;
    display: flex !important;
    justify-content: center;
    gap: 8px !important;
    flex-wrap: wrap;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: rgba(255,255,255,.94);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--grey-border);
    box-shadow: 0 -6px 20px -12px rgba(15,23,41,.3);
  }
  .ts-actions { z-index: 1100; }   /* sopra il cronometro (fixed, z-index 1000), che copriva i tasti */
  .ts-actions .rz-button { flex: 1; min-width: 0; max-width: 180px; }
  /* spazio per non finire sotto la barra */
  .main-content { padding-bottom: 84px; }

  /* Timesheet: calendario e pannello del giorno impilati, altezza libera */
  .ts-shell { height: auto !important; }
  .ts-split { flex-direction: column !important; }
  .ts-side  { width: 100% !important; max-height: none !important; }
  .ts-split .cal-grid { min-height: 320px; }

  /* ── Calendario iOS su telefono ────────────────────────── */

  /* Mese: celle compatte, chip minuscole con solo il titolo (come iPhone) */
  .ios-month .cal-cell { min-height: 74px; padding: 3px 3px 4px; gap: 1px; }
  .cal-daynum { min-width: 21px; height: 21px; font-size: 12px; padding: 0 4px; }
  .ios-month .cal-hours-total { font-size: 10px; }
  .cal-chip { font-size: 9px; padding: 1px 3px; border-radius: 4px; gap: 3px; }
  .cal-chip .chip-h { display: none; }        /* niente ore nella chip: spazio per il titolo */
  .cal-chip::before { width: 4px; height: 4px; }
  /* NB: niente nth-of-type per limitare le chip — conta i div fratelli (pallino di quadratura,
     riga numero/ore) e faceva sparire tutte le chip nei giorni col pallino. Le chip stanno
     dentro la cella che scorre: si limitano dall'altezza, non dal CSS. */

  /* Settimana: la griglia oraria scorre in orizzontale, colonne leggibili
     (7 colonne su 390px sarebbero da 40px: illeggibili) */
  .ios-grid { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .ios-grid > .ios-head,
  .ios-grid > .ios-allday,
  .ios-grid > .ios-body { min-width: calc(var(--gutter) + var(--cols) * 108px); }
  .ios-grid[style*="--cols:1"] > .ios-head,
  .ios-grid[style*="--cols:1"] > .ios-allday,
  .ios-grid[style*="--cols:1"] > .ios-body { min-width: 0; }   /* vista giorno: nessuno scroll */
  .ios-head { position: static; }              /* niente sticky dentro un contenitore che scorre */
  .ios-grid { --gutter: 44px; }
  .ios-head-num { min-width: 26px; height: 26px; font-size: 14px; }
  .ios-event { border-radius: 5px; padding: 2px 4px; }
  .ios-event .evt-sub { display: none; }

  /* Dialog → foglio a tutto schermo ancorato in basso (stile iOS).
     Radzen calcola left/top inline in JS sulla larghezza richiesta (es. 500px): se ci si
     limita a cambiare la larghezza, la finestra resta posizionata dove stava e finisce
     decentrata/fuori schermo. Quindi qui si sovrascrive anche la posizione. */
  .rz-dialog-wrapper { inset: 0 !important; }
  .rz-dialog {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    bottom: 0 !important;
    transform: none !important;
    margin: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    max-height: 92dvh !important;
    display: flex !important;
    flex-direction: column;
    border-radius: 18px 18px 0 0 !important;
  }
  .rz-dialog-titlebar { flex-shrink: 0; padding: 12px 14px !important; }
  .rz-dialog-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 14px calc(14px + env(safe-area-inset-bottom)) !important;
  }
  /* I dialog hanno larghezze/min-width fisse inline (es. 720px): sul telefono vanno liberate */
  .rz-dialog-content [style*="min-width"] { min-width: 0 !important; }
  .rz-dialog-content > div { width: auto !important; max-width: 100% !important; }

  /* Target touch */
  .btn, .rz-button { min-height: 42px; }
  /* ...ma non le frecce su/giù dei campi numerici: sono due rz-button impilate in un campo
     alto 38px, e con 42px ciascuna si sovrapponevano in un riquadro blu con una freccia sola. */
  .rz-numeric .rz-button { min-height: 0; }
  .nav-link { min-height: 46px; }
}

@media (max-width: 560px) {
  .stat-grid { grid-template-columns: 1fr !important; }
  /* NB: solo i lati — con lo shorthand si azzerava il padding-bottom che tiene il contenuto
     sopra la barra azioni fissa, che finiva per coprire il fondo di ogni pagina. */
  .main-content { padding-left: 10px; padding-right: 10px; padding-top: 12px; }
  .notif-panel { right: 6px; width: calc(100vw - 12px); }
}

/* ══════════════════════════════════════════════════════════════════════════
   CAPACITÀ FINITA (/pm/capacita) — persone × settimane
   Stessa impalcatura del Macro Planning: UNA riga per persona, con la cella del
   nome in position:sticky, così le righe non si disallineano mai.
   ══════════════════════════════════════════════════════════════════════════ */

.cap-grid {
  --name-w: 200px;
  --cell-w: 96px;
  overflow: auto;
  max-height: 72vh;
  border: 1px solid var(--grey-border);
  border-radius: 10px;
  background: var(--white);
}

.cap-inner { width: max-content; min-width: 100%; }

.cap-row {
  display: flex;
  align-items: stretch;
  background: var(--white);
  border-bottom: 1px solid var(--grey-border);
}
/* L'intestazione è il primo figlio, il totale squadra il secondo: la zebratura
   delle persone parte dal terzo. */
/* ⚠️ La zebratura è `.cap-row:nth-child(odd)` = specificità (0,2,0): batte un
   singolo `.cap-head` (0,1,0) a prescindere dall'ordine. Le righe speciali vanno
   quindi qualificate con `.cap-row`, altrimenti l'intestazione prende il fondo
   chiaro tenendosi il testo bianco — bianco su bianco, illeggibile. */
.cap-row:nth-child(odd) { background: #FAFBFE; }

.cap-row.cap-head {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--navy);
  color: var(--white);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.cap-row.cap-total { background: var(--navy-tint); font-weight: 700; }

.cap-row.cap-unassigned { background: #FDF3DA; }
.cap-unassigned .cap-c-name { color: #92400E; }

/* `background: inherit` prende il fondo della riga: senza, il contenuto
   scorrerebbe sotto la colonna congelata. */
.cap-c-name {
  position: sticky;
  left: 0;
  z-index: 2;
  flex: 0 0 var(--name-w);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: inherit;
  border-right: 2px solid var(--grey-border);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cap-head .cap-c-name { z-index: 5; color: var(--white); }

.cap-c-week {
  flex: 0 0 var(--cell-w);
  padding: 6px 6px;
  border-right: 1px solid rgba(255,255,255,.18);
  text-align: center;
}
.cap-c-week.current { background: rgba(255,255,255,.14); }
.cap-month  { font-size: 10.5px; font-weight: 700; letter-spacing: .03em; }
.cap-weekno { font-size: 10px; font-weight: 400; text-transform: none; opacity: .85; }

.cap-c-cell {
  flex: 0 0 var(--cell-w);
  padding: 7px 8px;
  border-right: 1px solid var(--grey-border);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
}
.cap-c-cell.current { background: #EFF6FF; }
.cap-c-cell:hover { background: var(--grey-bg); }
.cap-total .cap-c-cell,
.cap-head  .cap-c-cell { cursor: default; }

/* ── Indicatore ──────────────────────────────────────────────────────────── */

.cap-bar {
  height: 7px;
  border-radius: 999px;
  background: #E5E7EB;
  overflow: hidden;
}
.cap-bar-fill { height: 100%; border-radius: 999px; background: currentColor; }

.cap-bar.ok   { color: #10b981; }
.cap-bar.full { color: #f59e0b; }
.cap-bar.over { color: #dc2626; }
.cap-bar.none { color: #cbd5e1; }
/* Sopra il 100% la barra è piena: il numero sotto dice di quanto si sfora. */
.cap-bar.over .cap-bar-fill { background: repeating-linear-gradient(
    45deg, #dc2626, #dc2626 4px, #b91c1c 4px, #b91c1c 8px); }

.cap-hours {
  font-family: var(--font-mono, monospace);
  font-size: 10.5px;
  color: var(--grey);
  text-align: center;
  white-space: nowrap;
}
.cap-hours.cap-over { color: #b91c1c; font-weight: 700; }
.cap-sep { opacity: .45; margin: 0 1px; }
.cap-empty { font-size: 11px; color: var(--grey-light); text-align: center; }

@media (max-width: 900px) {
  .cap-grid { --name-w: 130px; --cell-w: 84px; }
}

/* ══════════════════════════════════════════════════════════════════════════
   MACRO-FASI DI PROGETTO (ProjectStage)
   Pastiglia con il colore della macro-fase, usata nel dialog Fasi e Gate e nelle
   corsie del Macro Planning. Il colore arriva dal dato, via --stage-color.
   ══════════════════════════════════════════════════════════════════════════ */

.stage-chip {
  display: inline-block;
  max-width: 100%;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--stage-color, var(--navy));
  background: color-mix(in srgb, var(--stage-color, #2563eb) 12%, white);
  border: 1px solid color-mix(in srgb, var(--stage-color, #2563eb) 35%, white);
}

/* Macro-fase disattivata in Impostazioni: resta leggibile ma si vede che è spenta. */
input.stage-off, .stage-off input { opacity: .55; text-decoration: line-through; }

/* ══════════════════════════════════════════════════════════════════════════
   GANTT DI PROGETTO (/pm/gantt) — vista in stile MS Project
   Due riquadri affiancati dentro UN SOLO contenitore che scorre: a sinistra la
   tabella delle attività (congelata in orizzontale con position:sticky), a destra
   la scala temporale con barre, milestone e frecce delle correlazioni.
   L'allineamento riga-a-riga regge perché entrambi i riquadri usano la stessa
   altezza di riga, passata dal componente in --gantt-row-h / --gantt-head-h.
   ══════════════════════════════════════════════════════════════════════════ */

.gantt-card { padding: 0; overflow: hidden; }

.gantt-body {
  overflow: auto;
  max-height: 620px;
  position: relative;
  background: var(--white);
}

.gantt-grid {
  display: flex;
  align-items: flex-start;
  width: max-content;
  min-width: 100%;
}

/* ── Riquadro attività (congelato a sinistra) ─────────────────────────────── */

.gantt-tasks {
  position: sticky;
  left: 0;
  z-index: 3;
  flex: 0 0 auto;
  background: var(--white);
  border-right: 2px solid var(--grey-border);
}

.gantt-tasks-head,
.gantt-task-row {
  display: flex;
  align-items: center;
  gap: 0;
  white-space: nowrap;
}

.gantt-tasks-head {
  height: var(--gantt-head-h);
  position: sticky;
  top: 0;
  z-index: 5;                       /* angolo: sopra sia le righe sia l'intestazione temporale */
  background: var(--navy);
  color: var(--white);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .02em;
}

.gantt-task-row {
  height: var(--gantt-row-h);
  font-size: 12.5px;
  border-bottom: 1px solid var(--grey-border);
}
/* nth-child(even) = prima riga dati: l'intestazione occupa il posto 1. Deve
   combaciare con la zebratura del riquadro temporale (.gantt-rowline.odd). */
.gantt-task-row:nth-child(even) { background: #FAFBFE; }
.gantt-task-row.is-milestone .gt-c-name { font-weight: 600; }

.gantt-tasks-head > span,
.gantt-task-row  > span {
  padding: 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gt-c-name { width: 224px; display: flex; align-items: center; gap: 6px; }
.gt-c-date { width: 76px;  text-align: center; font-family: var(--font-mono, monospace); font-size: 11.5px; }
.gt-c-dur  { width: 54px;  text-align: right;  font-family: var(--font-mono, monospace); font-size: 11.5px; }
.gt-c-pred { width: 168px; font-size: 11.5px; }
.gt-c-act  { width: 46px;  text-align: center; }

/* Il grigio dei predecessori vale nelle RIGHE: nell'intestazione (fondo navy)
   deve restare il bianco ereditato, altrimenti la colonna è illeggibile. */
.gantt-task-row .gt-c-pred { color: var(--grey); }

.gt-proj {
  font-size: 10px;
  font-weight: 700;
  color: var(--grey-light);
  flex: 0 0 auto;
}

.gt-diamond-mini {
  width: 8px; height: 8px;
  background: var(--ink);
  transform: rotate(45deg);
  flex: 0 0 auto;
}

.gt-link-btn {
  border: 1px solid var(--grey-border);
  background: var(--white);
  border-radius: 6px;
  width: 24px; height: 22px;
  cursor: pointer;
  color: var(--grey);
  line-height: 1;
}
.gt-link-btn:hover { border-color: var(--navy); color: var(--navy); background: var(--navy-tint); }

/* ── Riquadro temporale ───────────────────────────────────────────────────── */

.gantt-time { flex: 1 0 auto; }

.gantt-time-head {
  position: sticky;
  top: 0;
  z-index: 2;
  height: var(--gantt-head-h);
  background: var(--navy);
  color: var(--white);
}

.gantt-tier { position: relative; height: calc(var(--gantt-head-h) / 2); }
.gantt-tier-top    { border-bottom: 1px solid rgba(255,255,255,.22); }
.gantt-tier-bottom { font-size: 10.5px; }

.gantt-tick {
  position: absolute;
  top: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  border-left: 1px solid rgba(255,255,255,.18);
  overflow: hidden;
  white-space: nowrap;
}
.gantt-tick.weekend { color: rgba(255,255,255,.55); font-weight: 400; }

/* z-index 0 crea un contesto di impilamento: i livelli interni (barre e milestone a
   z-index 2) restano DENTRO la tela e non competono con l'intestazione sticky, che ha
   lo stesso z-index e veniva scavalcata scorrendo in giù. */
.gantt-canvas { position: relative; z-index: 0; }

/* Bande di sfondo (weekend, o mesi alterni allo zoom "mese").
   Semitrasparenti di proposito: sono disegnate DOPO le righe alternate e devono
   velarle, così il weekend resta riconoscibile sia sulle righe chiare sia su quelle
   zebrate. Un colore pieno renderebbe invisibili le bande sulle righe già grigie. */
.gantt-band {
  position: absolute;
  top: 0; bottom: 0;
  background: rgba(91, 100, 120, .075);
  z-index: 0;
}

.gantt-rowline {
  position: absolute;
  left: 0; right: 0;
  border-bottom: 1px solid var(--grey-border);
  z-index: 0;
}
.gantt-rowline.odd { background: #FAFBFE; }

.gantt-today {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--danger);
  z-index: 1;
  pointer-events: none;
}

/* ── Frecce delle correlazioni ────────────────────────────────────────────── */

.gantt-links {
  position: absolute;
  top: 0; left: 0;
  z-index: 1;
  pointer-events: none;              /* le frecce non devono rubare il click alle barre */
  overflow: visible;
}

.gantt-link {
  fill: none;
  stroke: var(--grey-light);
  stroke-width: 1.4;
}
.gantt-arrow { fill: var(--grey-light); }

.gantt-link.violated,
.gantt-arrow.violated { stroke: var(--danger); fill: var(--danger); }
.gantt-link.violated  { stroke-width: 1.8; }

/* ── Barre e milestone ────────────────────────────────────────────────────── */

.gantt-bar {
  position: absolute;
  z-index: 2;
  border: 1px solid var(--evt, var(--navy));
  background: var(--evt-bg, var(--navy-tint));
  border-radius: 5px;
  overflow: hidden;
  cursor: grab;
  display: flex;
  align-items: center;
  box-shadow: var(--shadow-xs);
}
.gantt-bar:hover { filter: brightness(.97); }
.gantt-bar.dragging { cursor: grabbing; opacity: .85; box-shadow: var(--shadow); }

/* Avanzamento: quota di ore dichiarate sul budget, come la barra piena di MS Project */
.gantt-bar-fill {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  background: var(--evt, var(--navy));
  opacity: .85;
}

.gantt-bar-text {
  position: relative;
  z-index: 1;
  padding: 0 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--evt-fg, var(--navy-dark));
  white-space: nowrap;
  pointer-events: none;
}

.gantt-ms {
  position: absolute;
  z-index: 2;
  background: var(--ink);
  transform: rotate(45deg);
  cursor: grab;
  box-shadow: var(--shadow-xs);
}
.gantt-ms.dragging   { cursor: grabbing; opacity: .85; }
.gantt-ms.ms-approved { background: var(--success); }
.gantt-ms.ms-rejected { background: var(--danger); }
.gantt-ms.ms-review   { background: var(--warning); }

.gantt-ms-label {
  position: absolute;
  z-index: 2;
  margin-left: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  line-height: 16px;
  white-space: nowrap;
  pointer-events: none;
}

/* ── Barra zoom, avviso vincoli, legenda ──────────────────────────────────── */

.gantt-zoom {
  display: inline-flex;
  border: 1px solid var(--grey-border);
  border-radius: var(--radius);
  overflow: hidden;
}
.gantt-zoom-btn {
  border: 0;
  background: var(--white);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--grey);
  cursor: pointer;
}
.gantt-zoom-btn + .gantt-zoom-btn { border-left: 1px solid var(--grey-border); }
.gantt-zoom-btn:hover  { background: var(--grey-bg); }
.gantt-zoom-btn.active { background: var(--navy); color: var(--white); }

.gantt-alert {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid var(--danger);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: #FDE8E8;
  color: #9B1C1C;
  font-size: 13px;
}

.gantt-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 10px 14px;
  border-top: 1px solid var(--grey-border);
  font-size: 11.5px;
  color: var(--grey);
  background: var(--grey-bg);
}
.gantt-legend span { display: inline-flex; align-items: center; gap: 6px; }
.gantt-legend i { display: inline-block; flex: 0 0 auto; }
.gantt-legend .lg-bar       { width: 22px; height: 10px; border-radius: 3px; background: var(--navy); }
.gantt-legend .lg-ms        { width: 10px; height: 10px; background: var(--ink); transform: rotate(45deg); }
.gantt-legend .lg-link      { width: 22px; height: 0; border-top: 2px solid var(--grey-light); }
.gantt-legend .lg-violated  { width: 22px; height: 0; border-top: 2px solid var(--danger); }
.gantt-legend .lg-today     { width: 2px;  height: 12px; background: var(--danger); }

/* ── Mobile: il drag è già spento dal JS, qui si stringe la parte fissa ───── */
@media (max-width: 900px) {
  .gantt-body { max-height: 70vh; }
  .gt-c-name { width: 140px; }
  .gt-c-pred { display: none; }
  .gt-c-dur  { display: none; }
  .gantt-bar { cursor: default; }
  .gantt-ms  { cursor: default; }
}

/* Pagine «filtri + anteprima» (Report, Report spese, Presenze, Dotazioni, Fatture): i filtri
   sono una barra compatta in alto — campi affiancati che vanno a capo da soli, sotto le opzioni
   (colonne, spunte) e i pulsanti — e l'anteprima prende tutta la larghezza sotto. Prima i filtri
   erano una colonna di 300px ferma a sinistra, alta quanto lo schermo, che rubava spazio
   all'anteprima per tutta la pagina. */
.filter-layout {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
/* min-width 0: la tabella righe di Fatture altrimenti sfonda il riquadro (era il motivo del
   minmax(0,1fr) della vecchia griglia a due colonne). */
.filter-layout > * { min-width: 0; }
.filter-fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px 14px;
    align-items: start;
}
.filter-fields > div > label,
.col-picker > label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 3px;
}
.filter-fields .span-2 { grid-column: span 2; }
.filter-hint { font-size: 11px; margin-top: 4px; color: var(--grey); }
.filter-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px 18px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--grey-border);
}
.filter-options {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 18px;
    font-size: 13px;
}
.filter-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.filter-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}
.col-picker { width: 240px; max-width: 100%; }
@media (max-width: 600px) {
    .filter-fields .span-2 { grid-column: auto; }
    .filter-actions { margin-left: 0; }
    .col-picker { width: 100%; }
}

/* La tabella delle righe scorre da sola invece di allargare la pagina. */
.inv-lines-scroll { overflow-x: auto; }

/* Filtri dello storico fatture: ricerca larga, menu stretti; su telefono uno per riga. */
.inv-history-filters {
    display: grid;
    grid-template-columns: minmax(180px, 2fr) repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}
@media (max-width: 600px) {
    .inv-history-filters { grid-template-columns: minmax(0, 1fr); }
}

/* ══════════════════════════════════════════════════════════════════════════
   CARICO RISORSE (/pm/carico-risorse) — persone/progetti × giorni, a barre
   Colonna dei nomi congelata (sticky) + scala in pixel calcolata dalla pagina
   (PxPerDay cambia con Ore/Giorno/Settimana/Mese). Barre e celle della striscia sono
   posizionate in assoluto dentro .rp-area con left/width in pixel: stessa origine
   per barre, striscia e intestazione, quindi restano allineate a ogni scala.
   L'intestazione ha z-index sopra le barre (vedi la trappola del Gantt): le barre
   stanno in .rp-area, che crea un suo contesto con z-index 0.
   ══════════════════════════════════════════════════════════════════════════ */

.rp-grid {
  --rp-name-w: 230px;
  overflow: auto;
  max-height: 74vh;
  border: 1px solid var(--grey-border);
  border-radius: 10px;
  background: var(--white);
}
.rp-inner { min-width: 100%; }

.rp-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--grey-border); }

.rp-name {
  position: sticky; left: 0; z-index: 2;
  flex: 0 0 var(--rp-name-w);
  padding: 8px 12px;
  background: var(--white);
  border-right: 2px solid var(--grey-border);
  overflow: hidden;
}
.rp-name-main { font-size: 13px; font-weight: 700; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-name-sub  { font-size: 11px; color: var(--grey); margin-top: 2px; }
.rp-name-sub.rp-over { color: #dc2626; font-weight: 600; }

.rp-head { position: sticky; top: 0; z-index: 4; background: var(--navy); color: var(--white); }
.rp-head .rp-name { background: var(--navy); color: var(--white); z-index: 5; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .03em; display: flex; align-items: flex-end; }
.rp-time-head { display: flex; flex-direction: column; }
.rp-months, .rp-days { display: flex; }
.rp-month { font-size: 11px; font-weight: 600; padding: 4px 6px; border-left: 1px solid rgba(255,255,255,.22);
  white-space: nowrap; overflow: hidden; }
.rp-day { text-align: center; font-size: 10.5px; padding: 3px 0; overflow: hidden; white-space: nowrap;
  border-left: 1px solid rgba(255,255,255,.12); }
.rp-day.we { color: rgba(255,255,255,.5); }
.rp-day.today { background: #dc2626; color: #fff; font-weight: 700; border-radius: 4px; }

.rp-area { position: relative; z-index: 0; flex: 1 0 auto; }

.rp-bg { position: absolute; inset: 0; display: flex; pointer-events: none; }
.rp-bg-day { border-left: 1px solid #F1F3F8; }
.rp-bg-day.daystart { border-left-color: #DCE1EA; }
.rp-bg-day.we { background: #F4F6FA; }
.rp-bg-day.today { background: rgba(220, 38, 38, .06); }

.rp-strip { position: relative; height: 20px; margin-top: 2px; }
.rp-cell { position: absolute; top: 0; height: 18px; line-height: 18px;
  font-size: 10px; font-weight: 700; text-align: center; color: #fff; border-right: 1px solid #fff;
  overflow: hidden; white-space: nowrap; }
.rp-cell.free { background: #10b981; }
.rp-cell.full { background: #f59e0b; }
.rp-cell.over { background: #dc2626; }
.rp-cell.off  { background: transparent; }

.rp-bar {
  position: absolute; height: 38px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--bar-c, #4f46e5);
  color: #fff;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
}
.rp-bar.click { cursor: pointer; }
.rp-bar.click:hover { filter: brightness(1.08); box-shadow: 0 3px 10px rgba(0,0,0,.18); }
.rp-bar-t { font-size: 11.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 18px; }
.rp-bar-s { font-size: 10.5px; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-bar-btn { position: absolute; top: 2px; right: 3px; border: 0; background: rgba(255,255,255,.2);
  border-radius: 4px; font-size: 11px; line-height: 1; padding: 2px 3px; cursor: pointer; }
.rp-bar-btn:hover { background: rgba(255,255,255,.4); }
.rp-bar.other { background: #cbd5e1; color: #334155; }
.rp-bar.absence { background: #64748b; }
.rp-bar.absence.pending { background: repeating-linear-gradient(135deg, #64748b 0 6px, #7c8ba1 6px 12px); }
.rp-bar.unassigned { background: #fff; color: #b45309; border: 2px dashed #f59e0b; box-shadow: none; }
.rp-bar.done { opacity: .55; }

@media (max-width: 900px) {
  .rp-grid { --rp-name-w: 140px; }
}
