/* ============================================================
   Stili Commissione Ingegneri Dipendenti - Ordine di Brescia
   Design System Professionale, Istituzionale e Reattivo
   ============================================================ */

:root {
  --primary: #0b2545;
  --primary-light: #134074;
  --primary-hover: #07192f;
  --accent: #0284c7;
  --accent-light: #e0f2fe;
  --gold: #d97706;
  --gold-light: #fef3c7;
  
  /* Stati presenze */
  --status-presenza: #16a34a;        /* Verde: Presente in presenza */
  --status-presenza-bg: #dcfce7;
  --status-presenza-border: #86efac;
  
  --status-streaming: #ca8a04;       /* Giallino: Presente in streaming */
  --status-streaming-bg: #fef9c3;
  --status-streaming-border: #fde047;

  --status-giustificato: #9333ea;    /* Violetto: Assente giustificato */
  --status-giustificato-bg: #f3e8ff;
  --status-giustificato-border: #c084fc;

  --status-ingiustificato: #dc2626;  /* Rosso: Assente ingiustificato */
  --status-ingiustificato-bg: #fee2e2;
  --status-ingiustificato-border: #fca5a5;

  --status-none: #94a3b8;            /* Grigio: Non registrato / Da svolgere */
  --status-none-bg: #f1f5f9;
  --status-none-border: #cbd5e1;

  /* Neutri */
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --border-focus: #3b82f6;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.07);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
}

/* Header Istituzionale */
.app-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #ffffff;
  padding: 1.25rem 2rem;
  box-shadow: var(--shadow);
  position: relative;
  border-bottom: 3px solid var(--gold);
}

.header-container {
  max-width: 1750px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.brand-logo {
  width: 58px;
  height: 58px;
  background: #ffffff;
  color: var(--primary);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 800;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.8);
  flex-shrink: 0;
}

.brand-titles h1 {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.15rem;
  line-height: 1.2;
}

.brand-titles .subtitle {
  font-size: 0.95rem;
  color: #cbd5e1;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.info-banner {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-md);
  font-size: 0.83rem;
  max-width: 540px;
}

.info-banner strong {
  color: #fde047;
}

.info-banner ul {
  list-style: none;
  margin-top: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.info-banner li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Layout Principale */
.app-container {
  max-width: 1750px;
  margin: 1.5rem auto;
  padding: 0 1.5rem 3rem 1.5rem;
}

/* Statistiche & KPI */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.kpi-content .kpi-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.kpi-content .kpi-value {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.kpi-content .kpi-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Barra degli Strumenti (Toolbar) */
.toolbar-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.search-filter-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  flex: 1;
}

.search-box {
  position: relative;
  min-width: 280px;
  flex: 1;
  max-width: 420px;
}

.search-box input {
  width: 100%;
  padding: 0.55rem 0.85rem 0.55rem 2.2rem;
  font-size: 0.88rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-main);
  color: var(--text-main);
  outline: none;
  transition: all 0.2s;
}

.search-box input:focus {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.search-box .search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}

.filter-select {
  padding: 0.55rem 0.85rem;
  font-size: 0.88rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-main);
  outline: none;
  cursor: pointer;
}

.filter-select:focus {
  border-color: var(--accent);
}

.action-buttons {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
}

/* Pulsanti */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-size: 0.86rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(11, 37, 69, 0.2);
}

.btn-primary:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
}

.btn-success {
  background: #15803d;
  color: #ffffff;
}

.btn-success:hover {
  background: #166534;
}

.btn-outline {
  background: #ffffff;
  border-color: var(--border);
  color: var(--text-main);
}

.btn-outline:hover {
  background: var(--bg-main);
  border-color: #cbd5e1;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
}

.btn-danger-outline {
  background: #ffffff;
  border-color: #fca5a5;
  color: #dc2626;
}

.btn-danger-outline:hover {
  background: #fef2f2;
}

/* Legenda Presenze */
.legend-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
}

.legend-title {
  font-weight: 700;
  color: var(--text-main);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--bg-main);
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* Tabella Presenze & Struttura */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: visible;
  position: relative;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  position: relative;
}

.presenze-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.84rem;
  text-align: left;
}

