/* ═══════════════════════════════════════════════════════════
   PROGETTO A HR Suite — CSS v20
   Direzione editoriale / rivista specializzata
   Arancione acceso #FF4A1C · palette calda · tema chiaro + scuro
   Plus Jakarta Sans (UI) · JetBrains Mono (dati/codici)
   ═══════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'Plus Jakarta Sans';
  src: url('fonts/PlusJakartaSans-Variable.woff2') format('woff2');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Source Serif 4';
  src: url('fonts/SourceSerif4-Variable.woff2') format('woff2');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('fonts/JetBrainsMono-Variable.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

/* ═══════════════════════════════════════════════════════════
   DESIGN TOKENS
   ═══════════════════════════════════════════════════════════ */

:root {
  /* ── palette calda — rivista specializzata ── */
  --cream:         #EAE2D8;
  --paper:         #FFFFFF;
  --paper2:        #F5F0EA;
  --paper3:        #E8E2D9;
  --ink:           #2E2420;
  --ink2:          #2E2420;
  --ink3:          #5A524C;

  /* arancione acceso, usato come accento principale */
  --coral:         #FF4A1C;
  --coral-dark:    #C03010;
  --coral-light:   #FFF0E8;
  --coral-border:  rgba(255, 74, 28, 0.35);
  --peach:         #FFAB91;

  /* chrome UI — sidebar + topbar su carta, voce attiva arancione */
  --sidebar-bg:    var(--paper);
  --sidebar-text:  var(--ink);
  --sidebar-text-muted: var(--ink3);
  --sidebar-active-bg: var(--coral-light);
  --sidebar-active-text: var(--coral-dark);
  --topbar-bg:     var(--paper);
  --topbar-text:   var(--ink);
  --topbar-text-muted: var(--ink3);

  --petrol:        #0B7A80;
  --petrol-dark:   #075458;
  --petrol-light:  #E6F5F5;

  --success:       #2FB350;
  --success-dark:  #1E7A38;
  --success-light: rgba(47, 179, 80, 0.10);
  --warning:       #FFA518;
  --warning-dark:  #8A5A00;
  --warning-light: rgba(255, 165, 24, 0.12);
  --danger:        #FF3B30;
  --danger-dark:   #C41E1E;
  --danger-light:  rgba(255, 59, 48, 0.10);

  --border:        #E4DCD3;
  --border2:       #D6CCC2;

  /* ── radius generosi, stile rivista ── */
  --radius-sm:     10px;
  --radius:        14px;
  --radius-lg:     20px;
  --radius-xl:     28px;
  --radius-full:   999px;

  /* ── ombre morbide e calde ── */
  --shadow-sm:     0 2px 10px rgba(60, 40, 25, 0.06);
  --shadow:        0 18px 50px rgba(80, 55, 40, 0.10);
  --shadow-coral:  0 8px 24px rgba(255, 74, 28, 0.18);

  --font-sans:     'Plus Jakarta Sans', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-serif:    'Plus Jakarta Sans', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono:     'JetBrains Mono', 'Courier New', monospace;

  /* ── text styles ── */
  --text-title:    700 1.25rem/1.2 var(--font-sans);
  --text-section:  700 0.6875rem/1.3 var(--font-sans);
  --text-label:    700 0.625rem/1.3 var(--font-sans);
  --text-caption:  500 0.625rem/1.4 var(--font-sans);
  --text-body:     500 0.8125rem/1.5 var(--font-sans);
  --text-stat-lg:  700 1.75rem/1.0 var(--font-sans);
  --text-stat-md:  700 1.4rem/1.1 var(--font-sans);

  /* ── z-index scale ── */
  --z-sticky-bar:      50;
  --z-sidebar:         100;
  --z-datepicker:      2000;
  --z-modal-summary:   9000;
  --z-modal-letter:    9800;
  --z-modal-attachments: 9900;
  --z-modal-detail:    9950;
  --z-modal-otp:       9960;
  --z-modal-import:    9998;
  --z-modal-top:       9999;
  --z-banner:          99999;

  /* ── alias di compatibilità ── */
  --bg:            var(--cream);
  --surface:       var(--paper);
  --surface2:      var(--paper2);
  --surface3:      var(--paper3);
  --text:          var(--ink);
  --text2:         var(--ink2);
  --text3:         var(--ink3);
  --black:         var(--ink);
  --black2:        var(--ink2);
  --black3:        var(--ink3);
  --black4:        rgba(60, 40, 25, 0.05);
  --white:         var(--paper);
  --white2:        rgba(250, 248, 245, 0.78);
  --orange:        var(--coral);
  --orange-dark:   var(--coral-dark);
  --orange-light:  var(--coral-light);
  --orange-border: var(--coral-border);
  --teal:          var(--petrol);
  --teal-dark:     var(--petrol-dark);
  --teal-light:    var(--petrol-light);
  --gold:          var(--coral);
  --gray:          var(--ink3);

  /* ── motion ── */
  --transition-fast: 120ms cubic-bezier(0.22, 1, 0.36, 1);
  --transition-base: 220ms cubic-bezier(0.22, 1, 0.36, 1);
  --transition-slow: 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* ── TEMA SCURO ── */
:root[data-theme="dark"] {
  --cream:         #141210;
  --paper:         #1E1A16;
  --paper2:        #26221D;
  --paper3:        #2F2923;
  --ink:           #F5F0EA;
  --ink2:          #D8CFC6;
  --ink3:          #A89B93;

  --coral:         #FF6B45;
  --coral-dark:    #FF4A1C;
  --coral-light:   #2A1510;
  --coral-border:  rgba(255, 107, 69, 0.40);
  --peach:         #FFAB91;

  --sidebar-bg:    var(--paper);
  --sidebar-text:  var(--ink);
  --sidebar-text-muted: var(--ink3);
  --sidebar-active-bg: var(--coral-light);
  --sidebar-active-text: var(--coral);
  --topbar-bg:     var(--paper);
  --topbar-text:   var(--ink);
  --topbar-text-muted: var(--ink3);

  --petrol:        #38B6BC;
  --petrol-dark:   #0B7A80;
  --petrol-light:  #142B2D;

  --success:       #4CD964;
  --success-dark:  #2FB350;
  --success-light: rgba(76, 217, 100, 0.12);
  --warning:       #FFCC4D;
  --warning-dark:  #FFA518;
  --warning-light: rgba(255, 204, 77, 0.12);
  --danger:        #FF5F57;
  --danger-dark:   #FF3B30;
  --danger-light:  rgba(255, 95, 87, 0.12);

  --border:        #3A3229;
  --border2:       #4A4136;

  --shadow-sm:     0 2px 10px rgba(0, 0, 0, 0.35);
  --shadow:        0 18px 50px rgba(0, 0, 0, 0.45);
  --shadow-coral:  0 8px 28px rgba(255, 107, 69, 0.18);

  --black4:        rgba(245, 240, 234, 0.06);
  --white2:        rgba(30, 26, 22, 0.78);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

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

html {
  color-scheme: light;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 0.875rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--transition-slow), color var(--transition-slow);
}

/* ═══ LAYOUT ═══ */
.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: 234px; min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; z-index: var(--z-sidebar);
  padding: 24px 16px 16px;
  transition: background-color var(--transition-slow);
}
.sidebar-logo {
  padding: 0 10px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 3px;
  margin-bottom: 8px;
}
.sidebar-logo img {
  max-width: 130px; max-height: 40px; object-fit: contain; display: block;
  border-radius: var(--radius-sm);
}
.sidebar-logo .brand {
  color: var(--sidebar-text);
  font-size: 9px; letter-spacing: 2.5px;
  text-transform: uppercase; font-weight: 700; margin-top: 6px;
}
.sidebar-logo .subbrand { color: var(--sidebar-text-muted); font-size: 10px; }

.nav-section {
  padding: 20px 12px 8px;
  font-size: 9px; color: var(--sidebar-text-muted);
  letter-spacing: 2px; text-transform: uppercase; font-weight: 700;
}
.nav-item {
  margin: 3px 0;
  padding: 10px 12px; cursor: pointer;
  display: flex; align-items: center; gap: 11px;
  color: var(--sidebar-text-muted); font-size: 13.5px; font-weight: 600;
  border-radius: var(--radius);
  transition: color var(--transition-fast), background-color var(--transition-fast), transform var(--transition-fast);
  user-select: none;
  position: relative;
}
.nav-item:hover { color: var(--sidebar-text); background: var(--surface2); transform: translateX(3px); }
.nav-item.active { color: var(--sidebar-active-text); background: var(--sidebar-active-bg); font-weight: 700; }
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 4px; height: 22px; border-radius: 2px; background: var(--coral);
  animation: activeBar 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes activeBar { from { height: 0; opacity: 0; } to { height: 22px; opacity: 1; } }
.nav-icon {
  width: 18px; height: 18px; flex-shrink: 0;
  stroke-width: 2.2; stroke: currentColor; fill: none;
  stroke-linecap: round; stroke-linejoin: round;
}
.sidebar::after {
  content: 'Progetto A HR · v20';
  display: block; padding: 14px 10px 0; font-size: 9px; color: var(--sidebar-text-muted);
  margin-top: auto; border-top: 1px solid var(--border); letter-spacing: 0.5px;
}