/* Header Tabella */
.presenze-table thead th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 700;
  padding: 0.85rem 0.75rem;
  border-bottom: 2px solid var(--border);
  border-right: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 10;
  user-select: none;
}

.presenze-table thead th.sortable {
  cursor: pointer;
  transition: background 0.15s;
}

.presenze-table thead th.sortable:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.sort-icon {
  margin-left: 0.35rem;
  font-size: 0.75rem;
  opacity: 0.4;
}

.sortable.active-sort .sort-icon {
  opacity: 1;
  color: var(--accent);
}

/* Colonne Fisse a Sinistra (Sticky) */
.col-sticky-1 {
  position: sticky;
  left: 0;
  z-index: 5;
  background: #ffffff;
  width: 140px;
  min-width: 140px;
  max-width: 140px;
  white-space: nowrap;
  box-sizing: border-box;
}

.col-sticky-2 {
  position: sticky;
  left: 140px;
  z-index: 5;
  background: #ffffff;
  width: 190px;
  min-width: 190px;
  max-width: 240px;
  white-space: nowrap;
  box-sizing: border-box;
}

.col-sticky-3 {
  position: sticky;
  left: 330px;
  z-index: 5;
  background: #ffffff;
  width: 85px;
  min-width: 85px;
  max-width: 85px;
  white-space: nowrap;
  box-sizing: border-box;
  text-align: center;
  box-shadow: 4px 0 6px -2px rgba(0, 0, 0, 0.08);
}

thead th.col-sticky-1 {
  z-index: 85 !important;
  background: #f1f5f9;
  width: 140px;
  min-width: 140px;
  max-width: 140px;
}

thead th.col-sticky-2 {
  z-index: 85 !important;
  background: #f1f5f9;
  left: 140px;
  width: 190px;
  min-width: 190px;
  max-width: 240px;
}

thead th.col-sticky-3 {
  z-index: 85 !important;
  background: #f1f5f9;
  left: 330px;
  width: 85px;
  min-width: 85px;
  max-width: 85px;
  box-shadow: 4px 0 6px -2px rgba(0, 0, 0, 0.08);
}

/* Righe e Celle */
.presenze-table tbody tr {
  transition: background 0.12s ease;
}

.presenze-table tbody tr:hover {
  background-color: #f8fafc;
  position: relative;
  z-index: 55;
}

.presenze-table tbody tr:hover td.col-sticky-1,
.presenze-table tbody tr:hover td.col-sticky-2,
.presenze-table tbody tr:hover td.col-sticky-3 {
  background-color: #f1f5f9;
}

/* Eleva la colonna Cognome/Nome del commissario in hover sopra le colonne e righe adiacenti (elimina il taglio del tooltip da parte di Azioni) */
.presenze-table tbody tr:hover td.col-sticky-2,
.presenze-table tbody td.col-sticky-2:hover {
  z-index: 75 !important;
}

.presenze-table tbody td {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap; /* Le colonne si adattano alla larghezza naturale del testo */
}

.cell-multiline {
  white-space: normal !important;
  min-width: 220px;
  max-width: 360px;
  line-height: 1.35;
  font-size: 0.8rem;
}