/* ── Main ── */
.main { margin-left: 234px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* ── Topbar ── */
.topbar {
  background: var(--topbar-bg);
  padding: 22px 28px;
  display: flex; align-items: flex-end; justify-content: space-between;
  position: sticky; top: 0; z-index: var(--z-sticky-bar);
  box-shadow: var(--shadow-sm);
  transition: background-color var(--transition-slow);
}
.topbar-left  { display: flex; align-items: baseline; gap: 12px; }
.topbar-title {
  font: var(--text-title); color: var(--topbar-text);
  position: relative; padding-bottom: 6px;
}
.topbar-title::after {
  content: ''; position: absolute; bottom: -4px; left: 0;
  width: 36px; height: 4px; background: var(--coral); border-radius: 2px;
  transition: background-color var(--transition-slow), width var(--transition-slow);
}
.topbar-sub   { font-size: 11px; color: var(--topbar-text-muted); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar .header-logo { max-width: 130px; max-height: 40px; object-fit: contain; display: block; }
.periodo-label { font-size: 9px; color: var(--topbar-text-muted); letter-spacing: 1px; text-transform: uppercase; }

/* ── Theme toggle ── */
.theme-toggle {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: var(--radius-full);
  border: 1px solid var(--border2); background: var(--surface2); color: var(--text2);
  font-size: 12px; font-weight: 700; cursor: pointer;
  transition: border-color var(--transition-fast), background-color var(--transition-fast), color var(--transition-fast);
}
.theme-toggle:hover { border-color: var(--coral); color: var(--text); }

/* ── Content / Pages ── */
.content { padding: 26px 28px; flex: 1; }
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ═══ CARDS ═══ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px; margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-base), box-shadow var(--transition-base), background-color var(--transition-slow);
}
.card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.card-muted { background: var(--surface2); }
.card-title {
  font: var(--text-section); color: var(--text2);
  margin-bottom: 18px; letter-spacing: 1.2px; text-transform: uppercase;
  display: flex; align-items: center; gap: 10px;
}
.card-title::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--coral);
  flex-shrink: 0;
}

/* ── KPI ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 18px;
  position: relative; overflow: hidden; cursor: default;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-base), box-shadow var(--transition-base), background-color var(--transition-slow);
}
.stat-card::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: var(--coral); border-radius: 2px; opacity: 0;
  transition: opacity var(--transition-base);
}
.stat-card:hover { box-shadow: var(--shadow-coral); transform: translateY(-3px); }
.stat-card:hover::after { opacity: 1; }
.stat-card:hover .stat-label { color: var(--coral-dark); }
.stat-card:hover .stat-value { color: var(--coral-dark); }
.stat-label { display: inline-block; font: var(--text-caption); color: var(--text2); text-transform: uppercase;
              letter-spacing: 1px; margin-bottom: 8px; transition: color var(--transition-base); }
.stat-value { font: var(--text-stat-lg); color: var(--coral); transition: color var(--transition-base); }

/* ═══ FORM ═══ */
.form-grid  { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 18px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font: var(--text-label); text-transform: uppercase;
              letter-spacing: 0.8px; color: var(--text2); transition: color 0.12s; }
.form-group.has-value .form-label { color: var(--coral-dark); }

/* Inputs — vuoto */
input[type="text"], input[type="number"], input[type="email"],
input[type="date"], input[type="month"], input[type="time"], input[type="tel"],
input[type="password"],
select, textarea {
  width: 100%; padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit; font-size: 13.5px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast), color var(--transition-fast);
  outline: none; appearance: none; -webkit-appearance: none;
}
input:hover, select:hover, textarea:hover { border-color: var(--coral-border); }
input:focus, select:focus, textarea:focus {
  border-color: var(--coral) !important;
  box-shadow: 0 0 0 3px var(--coral-light) !important;
  background: var(--surface) !important;
}
/* Compilato — corallo pieno */
input.filled, select.filled, textarea.filled {
  background: var(--coral) !important;
  border-color: var(--coral) !important;
  color: #FFFFFF !important;
  font-weight: 700 !important;
}
input.filled::placeholder { color: rgba(255,255,255,0.5); }
select.filled option { background: var(--surface); color: var(--text); }
input[readonly], input:disabled, select:disabled {
  background: var(--surface2); color: var(--text2); cursor: default; border-color: var(--border);
}
input[type="checkbox"] { accent-color: var(--coral); width: 15px; height: 15px; }