/* Informazioni Commissario */
.comm-role-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.role-coordinatore {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.role-segretario {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.role-referente {
  background: #fce7f3;
  color: #9d174d;
  border: 1px solid #fbcfe8;
}

.role-commissario {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

.comm-name {
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
}

.comm-name-text {
  transition: color 0.15s ease;
}

.comm-name:hover .comm-name-text {
  color: var(--primary);
}

/* Badge Percentuale al passaggio del mouse sul commissario */
.comm-hover-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem 0.45rem;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  position: relative;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  opacity: 0.9;
}

.comm-name:hover .comm-hover-badge {
  transform: scale(1.08);
  opacity: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.comm-hover-badge.badge-pct-high {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.comm-hover-badge.badge-pct-mid {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.comm-hover-badge.badge-pct-low {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

.comm-hover-badge.badge-pct-none {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
}

/* Tooltip Card Dettagliata al passaggio del mouse sul badge */
.comm-hover-tooltip {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  margin-top: 8px;
  background: #0f172a;
  color: #ffffff;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.76rem;
  font-weight: 400;
  line-height: 1.4;
  white-space: nowrap;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.45), 0 8px 10px -6px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.15);
  z-index: 1000;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
  pointer-events: none;
}

.comm-hover-tooltip::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: transparent transparent #0f172a transparent;
}

.comm-name:hover .comm-hover-tooltip,
.comm-hover-badge:hover .comm-hover-tooltip {
  visibility: visible;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Per le ultime 4 righe in fondo alla tabella, apri il tooltip verso l'alto per non toccare o coprire il footer */
.presenze-table tbody tr:nth-last-child(-n+4) .comm-hover-tooltip {
  top: auto;
  bottom: 100%;
  margin-top: 0;
  margin-bottom: 8px;
  transform: translateX(-50%) translateY(4px);
}

.presenze-table tbody tr:nth-last-child(-n+4) .comm-hover-tooltip::before {
  bottom: auto;
  top: 100%;
  border-color: #0f172a transparent transparent transparent;
}

.presenze-table tbody tr:nth-last-child(-n+4) .comm-name:hover .comm-hover-tooltip,
.presenze-table tbody tr:nth-last-child(-n+4) .comm-hover-badge:hover .comm-hover-tooltip {
  transform: translateX(-50%) translateY(0);
}

.comm-hover-tooltip .tooltip-header {
  font-weight: 700;
  color: #38bdf8;
  font-size: 0.82rem;
  margin-bottom: 2px;
}

.comm-hover-tooltip .tooltip-pct {
  color: #f8fafc;
  margin-bottom: 4px;
}

.comm-hover-tooltip .tooltip-breakdown {
  font-size: 0.72rem;
  color: #cbd5e1;
}

.comm-name a {
  color: inherit;
  text-decoration: none;
}

.comm-contact {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  white-space: nowrap;
}

.comm-contact:hover {
  color: var(--accent);
  text-decoration: underline;
}

.badge-tag {
  display: inline-block;
  background: #f1f5f9;
  color: #334155;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  border: 1px solid #e2e8f0;
  margin-right: 0.25rem;
  margin-bottom: 0.25rem;
}

/* Intestazione Riunione */
.meeting-header {
  text-align: center;
  min-width: 110px;
  padding: 0.5rem 0.6rem !important;
}

.meeting-date {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-main);
  display: block;
}

.meeting-weekday {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.meeting-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 12px;
  margin-top: 0.25rem;
  text-transform: uppercase;
}

.badge-presenza {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.badge-streaming {
  background: #fef9c3;
  color: #a16207;
  border: 1px solid #fef08a;
}

.badge-misto {
  background: #e0e7ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
}

.meeting-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  display: block;
  margin-top: 0.15rem;
}

.meeting-actions-btn {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-size: 0.75rem;
  margin-top: 0.2rem;
}

.meeting-actions-btn:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

/* Pallino Presenza (Dot) */
.cell-presenza {
  text-align: center;
  padding: 0.4rem !important;
  cursor: pointer;
  position: relative;
}

.cell-presenza:hover {
  background-color: #f1f5f9;
}

.status-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  cursor: pointer;
}

.status-dot:hover {
  transform: scale(1.15);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.25);
}

.dot-presenza {
  background-color: var(--status-presenza);
  color: #ffffff;
  border: 2px solid var(--status-presenza-border);
}

.dot-streaming {
  background-color: var(--status-streaming);
  color: #ffffff;
  border: 2px solid var(--status-streaming-border);
}

.dot-giustificato {
  background-color: var(--status-giustificato);
  color: #ffffff;
  border: 2px solid var(--status-giustificato-border);
}

.dot-ingiustificato {
  background-color: var(--status-ingiustificato);
  color: #ffffff;
  border: 2px solid var(--status-ingiustificato-border);
}

.dot-none {
  background-color: var(--status-none-bg);
  color: var(--status-none);
  border: 2px dashed var(--status-none-border);
}

/* Colonne Percentuali e Annuali */
.col-annual-pct {
  background: #eff6ff !important;
  text-align: center;
  min-width: 105px;
  font-weight: 700;
  border-left: 2px solid #bfdbfe !important;
  border-right: 2px solid #bfdbfe !important;
}

.col-total-pct {
  background: #fdf2f8 !important;
  text-align: center;
  min-width: 115px;
  font-weight: 800;
  border-left: 2px solid #fbcfe8 !important;
  border-right: 2px solid #fbcfe8 !important;
}

.pct-pill {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.65rem;
  border-radius: 16px;
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.pct-high {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.pct-mid {
  background: #fef9c3;
  color: #854d0e;
  border: 1px solid #fde047;
}

.pct-low {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.pct-sub {
  font-size: 0.65rem;
  font-weight: 500;
  opacity: 0.8;
  margin-top: 0.15rem;
}

/* Colonna Azioni Commissario */
.col-actions {
  width: 85px;
  min-width: 85px;
  max-width: 85px;
  text-align: center;
  padding: 0.35rem 0.2rem !important;
  vertical-align: middle;
}

.row-actions-group {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.row-actions-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.row-actions-bottom {
  display: flex;
  justify-content: center;
  margin-top: 1px;
}

.row-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.2rem 0.3rem;
  border-radius: 4px;
  font-size: 0.85rem;
  line-height: 1;
  transition: all 0.12s;
}

.row-action-btn:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.row-action-delete {
  padding: 0.15rem 0.3rem;
  font-size: 0.82rem;
}

.row-action-delete:hover {
  background: #fee2e2;
  color: #dc2626;
}

/* Riga Riepilogo Finale (Footer Tabella) */
.presenze-table tfoot th,
.presenze-table tfoot td {
  background: #f8fafc;
  font-weight: 700;
  padding: 0.85rem 0.75rem;
  border-top: 2px solid var(--border);
  position: sticky;
  bottom: 0;
  z-index: 10;
}

.tfoot-sticky-group {
  position: sticky;
  left: 0;
  z-index: 25 !important;
  background: #f1f5f9 !important;
  width: 415px;
  min-width: 415px;
  box-shadow: 4px 0 6px -2px rgba(0, 0, 0, 0.08);
}

.tfoot-summary-cell {
  text-align: center;
  font-size: 0.75rem;
  line-height: 1.25;
}

/* Header Ripetuto a Fondo Tabella */
.tfoot-repeated-headers th {
  background: #f1f5f9 !important;
  color: var(--text-main) !important;
  font-weight: 700 !important;
  font-size: 0.78rem !important;
  border-top: 2px solid var(--border) !important;
  border-bottom: 2px solid var(--primary) !important;
  padding: 0.6rem 0.55rem !important;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
}

.tfoot-repeated-headers th:hover {
  background: #e2e8f0 !important;
  color: var(--primary) !important;
}

.tfoot-repeated-headers .col-sticky-1 {
  position: sticky;
  left: 0;
  z-index: 15;
  background: #f1f5f9;
}

.tfoot-repeated-headers .col-sticky-2 {
  position: sticky;
  left: 140px;
  z-index: 15;
  background: #f1f5f9;
}

.tfoot-repeated-headers .col-sticky-3 {
  position: sticky;
  left: 330px;
  z-index: 15;
  background: #f1f5f9;
  box-shadow: 4px 0 6px -2px rgba(0, 0, 0, 0.08);
}

.tfoot-repeated-headers .meeting-header {
  padding: 0.4rem 0.35rem !important;
  min-width: 95px;
}

.tfoot-repeated-headers .meeting-date {
  font-size: 0.78rem;
}

.tfoot-repeated-headers .meeting-badge {
  font-size: 0.62rem;
  padding: 0.1rem 0.35rem;
}

/* Barra Inferiore Tabella con Info e Azioni Rapide */
.table-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: #f8fafc;
  border-top: 1px solid var(--border);
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.table-bottom-info {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.table-bottom-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Pulsante Fluttuante Rapido per Tornare a Inizio Tabella */
.btn-floating-scroll {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99;
  background: var(--primary);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 30px;
  padding: 0.55rem 1rem;
  font-size: 0.82rem;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(11, 37, 69, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0.95;
}

.btn-floating-scroll:hover {
  background: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(11, 37, 69, 0.4);
  opacity: 1;
}

/* Popover Rapido Selezione Presenza */
.presence-popover {
  position: absolute;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  z-index: 100;
  min-width: 175px;
  animation: popoverFadeIn 0.15s ease-out;
}

@keyframes popoverFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.presence-popover-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: left;
  width: 100%;
  transition: background 0.12s;
}

.presence-popover-item:hover {
  background: #f1f5f9;
}

/* Modali (Pop-up Aggiunta/Modifica) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-overlay.open {
  display: flex;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.15), 0 8px 10px -6px rgb(0 0 0 / 0.15);
  animation: modalSlide 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

@keyframes modalSlide {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}

.modal-close-btn:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  outline: none;
  background: #ffffff;
  color: var(--text-main);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.form-helper {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Toast Notifiche */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: var(--primary);
  color: #ffffff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  pointer-events: auto;
  animation: toastIn 0.25s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Gestione Colonne Dinamiche */
.columns-list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.columns-list-table th,
.columns-list-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.columns-list-table th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.columns-list-table input[type="text"],
.columns-list-table select {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  outline: none;
}

.columns-list-table input[type="text"]:focus,
.columns-list-table select:focus {
  border-color: var(--accent);
}

.col-btn-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-muted);
  transition: all 0.15s;
}

.col-btn-icon:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.col-btn-icon.btn-delete:hover {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}

/* Toggle Direttivo in Testa */
.sort-anchor-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
}

.sort-anchor-toggle:hover {
  background: #dbeafe;
}

.sort-anchor-toggle input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--primary);
}