/* ═══ BUTTONS ═══ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 20px; border-radius: var(--radius-full);
  font-size: 13px; font-weight: 700; font-family: inherit;
  cursor: pointer; border: 1px solid transparent;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
  white-space: nowrap; user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible,
.nav-item:focus-visible,
.arch-tab:focus-visible,
.socio-btn:focus-visible,
.cal-day:focus-visible,
.theme-toggle:focus-visible {
  outline: 2px solid var(--coral);
  outline-offset: 2px;
}
.btn-primary   { background: var(--coral); color: #fff; border-color: var(--coral); }
.btn-primary:hover { background: var(--coral-dark); border-color: var(--coral-dark); box-shadow: var(--shadow-coral); }
.btn-secondary { background: transparent; color: var(--text2); border-color: var(--border2); }
.btn-secondary:hover { background: var(--surface2); border-color: var(--coral-border); color: var(--text); }
.btn-danger    { background: var(--danger-light); color: var(--danger-dark); border-color: rgba(196, 30, 30, 0.25); font-size: 12px; }
.btn-danger:hover { background: rgba(255, 59, 48, 0.16); }
.btn-sm  { padding: 7px 14px; font-size: 12px; }
.btn-lg  { padding: 13px 30px; font-size: 14px; }

/* ═══ TABLES ═══ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  background: var(--surface2); color: var(--text2);
  font-weight: 700; font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.9px; padding: 11px 14px;
  border-bottom: 2px solid var(--border);
  text-align: left; white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background-color var(--transition-fast); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--coral-light); }
tbody tr:hover td { color: var(--coral-dark); }
td { padding: 11px 14px; color: var(--text); vertical-align: middle; font-size: 13.5px; transition: color var(--transition-fast); }
td a { color: var(--coral-dark); text-decoration: none; font-weight: 700; }
td a:hover { text-decoration: underline; }

/* ═══ BADGES ═══ */
.badge { display: inline-flex; align-items: center; padding: 4px 11px; border-radius: var(--radius-full); font-size: 11px; font-weight: 700; }
.badge-td { background: var(--teal-light); color: var(--teal-dark); border: 1px solid rgba(11, 122, 128, 0.22); }
.badge-ti { background: var(--coral-light); color: var(--coral-dark); border: 1px solid var(--coral-border); }
.badge-ft { background: var(--success-light); color: var(--success-dark); border: 1px solid rgba(47, 179, 80, 0.25); }
.badge-pt { background: var(--warning-light); color: var(--warning-dark); border: 1px solid rgba(255, 165, 24, 0.25); }

/* ═══ SECTION LABEL ═══ */
.section-label {
  font-size: 10px; font-weight: 700; color: var(--coral-dark);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
}
.section-label::before { content: ''; display: inline-block; width: 7px; height: 7px;
                          background: var(--coral); border-radius: 50%; flex-shrink: 0; }

/* ═══ TOTALE BAR ═══ */
.totale-bar {
  background: var(--coral-light); border: 1px solid var(--coral-border);
  border-radius: var(--radius-lg); padding: 14px 18px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  text-align: center;
}
.totale-label { font: var(--text-caption); color: var(--text3); text-transform: uppercase; letter-spacing: 1px; }
.totale-value { font: var(--text-stat-md); color: var(--coral); }

/* ═══ CF DISPLAY ═══ */
.cf-display {
  font-family: var(--font-mono); font-size: 14px; font-weight: 700;
  color: var(--coral-dark); padding: 10px 14px;
  background: var(--coral-light); border: 1px solid var(--coral-border);
  border-radius: var(--radius); letter-spacing: 2px; min-height: 40px;
  text-align: center; display: flex; align-items: center; justify-content: center;
}

/* ═══ SALARY GRID ═══ */
.salary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-top: 10px; }
.salary-item { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; text-align: center; }
.salary-item:last-child { background: var(--coral-light); border-color: var(--coral-border); }
.s-label { font-size: 9px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 3px; }
.s-value { font-size: 15px; font-weight: 700; color: var(--coral-dark); font-family: var(--font-mono); }

/* ═══ SELETTORE SOCIO ═══ */
.socio-selector { display: flex; border-radius: var(--radius-full); overflow: hidden; border: 1px solid var(--border2); }
.socio-btn { flex: 1; padding: 11px 16px; text-align: center; cursor: pointer;
             font-size: 13.5px; font-weight: 700; color: var(--text2);
             transition: background-color var(--transition-fast), color var(--transition-fast); border: none; background: var(--surface2); }
.socio-btn:hover:not(.active) { background: var(--coral-light); color: var(--text); }
.socio-btn.active { background: var(--coral); color: #fff; font-weight: 800; }
.socio-btn + .socio-btn { border-left: 1px solid var(--border2); }

/* ═══ ARCHIVIO TABS ═══ */
.arch-tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.arch-tab { padding: 8px 17px; border-radius: var(--radius-full); font-size: 12px; font-weight: 700;
            cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--text2);
            transition: border-color var(--transition-fast), color var(--transition-fast), background-color var(--transition-fast); }
.arch-tab:hover  { border-color: var(--coral-border); color: var(--coral-dark); background: var(--coral-light); }
.arch-tab.active { background: var(--coral); color: #fff; border-color: var(--coral); font-weight: 800; }

/* ═══ CCNL TABLE ═══ */
#ccnlTableBody td input { width: 90px; padding: 5px 8px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12px; text-align: right; color: var(--text); }
#ccnlTableBody td input:focus { border-color: var(--coral) !important; box-shadow: 0 0 0 2px var(--coral-light) !important; }

/* ═══ ORARIO TABLE ═══ */
.orario-table .orario-row { display: grid; grid-template-columns: 100px 1fr 1fr;
  gap: 8px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--border); }
.orario-table .orario-row:last-child { border-bottom: none; }
.orario-day { font-size: 12px; font-weight: 700; color: var(--text2); }