/* ============================================================
   MODAL SCELTA STAMPA & BANNER STAMPA
   ============================================================ */
.print-options-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.print-option-card {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  background: #ffffff;
  transition: all 0.15s ease;
}

.print-option-card:hover {
  border-color: var(--accent);
  background: #f8fafc;
}

.print-option-card.active {
  border-color: var(--primary);
  background: #eff6ff;
  box-shadow: 0 0 0 1px var(--primary);
}

.print-option-card input[type="radio"] {
  margin-top: 0.25rem;
  accent-color: var(--primary);
  cursor: pointer;
}

.print-option-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.print-option-content {
  flex: 1;
}

.print-option-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.2rem;
}

.print-option-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.orientation-choice {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  cursor: pointer;
  background: #ffffff;
  transition: all 0.15s;
}

.orientation-choice:hover {
  border-color: var(--accent);
}

.orientation-choice.active {
  border-color: var(--primary);
  background: #eff6ff;
  font-weight: 600;
  color: var(--primary);
}

.orientation-choice input[type="radio"] {
  accent-color: var(--primary);
}

/* Header di Stampa Istituzionale */
.print-header-banner {
  display: none;
}

/* ============================================================
   OTTIMIZZAZIONE STAMPA (@media print)
   ============================================================ */
@media print {
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body {
    background: #ffffff !important;
    color: #0f172a !important;
    font-size: 8pt !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Nascondi intestazione web standard, toolbar, bottoni, modali e popover */
  .app-header,
  .info-banner,
  .kpi-grid,
  .toolbar-card,
  .meeting-actions-btn,
  .row-action-btn,
  .btn,
  .modal-overlay,
  .presence-popover,
  .toast-container,
  .comm-hover-badge,
  .comm-hover-tooltip,
  .tfoot-repeated-headers,
  .table-bottom-bar,
  .btn-floating-scroll {
    display: none !important;
  }

  /* Mostra il banner di stampa istituzionale */
  .print-header-banner {
    display: flex !important;
    justify-content: space-between;
    align-items: flex-end;
    border-bottom: 2px solid #0f172a;
    padding-bottom: 6px;
    margin-bottom: 10px;
  }

  .print-header-inst {
    font-size: 11pt;
    font-weight: 800;
    color: #0b2545;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .print-header-comm {
    font-size: 9.5pt;
    font-weight: 700;
    color: #1e3a8a;
    margin-top: 2px;
  }

  .print-header-doc {
    font-size: 8.5pt;
    font-weight: 600;
    color: #475569;
    margin-top: 1px;
  }

  .print-header-right {
    text-align: right;
  }

  .print-header-date {
    font-size: 7.5pt;
    color: #64748b;
  }

  .print-header-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #e2e8f0;
    border: 1px solid #94a3b8;
    border-radius: 4px;
    font-size: 7.5pt;
    font-weight: 700;
    color: #0f172a;
    margin-top: 4px;
    text-transform: uppercase;
  }

  .app-container {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
  }

  .table-card {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .table-responsive {
    max-height: none !important;
    overflow: visible !important;
    box-shadow: none !important;
    border: none !important;
  }

  /* Tabella Presenze */
  .presenze-table {
    width: 100% !important;
    border-collapse: collapse !important;
    border: 1.5px solid #0f172a !important;
    font-size: 7.5pt !important;
    table-layout: auto !important;
  }

  .presenze-table thead {
    display: table-header-group !important;
  }

  .presenze-table tfoot {
    display: table-footer-group !important;
  }

  .presenze-table tr {
    page-break-inside: avoid !important;
  }

  .presenze-table th,
  .presenze-table td {
    border: 1px solid #cbd5e1 !important;
    padding: 3px 5px !important;
    page-break-inside: avoid !important;
    vertical-align: middle !important;
  }

  .presenze-table thead th {
    background: #f1f5f9 !important;
    color: #0f172a !important;
    font-weight: 700 !important;
    border-bottom: 2px solid #0f172a !important;
  }

  .presenze-table tfoot th,
  .presenze-table tfoot td {
    background: #f8fafc !important;
    border-top: 2px solid #0f172a !important;
  }

  /* Reset tassativo per le colonne sticky: in stampa DEVONO essere statiche per evitare spostamenti */
  .col-sticky-1,
  .col-sticky-2,
  .col-sticky-3 {
    position: static !important;
    left: auto !important;
    box-shadow: none !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
  }

  /* NASCONDI SEMPRE LA COLONNA AZIONI (Sia nel thead, tbody che nel tfoot) */
  th.col-sticky-3,
  td.col-sticky-3,
  .col-actions {
    display: none !important;
  }

  /* Badge Ruolo */
  .comm-role-badge {
    padding: 1px 4px !important;
    font-size: 6.5pt !important;
    border: 1px solid #94a3b8 !important;
  }

  /* Nome Commissario */
  .comm-name {
    font-size: 7.8pt !important;
    font-weight: 700 !important;
    color: #0f172a !important;
  }

  /* Meeting Headers */
  .meeting-header {
    min-width: 0 !important;
    padding: 3px 2px !important;
    text-align: center !important;
  }

  .meeting-header .meeting-weekday {
    font-size: 6pt !important;
  }

  .meeting-header .meeting-date {
    font-size: 7.5pt !important;
    font-weight: 700 !important;
  }

  .meeting-header .meeting-badge {
    font-size: 6pt !important;
    padding: 0 3px !important;
  }

  .meeting-header .meeting-time {
    font-size: 6pt !important;
  }

  /* Celle Presenze */
  .cell-presenza {
    text-align: center !important;
    padding: 2px !important;
  }

  .status-dot {
    width: 17px !important;
    height: 17px !important;
    line-height: 17px !important;
    font-size: 6.8pt !important;
    border: 1px solid rgba(0, 0, 0, 0.3) !important;
    box-shadow: none !important;
    margin: 0 auto !important;
  }

  .pct-pill {
    padding: 1px 3px !important;
    font-size: 7pt !important;
  }

  .col-annual-pct,
  .col-total-pct {
    text-align: center !important;
    padding: 2px !important;
  }

  /* Testo contatti e anagrafica */
  .comm-contact {
    text-decoration: none !important;
    color: #0f172a !important;
  }

  .cell-multiline {
    white-space: normal !important;
    min-width: 140px !important;
    max-width: 220px !important;
    font-size: 6.8pt !important;
  }

  /* ============================================================
     3 MODALITÀ DI STAMPA SPECIFICHE
     ============================================================ */

  /* MODALITÀ 2: Solo Dati Aggiuntivi (Anagrafica & Albo) SENZA Presenze */
  body.print-mode-anagrafica .col-meeting-data,
  body.print-mode-anagrafica .col-stats-data,
  body.print-mode-anagrafica .col-annual-pct,
  body.print-mode-anagrafica .col-total-pct,
  body.print-mode-anagrafica .legend-bar {
    display: none !important;
  }

  /* MODALITÀ 3: Solo Presenze SENZA Dati Aggiuntivi */
  body.print-mode-presenze .col-anagrafica-custom {
    display: none !important;
  }
}