/* ═══ CALENDARIO ═══ */
#calModal { display: none; position: fixed; inset: 0; z-index: var(--z-datepicker); }
#calBox { position: absolute; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); width: 280px; padding: 14px; }
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-month-label { font-size: 13px; font-weight: 700; color: var(--text); cursor: pointer; }
.cal-nav { background: none; border: none; color: var(--text2); cursor: pointer; font-size: 16px; padding: 3px 8px; border-radius: var(--radius-full); }
.cal-nav:hover { background: var(--coral-light); color: var(--coral); }
.cal-days-header { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 4px; }
.cal-dh { font-size: 10px; text-align: center; color: var(--text3); font-weight: 700; padding: 3px 0; }
#calDays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-day { font-size: 12px; text-align: center; padding: 6px 0; border-radius: var(--radius-full); cursor: pointer; color: var(--text); transition: background-color var(--transition-fast), color var(--transition-fast); }
.cal-day:hover    { background: var(--coral-light); color: var(--coral-dark); }
.cal-day.selected { background: var(--coral); color: #fff; font-weight: 700; }
.cal-day.today    { color: var(--coral-dark); font-weight: 700; }
.cal-day.empty    { cursor: default; }
.cal-month-grid   { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px 0; }
.cal-month-opt    { font-size: 12px; text-align: center; padding: 8px 4px; border-radius: var(--radius-sm); cursor: pointer; color: var(--text2); }
.cal-month-opt:hover   { background: var(--coral-light); color: var(--coral-dark); }
.cal-month-opt.cal-sel { background: var(--coral); color: #fff; font-weight: 700; }
.cal-year-row  { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
#calYearLabel  { font-size: 13px; font-weight: 700; color: var(--text); }

/* ═══ TOAST ═══ */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: var(--z-modal-top); display: flex; flex-direction: column; gap: 10px; }
.toast { padding: 13px 20px; border-radius: var(--radius); font-size: 13.5px; font-weight: 700;
         color: #fff; box-shadow: var(--shadow); min-width: 240px; animation: toastIn 0.25s cubic-bezier(0.22, 1, 0.36, 1) both; }
.toast.success { background: var(--success-dark); }
.toast.error   { background: var(--danger-dark); }
.toast.info    { background: var(--petrol-dark); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ═══ MODALI ═══ */
/* Gli overlay mantengono display inline (gestito da JS); la parte interna usa classi. */
.modal-overlay { position: fixed; inset: 0; padding: 24px; background: rgba(0, 0, 0, 0.45); backdrop-filter: blur(4px); overflow-y: auto; }
.modal-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 24px; }
.modal-card-lg { max-width: 860px; width: 100%; margin: 0 auto; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; padding: 0; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-title { font: var(--text-title); font-weight: 700; color: var(--coral); }
.modal-close { background: none; border: none; font-size: 22px; color: var(--text3); cursor: pointer; border-radius: var(--radius-sm); }
.modal-close:hover { color: var(--coral); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.modal-body { flex: 1; overflow-y: auto; padding: 20px 22px; }
.modal-toolbar { padding: 8px 22px; border-bottom: 1px solid var(--border); background: var(--surface2); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.modal-toolbar-label { font-size: 10px; color: var(--text3); margin-right: 6px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.modal-toolbar-btn { padding: 4px 9px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; font-size: 13px; color: var(--text); min-width: 32px; }
.modal-toolbar-btn:hover { border-color: var(--coral-border); background: var(--coral-light); }
.modal-toolbar-divider { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.modal-toolbar-hint { margin-left: auto; font-size: 10px; color: var(--text3); font-style: italic; }
.modal-warning { display: none; padding: 10px 22px; background: var(--danger-light); border-bottom: 1px solid rgba(196, 30, 30, 0.2); font-size: 12px; color: var(--danger-dark); }
.modal-editor-hint { font-size: 11px; color: var(--text3); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.modal-editor-hint::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--coral); display: inline-block; }
.modal-badge { display: inline-block; font-size: 10px; background: var(--coral-light); color: var(--coral-dark); padding: 3px 9px; border-radius: var(--radius-sm); font-weight: 700; letter-spacing: 0.3px; }
.modal-section-header { padding: 16px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; background: var(--surface); flex-shrink: 0; }
.modal-section-title { font-size: 15px; font-weight: 700; color: var(--text); }
.modal-section-subtitle { font-size: 11px; color: var(--text3); margin-top: 2px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface2); flex-shrink: 0; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.modal-footer-between { justify-content: space-between; }
.modal-list { font-size: 13px; color: var(--text2); }
.modal-empty { text-align: center; color: var(--text3); padding: 16px; }
.modal-divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ═══ RELOAD CONFIRM ═══ */
.reload-confirm-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 10px; }
.reload-confirm-table th { background: var(--surface2); color: var(--text); font-weight: 700;
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px;
  padding: 8px 10px; border-bottom: 1px solid var(--coral-border); text-align: left; }
.reload-confirm-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); color: var(--text); font-size: 12px; }
.reload-confirm-table tr:last-child td { border-bottom: none; }
.reload-ok   { color: var(--success-dark); font-weight: 700; }
.reload-miss { color: var(--danger-dark); font-weight: 700; }
.reload-val  { color: var(--coral-dark); font-weight: 700; font-family: var(--font-mono); font-size: 11px; }
.ts-badge { display: inline-flex; align-items: center; gap: 5px; background: var(--coral-light);
  border: 1px solid var(--coral-border); color: var(--coral-dark); border-radius: var(--radius-full);
  padding: 4px 12px; font-size: 11px; font-weight: 700; }

/* ═══ STATUS DOT ═══ */
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.status-dot.ok      { background: var(--success); }
.status-dot.warn    { background: var(--warning); }
.status-dot.missing { background: var(--danger); }

/* ═══ MISC ═══ */
code { background: var(--coral-light); padding: 2px 7px; border-radius: var(--radius-sm); color: var(--coral-dark); font-size: 12px; font-family: var(--font-mono); }
#periodoFilter { border-color: var(--coral-border); }
#regFilterRow input { padding: 4px 7px; font-size: 11px; border-radius: var(--radius-sm); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }
#server-banner { display: none; position: fixed; top: 0; left: 0; right: 0; z-index: var(--z-banner);
  background: var(--danger-dark); color: #fff; text-align: center; padding: 12px; font-size: 13px; font-weight: 700; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }

/* salary grid total row */
.salary-item-total { background: var(--coral-light) !important; border-color: var(--coral-border) !important; }
.salary-item-total .s-label { color: var(--text2); font-weight: 700; }
.salary-item-total .s-value { font-size: 14px; }

/* numeri tabellari */
.tabular-nums { font-variant-numeric: tabular-nums; }

/* ═══ FIRMA DIGITALE ═══════════════════════════════════════════════════════ */

/* Editor anteprima lettera */
.anteprima-editor {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  font-family: 'Times New Roman', Times, serif;
  font-size: 13px;
  line-height: 1.8;
  color: var(--text);
  min-height: 400px;
}
.anteprima-para {
  margin: 0;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  outline: none;
  white-space: pre-wrap;
  transition: border-color var(--transition-fast), background var(--transition-fast);
  min-height: 1.5em;
}
.anteprima-para:focus {
  border-color: var(--coral-border);
  background: var(--coral-light);
}
.anteprima-para.bold-para { font-weight: 700; }
.anteprima-para.heading-para { font-weight: 700; margin-top: 10px; font-size: 13.5px; }
.anteprima-para.empty-para { color: var(--text3); font-style: italic; min-height: 0.8em; }

/* Drop zone upload esterno */
#firmaDropZone {
  border: 2px dashed var(--border2);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
  background: var(--surface2);
  cursor: default;
}
#firmaDropZone.dragover {
  border-color: var(--coral);
  background: var(--coral-light);
}
.dropzone-icon { font-size: 32px; margin-bottom: 8px; opacity: 0.5; }
.dropzone-label { font-size: 13.5px; color: var(--text2); }
.dropzone-label span { color: var(--coral-dark); font-weight: 700; }

/* Badge stato firma */
.firma-stato {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.firma-stato.lettera          { background: var(--coral-light); color: var(--coral-dark); }
.firma-stato.in-attesa-firma  { background: var(--petrol-light); color: var(--petrol-dark); }
.firma-stato.inviata          { background: var(--success-light); color: var(--success-dark); }

/* Badge origine */
.firma-origine {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--surface2);
  color: var(--text2);
  border: 1px solid var(--border);
}

/* Bottone avvia firma */
.btn-firma {
  background: none;
  border: 1px solid var(--petrol);
  color: var(--petrol);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}
.btn-firma:hover { background: var(--petrol); color: #fff; }
.btn-firma:disabled { opacity: 0.45; cursor: not-allowed; border-color: var(--border2); color: var(--text3); }

/* ═══ FILTRI COLONNA ═══ */
.filtri-row th {
  padding: 4px 6px !important;
  background: var(--surface2) !important;
  border-bottom: 1px solid var(--border) !important;
}
.col-filter {
  width: 100%;
  padding: 4px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 10px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  transition: border-color var(--transition-fast);
}
.col-filter:focus { outline: none; border-color: var(--coral); }
.col-filter option { font-size: 11px; }
#archivioTableBody td,
#archProrogheBody td,
#archPassaggiBody td,
#archivioTrasTableBody td,
#firmaTableBody td { font-weight: 500; }

/* ═══ UTILITY ═══ */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.flex-wrap { flex-wrap: wrap; }
.gap-4 { gap: 4px; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.gap-12 { gap: 12px; }
.gap-14 { gap: 14px; }
.gap-16 { gap: 16px; }
.gap-18 { gap: 18px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mt-16 { margin-top: 16px; }
.mt-18 { margin-top: 18px; }
.mt-20 { margin-top: 20px; }
.mb-8 { margin-bottom: 8px; }
.mb-10 { margin-bottom: 10px; }
.mb-12 { margin-bottom: 12px; }
.mb-14 { margin-bottom: 14px; }
.mb-16 { margin-bottom: 16px; }
.mb-18 { margin-bottom: 18px; }
.mb-20 { margin-bottom: 20px; }
.p-12 { padding: 12px; }
.p-14 { padding: 14px; }
.p-16 { padding: 16px; }
.p-18 { padding: 18px; }
.p-20 { padding: 20px; }
.text-muted { color: var(--text3); }
.text-small { font-size: 11px; }
.text-sm { font-size: 12px; }
.text-accent { color: var(--coral-dark); }
.text-bold { font-weight: 700; }
.bg-surface2 { background: var(--surface2); }
.border-subtle { border: 1px solid var(--border); }
.rounded { border-radius: var(--radius); }
.w-full { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 1024px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.items-baseline { align-items: baseline; }
.ml-3 { margin-left: 3px; }
.uppercase { text-transform: uppercase; }
.tracking-wide { letter-spacing: 1px; }

.chart-box { position: relative; height: 200px; display: flex; align-items: center; justify-content: center; }
.chart-center { position: absolute; text-align: center; pointer-events: none; }
.chart-center .stat-value { font-size: 28px; }
.chart-legend { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; font-size: 11px; }

.info-banner { display: none; margin-top: 10px; padding: 12px 14px; background: var(--coral-light); border: 1px solid var(--coral-border); border-radius: var(--radius); font-size: 12.5px; color: var(--text2); }
.info-banner strong { color: var(--coral-dark); }

.checkbox-row { display: flex; align-items: center; gap: 10px; margin-bottom: 0; }
.checkbox-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--coral); flex-shrink: 0; }
.checkbox-row label { font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; margin: 0; }
.checkbox-row label strong { color: var(--coral-dark); }

.sostituzione-block { display: none; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }

.helper-text { font-size: 11px; color: var(--text3); margin-top: 6px; padding-left: 2px; }
.helper-text strong { color: var(--coral-dark); }

.col-span-2 { grid-column: span 2; }
.w-90 { max-width: 90px; }
.cf-input { letter-spacing: 1.5px; font-family: var(--font-mono); }
.cursor-pointer { cursor: pointer; }

.summary-box { margin: 14px 0; padding: 14px 16px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); }
.summary-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.summary-left { display: flex; gap: 16px; flex-wrap: wrap; align-items: baseline; }
.summary-label { font-size: 11px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; }
.summary-value { font-size: 22px; font-weight: 700; color: var(--coral); }
.summary-items { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11px; color: var(--text3); }

.body-text { font-size: 13px; line-height: 1.8; color: var(--text2); }
.body-text strong { color: var(--coral-dark); }
.hint { font-size: 11px; color: var(--text3); margin-top: 4px; }
.inail-info { font-size: 10px; color: var(--text3); margin-top: 3px; min-height: 14px; }
.file-input-btn { position: relative; cursor: pointer; }
.file-input-btn input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text2); cursor: pointer; }
.label-hint { font-size: 10px; color: var(--text3); }
.collapsible-group { display: none; margin-bottom: 14px; }
.note-box { padding: 10px 14px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); font-size: 12px; color: var(--text2); }
.actions { display: flex; gap: 12px; justify-content: flex-end; padding-bottom: 32px; }
.w-220 { max-width: 220px; }
.ml-auto { margin-left: auto; }
.collocation-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }

/* ═══ UTILITY SPACING / WIDTHS ═══ */
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-header .card-title { margin: 0; }
.mt-6 { margin-top: 6px; }
.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mt-14 { margin-top: 14px; }
.mb-10 { margin-bottom: 10px; }
.mb-14 { margin-bottom: 14px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.grid-full { grid-column: 1 / -1; }
.table-empty { text-align: center; color: var(--text3); padding: 20px; }
.dropzone-file { margin-top: 8px; font-size: 12px; color: var(--coral); font-weight: 600; }
.table-title { font-size: 11px; font-weight: 700; color: var(--text); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.8px; }
.body-text-lg { font-size: 13px; line-height: 2.4; color: var(--text2); }
.body-text-lg strong { color: var(--text); }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.m-0 { margin: 0 !important; }
.max-w-520 { max-width: 520px; }
.btn-filter { padding: 5px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 11px; background: var(--surface); color: var(--text2); cursor: pointer; transition: border-color var(--transition-fast), color var(--transition-fast); }
.btn-filter:hover { border-color: var(--coral-border); color: var(--coral); }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.section-header .section-label { margin: 0; }
.section-actions { display: flex; gap: 8px; align-items: center; }
.input-sm { width: 130px; padding: 5px 10px; font-size: 12px; border-radius: var(--radius-sm); }
.flex-row { display: flex; align-items: center; gap: 10px; }
.flex-row-wrap { flex-wrap: wrap; }
.align-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.info-card-title { color: var(--coral); font-size: 11px; letter-spacing: 2px; text-transform: uppercase; margin-bottom: 10px; font-weight: 700; }
.info-list { list-style: none; display: flex; flex-direction: column; gap: 7px; font-size: 12px; color: var(--text2); }
.info-list strong { color: var(--text); }
.code-box { font-size: 11px; background: var(--surface2); padding: 12px 14px; border-radius: var(--radius); max-height: 300px; overflow-y: auto; white-space: pre-wrap; color: var(--text2); margin-top: 10px; }
.max-w-600 { max-width: 600px; }
.w-145 { width: 145px; }
.grid-span-2 { grid-column: span 2; }
.text-mono { font-family: var(--font-mono); }

/* ═══ RESPONSIVE ═══ */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; min-height: auto; position: relative; border-right: none; border-bottom: 1px solid var(--border); }
  .main { margin-left: 0; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 12px; }
  .topbar-right { width: 100%; justify-content: space-between; }
  .stats-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}


/* ═══ BLOCCO UTENTE COLLEGATO (sidebar) ═══ */
.sidebar-user {
  margin-top: auto; padding: 14px 12px 4px;
  border-top: 1px solid var(--border);
}
.sidebar-user .su-nome {
  font-size: 12.5px; font-weight: 700; color: var(--sidebar-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user .su-ruolo {
  font-size: 9px; letter-spacing: 1.4px; text-transform: uppercase;
  font-weight: 700; color: var(--sidebar-text-muted); margin-top: 2px;
}
.sidebar-user .su-azioni { display: flex; gap: 6px; margin-top: 10px; }
.sidebar-user .su-azioni .btn { flex: 1; justify-content: center; padding: 6px 8px; font-size: 11px; }

/* Badge di stato nella tabella utenti */
.badge-ruolo, .badge-stato {
  display: inline-block; padding: 3px 10px; border-radius: var(--radius-full);
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px;
}
.badge-ruolo.admin   { background: var(--coral-light); color: var(--coral-dark); }
.badge-ruolo.utente  { background: var(--surface2); color: var(--text3); }
.badge-stato.attivo  { background: var(--success-light); color: var(--success-dark); }
.badge-stato.sospeso { background: var(--danger-light); color: var(--danger-dark); }
