/* ============================================================
   PDF Manager — Design System "Carta & Inchiostro"
   Redesign by AI — Preserva tutta la struttura popup/z-index
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@500;600;700;800&family=Manrope:wght@400;500;600;700;800&display=swap');

/* ============================================================
   VARIABILI DESIGN
   ============================================================ */
:root {
  /* Colori principali */
  --primary:          #1e3a5f;
  --primary-hover:    #16304f;
  --primary-light:    #2c5282;
  --primary-muted:    #4a7ab5;
  --accent:           #c9882e;
  --accent-hover:     #b37a28;
  --accent-soft:      #fdf3e7;
  --success:          #2d6a4f;
  --success-hover:    #235639;
  --warning:          #d97706;
  --danger:           #b91c1c;
  --danger-hover:     #991b1b;
  --danger-soft:      #fef2f2;

  /* Superficie */
  --bg:               #f3f0eb;
  --bg-2:             #ebe7e0;
  --bg-3:             #e0dbd3;
  --surface:          #ffffff;
  --surface-alt:      #faf8f5;
  --surface-raised:   #ffffff;
  --panel:            rgba(255, 255, 255, 0.97);
  --panel-soft:       rgba(255, 255, 255, 0.88);

  /* Testo */
  --text:             #1c1917;
  --text-soft:        #5c5750;
  --text-muted:       #9b9590;
  --text-on-primary:  #ffffff;

  /* Bordi e ombre */
  --border:           #d8d3cc;
  --border-strong:    #b8b3ac;
  --border-focus:     rgba(30, 58, 95, 0.55);
  --shadow-sm:        0 1px 3px rgba(28, 25, 23, 0.08), 0 1px 2px rgba(28, 25, 23, 0.04);
  --shadow-md:        0 4px 16px rgba(28, 25, 23, 0.10), 0 2px 6px rgba(28, 25, 23, 0.06);
  --shadow-lg:        0 12px 40px rgba(28, 25, 23, 0.13), 0 4px 16px rgba(28, 25, 23, 0.07);
  --shadow-popup:     0 24px 64px rgba(28, 25, 23, 0.18), 0 8px 24px rgba(28, 25, 23, 0.10);

  /* Tipografia */
  --font-display:     'Syne', system-ui, sans-serif;
  --font-ui:          'Manrope', 'Segoe UI', system-ui, sans-serif;

  /* Raggi */
  --radius-xs:        6px;
  --radius-sm:        10px;
  --radius-md:        14px;
  --radius-lg:        18px;
  --radius-xl:        24px;
  --radius-full:      999px;

  /* Spinner */
  --spinner-size:     128px;
  --spinner-border:   6px;

  /* Z-index (invariati per compatibilità) */
  --z-overlay:        3900;
  --z-popup:          4000;
  --z-spinner:        12000;
  --z-share:          5000;
  --z-nav:            8000;

  /* Layout */
  --page-max:         1560px;
  --nav-height:       64px;
  --content-pad:      28px;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--font-ui);
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 10% 0%, rgba(30,58,95,0.06), transparent),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(201,136,46,0.05), transparent);
  min-height: 100vh;
  padding-top: calc(var(--nav-height) + 24px);
  padding-bottom: 80px;
  padding-left: var(--content-pad);
  padding-right: var(--content-pad);
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.6;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23noise)' opacity='0.025'/%3E%3C/svg%3E");
  z-index: -1;
}

/* ============================================================
   TIPOGRAFIA
   ============================================================ */
h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 2.5vw + 1rem, 3.2rem);
  font-weight: 600;
  color: var(--primary);
  letter-spacing: -0.01em;
  text-align: center;
  margin-bottom: 24px;
  line-height: 1.2;
}

h2 {
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 1.2vw + 0.8rem, 1.9rem);
  font-weight: 600;
  color: var(--primary);
  letter-spacing: -0.01em;
  margin-bottom: 16px;
}

h3 {
  font-family: var(--font-ui);
  font-size: clamp(1rem, 0.6vw + 0.85rem, 1.2rem);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

p, li, td, th, label, select, textarea { font-size: 14px; }
input { font-size: 14px; }

/* ============================================================
   NAVIGAZIONE TOP — solo .topnav e .menu-dropdown
   .dropdown è usato nei dropdown contestuali delle tabelle
   e NON deve ricevere stili di nav bar
   ============================================================ */
.topnav,
.menu-dropdown {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--nav-height);
  background: var(--primary);
  background-image: linear-gradient(135deg, #1e3a5f 0%, #16304f 100%);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 8px;
  z-index: var(--z-nav);
}

/* Bottoni della nav bar */
.menu-btn,
.topnav-btn {
  appearance: none;
  background: rgba(255,255,255,0.12) !important;
  color: #fff !important;
  border: 1px solid rgba(255,255,255,0.18) !important;
  border-radius: var(--radius-sm) !important;
  padding: 8px 18px !important;
  font-family: var(--font-ui) !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  letter-spacing: 0.02em !important;
  text-transform: uppercase !important;
  transition: background 0.18s, border-color 0.18s, transform 0.14s !important;
  box-shadow: none !important;
  margin: 0 4px !important;
}

.menu-btn:hover,
.topnav-btn:hover {
  background: rgba(255,255,255,0.22) !important;
  border-color: rgba(255,255,255,0.32) !important;
  transform: none !important;
  box-shadow: none !important;
}

/* Brand nella nav: logo + testo */
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  letter-spacing: 0.01em;
  /* Centrato nella barra fissa indipendentemente dal contenuto ai lati */
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  pointer-events: none;
  white-space: nowrap;
}

.nav-logo {
  height: 38px;
  width: auto;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 1px 4px rgba(0,0,0,0.25));
}

/* Menu a tendina della nav */
.menu-dropdown-content {
  display: none;
  position: absolute;
  top: calc(var(--nav-height) - 4px);
  left: 4px;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: calc(var(--z-nav) + 10);
  animation: dropDown 0.18s ease;
}

@keyframes dropDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Trigger spostato su .nav-menu-wrap per non attivare il dropdown sull'intera barra */
.menu-dropdown:hover .menu-dropdown-content { display: none; }
.nav-menu-wrap:hover .menu-dropdown-content,
.nav-menu-wrap .menu-dropdown-content:hover { display: block; }

.menu-dropdown-content a,
.menu-dropdown-content button {
  display: block;
  padding: 11px 18px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  transition: background 0.14s, color 0.14s;
  border-bottom: 1px solid var(--border);
  background: none !important;
  border-left: none !important;
  border-right: none !important;
  border-top: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  margin: 0 !important;
  width: 100%;
  text-align: left;
  cursor: pointer;
  letter-spacing: normal !important;
  text-transform: none !important;
}

.menu-dropdown-content a:last-child,
.menu-dropdown-content button:last-child { border-bottom: none; }

.menu-dropdown-content a:hover,
.menu-dropdown-content button:hover {
  background: var(--accent-soft) !important;
  color: var(--accent) !important;
  transform: none !important;
}

/* ============================================================
   DROPDOWN CONTESTUALE (nelle celle tabella — .dropdown)
   Completamente separato dalla nav: position relative,
   nessun stile di barra, nessun ::before
   ============================================================ */
.dropdown {
  position: relative;
  display: inline-block;
  text-align: left;
}

/* Pulsante "Azioni" dentro le celle tabella */
.dropdown .dropbtn {
  background: linear-gradient(180deg, var(--primary-light) 0%, var(--primary) 100%) !important;
  color: #fff !important;
  border: 1px solid rgba(22, 48, 79, 0.45) !important;
  border-radius: var(--radius-xs) !important;
  padding: 5px 12px !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  box-shadow: 0 2px 6px rgba(30, 58, 95, 0.20) !important;
  margin: 0 !important;
  letter-spacing: 0.01em !important;
  text-transform: none !important;
  transition: background 0.14s, transform 0.14s !important;
  width: auto !important;
}

.dropdown .dropbtn:hover {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-hover) 100%) !important;
  transform: translateY(-1px) !important;
}

/* Menu a tendina contestuale */
.dropdown-content {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 500;
}

.dropdown:hover .dropdown-content,
.dropdown:focus-within .dropdown-content {
  display: block;
}

/* Voci menu: Firma / Condividi / Cancella */
.dropdown-content button,
.dropdown-content a {
  display: block !important;
  width: 100% !important;
  padding: 10px 14px !important;
  text-align: left !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  color: var(--text) !important;
  background: none !important;
  border: none !important;
  border-bottom: 1px solid var(--border) !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  margin: 0 !important;
  cursor: pointer !important;
  letter-spacing: normal !important;
  text-transform: none !important;
  transition: background 0.12s, color 0.12s !important;
}

.dropdown-content button:last-child,
.dropdown-content a:last-child {
  border-bottom: none !important;
}

.dropdown-content button:hover,
.dropdown-content a:hover {
  background: var(--accent-soft) !important;
  color: var(--primary) !important;
  transform: none !important;
}

/* Voce "Cancella" in rosso */
.dropdown-content button[onclick*="confirm"],
.dropdown-content button[onclick*="Delete"],
.dropdown-content button[onclick*="delete"],
.dropdown-content button[onclick*="Cancella"],
.dropdown-content button[onclick*="elimina"] {
  color: var(--danger) !important;
}
.dropdown-content button[onclick*="confirm"]:hover,
.dropdown-content button[onclick*="Delete"]:hover,
.dropdown-content button[onclick*="delete"]:hover {
  background: var(--danger-soft) !important;
  color: var(--danger-hover) !important;
}

/* ============================================================
   ELEMENTI FORM BASE
   ============================================================ */
button,
input[type="submit"],
input[type="button"] {
  appearance: none;
  font-family: var(--font-ui);
  background: linear-gradient(180deg, var(--primary-light) 0%, var(--primary) 100%);
  color: #fff;
  padding: 10px 20px;
  border: 1px solid rgba(22, 48, 79, 0.45);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 4px 0;
  box-shadow: 0 2px 8px rgba(30, 58, 95, 0.22), inset 0 1px 0 rgba(255,255,255,0.15);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

button:hover,
input[type="submit"]:hover,
input[type="button"]:hover {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-hover) 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(30, 58, 95, 0.30), inset 0 1px 0 rgba(255,255,255,0.12);
}

button:active,
input[type="submit"]:active,
input[type="button"]:active {
  transform: translateY(0);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.18), 0 0 0 1px rgba(30, 58, 95, 0.38);
}

/* Sort buttons - piccoli */
.sort-btn {
  background: rgba(30,58,95,0.09) !important;
  color: var(--primary) !important;
  border: 1px solid rgba(30,58,95,0.18) !important;
  padding: 3px 8px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  border-radius: var(--radius-xs) !important;
  box-shadow: none !important;
  margin: 2px 1px !important;
}
.sort-btn:hover {
  background: rgba(30,58,95,0.16) !important;
  transform: none !important;
  box-shadow: none !important;
}

/* Bottone pericolo */
button.danger,
.btn-danger {
  background: linear-gradient(180deg, #dc2626 0%, var(--danger) 100%) !important;
  border-color: rgba(153, 27, 27, 0.45) !important;
  box-shadow: 0 2px 8px rgba(185, 28, 28, 0.22) !important;
}

/* Bottone successo */
button.success,
.btn-success {
  background: linear-gradient(180deg, #2d9b6b 0%, var(--success) 100%) !important;
  border-color: rgba(35, 86, 57, 0.45) !important;
}

/* Bottone close standard */
.close-btn {
  background: transparent !important;
  color: var(--text-soft) !important;
  border: none !important;
  font-size: 18px !important;
  font-weight: 700 !important;
  padding: 4px 8px !important;
  box-shadow: none !important;
  cursor: pointer !important;
  line-height: 1 !important;
  border-radius: var(--radius-xs) !important;
  transition: color 0.15s, background 0.15s !important;
}
.close-btn:hover {
  background: var(--bg-2) !important;
  color: var(--danger) !important;
  transform: none !important;
}

/* ============================================================
   INPUT & FORM ELEMENTS
   ============================================================ */
form {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: var(--content-pad);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  letter-spacing: 0.01em;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="file"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 11px 14px;
  margin-bottom: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  box-shadow: inset 0 1px 2px rgba(28, 25, 23, 0.03);
  transition: border-color 0.16s, box-shadow 0.16s;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.10), inset 0 1px 2px rgba(28, 25, 23, 0.03);
}

input[type="text"]:hover,
input[type="password"]:hover,
select:hover,
textarea:hover {
  border-color: var(--border-strong);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

input[type="checkbox"] {
  accent-color: var(--primary);
  cursor: pointer;
  width: 15px;
  height: 15px;
}

code {
  background: #f0f4fa;
  color: #1e3a5f;
  padding: 3px 7px;
  border-radius: var(--radius-xs);
  border: 1px solid rgba(30,58,95,0.12);
  font-size: 13px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--primary-light); }

/* ============================================================
   CONTENITORI PRINCIPALI
   ============================================================ */
.container,
.centered-table,
.table-container,
.control-block > form,
.control-block > .centered-table,
.create-pdf-page #pdfForm,
.search-page > form,
.login-page .container,
.activation-page .container,
.admin-page .container,
.usermgmt-page .container,
.emailcfg-page .container,
.configure2fa-page .container,
.chat-page .container {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.container,
.table-container,
.centered-table,
.dashboard-controls,
.pdf-row,
.chat-page .container,
.search-page > form,
.create-pdf-page #pdfForm,
.dashboard-page h1,
.userpanel-page > h1,
.search-page > h1,
.create-pdf-page > h1,
.admin-page > h1,
.usermgmt-page > h1,
.emailcfg-page > .container,
.configure2fa-page .container,
.twofa-page .twofa-container {
  width: min(var(--page-max), calc(100% - 16px));
}

.divider {
  width: min(var(--page-max), calc(100% - 16px));
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

/* ============================================================
   CREDITS / FOOTER
   ============================================================ */
.credits {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 10px 16px;
  background: rgba(255,255,255,0.90);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  z-index: 1000;
  letter-spacing: 0.02em;
}

/* ============================================================
   TABELLE
   ============================================================ */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-size: 14px;
}

th, td {
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

th {
  background: linear-gradient(180deg, #f8f6f2 0%, #f0ede6 100%);
  color: var(--primary);
  font-weight: 800;
  font-size: 12px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border-strong);
}

tr:nth-child(even) td { background: rgba(243, 240, 235, 0.60); }

tbody tr {
  transition: background 0.14s;
}

tbody tr:hover td {
  background: rgba(201, 136, 46, 0.07) !important;
}

.pdf-title { width: 50%; }
.pdf-date  { width: 10%; }
.pdf-download, .pdf-sign, .pdf-share, .pdf-delete { width: 10%; }
.signed-pdf-title { width: 60%; }
.signed-pdf-date, .signed-pdf-share, .signed-pdf-download, .signed-pdf-delete { width: 10%; }

/* ============================================================
   ALLINEAMENTO E PROPORZIONI — tabelle PDF non Firmati / PDF Firmati / Cestino
   Stesse regole applicate a entrambe le tabelle
   ============================================================ */

/* Layout colonne: Nome File prende lo spazio restante,
   le altre si adattano al loro contenuto */
#pdfManagementTable,
#trashTable {
  table-layout: auto;
}

#pdfManagementTable th,
#pdfManagementTable td,
#trashTable th,
#trashTable td {
  vertical-align: middle;
  white-space: nowrap;
}

/* Colonna Nome: prende tutto lo spazio disponibile,
   intestazione centrata, contenuto righe a sinistra */
#pdfManagementTable th.pdf-title,
#trashTable th.pdf-title {
  text-align: center;
  width: auto;
}
#pdfManagementTable td.pdf-title,
#pdfManagementTable tbody td:first-child,
#trashTable td.pdf-title,
#trashTable tbody td:first-child {
  text-align: left;
  white-space: normal;   /* Il nome file può andare a capo */
}

/* Header "Nome" + sort buttons sulla stessa riga */
#pdfManagementTable th.pdf-title .sort-btn-container,
#pdfManagementTable th:first-child .sort-btn-container,
#trashTable th.pdf-title .sort-btn-container,
#trashTable th:first-child .sort-btn-container {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 0;
  margin-left: 8px;
  vertical-align: middle;
}

/* Colonna Data: larghezza adattata al contenuto
   (testo + bottoni sulla stessa riga) */
#pdfManagementTable th.pdf-date,
#trashTable th.pdf-date {
  text-align: center;
  width: 1%;           /* forza shrink-to-fit */
  white-space: nowrap;
}
#pdfManagementTable td.pdf-date,
#pdfManagementTable tbody td:nth-child(2),
#trashTable td.pdf-date,
#trashTable tbody td:nth-child(2) {
  text-align: center;
  white-space: nowrap;
}

/* Sort buttons Data sulla stessa riga */
#pdfManagementTable th.pdf-date .sort-btn-container,
#trashTable th.pdf-date .sort-btn-container {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 0;
  margin-left: 6px;
  vertical-align: middle;
}

/* Colonna Azioni: larga quanto la scritta */
#pdfManagementTable th:nth-child(3),
#pdfManagementTable td:nth-child(3),
#trashTable th:nth-child(3),
#trashTable td:nth-child(3) {
  text-align: center;
  width: 1%;
  white-space: nowrap;
}

/* Colonna Seleziona: larga quanto la scritta */
#pdfManagementTable th:nth-child(4),
#pdfManagementTable td:nth-child(4),
#trashTable th:nth-child(4),
#trashTable td:nth-child(4) {
  text-align: center;
  width: 1%;
  white-space: nowrap;
}

/* Pulsante Azioni centrato */
#pdfManagementTable td .dropdown,
#trashTable td .dropdown {
  display: inline-flex;
  justify-content: center;
}

/* Checkbox centrata */
#pdfManagementTable td input[type="checkbox"],
#trashTable td input[type="checkbox"] {
  display: block;
  margin: 0 auto;
}

/* Tabella: overflow visible per permettere al dropdown di uscire dai bordi */
table { overflow: visible; }

/* ============================================================
   ALLINEAMENTO E PROPORZIONI — tabelle userpanel.jsp
   pdfTable e signedPdfTable: 3 colonne (Nome, Data, Seleziona)
   ============================================================ */
#pdfTable,
#signedPdfTable {
  table-layout: auto;
}

#pdfTable th,
#pdfTable td,
#signedPdfTable th,
#signedPdfTable td {
  vertical-align: middle;
  white-space: nowrap;
}

/* Colonna Nome: prende tutto lo spazio, header centrato, celle a sinistra */
#pdfTable th.pdf-title,
#signedPdfTable th.pdf-title {
  text-align: center;
  width: auto;
}
#pdfTable tbody td:first-child,
#signedPdfTable tbody td:first-child {
  text-align: left;
  white-space: normal;
}

/* Sort buttons "Nome" sulla stessa riga del testo */
#pdfTable th.pdf-title .sort-btn-container,
#signedPdfTable th.pdf-title .sort-btn-container {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 0;
  margin-left: 8px;
  vertical-align: middle;
}

/* Colonna Data: shrink-to-fit, sort buttons inline */
#pdfTable th.pdf-date,
#signedPdfTable th.pdf-date {
  text-align: center;
  width: 1%;
  white-space: nowrap;
}
#pdfTable tbody td:nth-child(2),
#signedPdfTable tbody td:nth-child(2) {
  text-align: center;
  white-space: nowrap;
}
#pdfTable th.pdf-date .sort-btn-container,
#signedPdfTable th.pdf-date .sort-btn-container {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 0;
  margin-left: 6px;
  vertical-align: middle;
}

/* Colonna Seleziona: shrink-to-fit */
#pdfTable th.pdf-select,
#pdfTable tbody td:nth-child(3),
#signedPdfTable th.pdf-select,
#signedPdfTable tbody td:nth-child(3) {
  text-align: center;
  width: 1%;
  white-space: nowrap;
}

/* Checkbox centrata */
#pdfTable td input[type="checkbox"],
#signedPdfTable td input[type="checkbox"] {
  display: block;
  margin: 0 auto;
}

.upload-progress-container { width: 100%; margin-top: 16px; }

.upload-progress-container progress,
#progressBar,
#aiProgressBar {
  width: 100%;
  height: 10px;
  display: none;
  border: none;
  border-radius: var(--radius-full);
  overflow: hidden;
  background: var(--bg-2);
}

progress::-webkit-progress-bar { background: var(--bg-2); border-radius: var(--radius-full); }
progress::-webkit-progress-value { background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: var(--radius-full); }
progress::-moz-progress-bar { background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: var(--radius-full); }

#progressPercent, #aiCountdown {
  text-align: center;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-soft);
  font-weight: 600;
}

/* ============================================================
   MESSAGGI ERRORE / SUCCESSO
   ============================================================ */
.error-message {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(185, 28, 28, 0.25);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-weight: 600;
  font-size: 13.5px;
  margin-top: 12px;
  text-align: center;
}

.success-message {
  background: #f0fdf4;
  color: var(--success);
  border: 1px solid rgba(45, 106, 79, 0.25);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-weight: 600;
  font-size: 13.5px;
  margin-top: 12px;
  text-align: center;
}

.app-version {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
  font-weight: 500;
}

/* ============================================================
   LOGIN & ACTIVATION PAGE
   ============================================================ */
.login-page,
.activation-page {
  background-color: var(--primary);
  background-image:
    radial-gradient(ellipse 80% 60% at 30% 20%, rgba(44,82,130,0.8), transparent),
    radial-gradient(ellipse 60% 80% at 80% 80%, rgba(201,136,46,0.15), transparent),
    linear-gradient(160deg, #0f1e30 0%, #1e3a5f 50%, #16304f 100%);
  padding-top: var(--nav-height) !important;
  padding-bottom: 0;
  justify-content: center;
  min-height: 100vh;
}

.login-page::before,
.activation-page::before { display: none; }

.login-page .container,
.activation-page .container {
  background: rgba(255,255,255,0.97);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius-xl);
  padding: 44px 48px 36px;
  box-shadow:
    0 32px 80px rgba(0,0,0,0.30),
    0 8px 24px rgba(0,0,0,0.18),
    inset 0 1px 0 rgba(255,255,255,0.9);
  width: min(440px, calc(100% - 32px));
  display: flex;
  flex-direction: column;
  align-items: center;
}

.login-page .container img,
.activation-page .container img {
  max-width: 110px;
  height: auto;
  margin-bottom: 20px;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.15));
}

.login-page .container form,
.activation-page .container form {
  width: 100%;
  background: transparent;
  border: none;
  padding: 0;
  box-shadow: none;
}

.login-page .container h1,
.activation-page .container h1 {
  font-size: 1.6rem;
  margin-bottom: 20px;
  color: var(--primary);
}

.button-container {
  display: flex;
  justify-content: stretch;
  width: 100%;
  margin-top: 4px;
}

.button-container button {
  width: 100%;
  padding: 13px 20px;
  font-size: 15px;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--primary-light) 0%, var(--primary) 100%);
  letter-spacing: 0.03em;
}

/* Video background per login */
.video-background {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -1;
  opacity: 0.18;
}

.helper-links {
  margin-top: 14px;
  text-align: center;
}

.helper-links--small { font-size: 13px; }

.reset-link {
  color: var(--primary-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s;
}
.reset-link:hover { color: var(--accent); text-decoration: underline; }

/* ============================================================
   POPUP / MODAL
   ============================================================ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 28, 0.56);
  backdrop-filter: blur(3px);
  z-index: var(--z-overlay);
  display: none;
}

.popup {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px 36px 28px;
  z-index: var(--z-popup);
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  box-shadow: var(--shadow-popup);
}

@keyframes popIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.92); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Quando il popup viene aperto via JS con display:block */
.popup[style*="display: block"],
.popup[style*="display:block"] {
  animation: popIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.popup h2 {
  font-family: var(--font-display);
  font-size: 1.45rem;
  margin-bottom: 16px;
  color: var(--primary);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.popup form {
  background: transparent;
  border: none;
  padding: 0;
  box-shadow: none;
}

.popup.share,
.popup.delete,
.popup.move {
  right: 24px;
  left: auto;
  transform: translateY(0);
  top: auto;
  position: fixed;
}

/* ============================================================
   DASHBOARD PAGE
   ============================================================ */
.dashboard-page body,
.dashboard-controls {
  width: min(var(--page-max), calc(100% - 16px));
}

.dashboard-controls {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(520px, 1.4fr);
  gap: 20px;
  width: min(var(--page-max), calc(100% - 16px));
}

/* ---- Barra di ricerca sotto i controlli ---- */
/* Override stile form globale quando il form stesso è la search bar */
form.dashboard-search {
  background: var(--panel) !important;
  border: 1px solid var(--border) !important;
  padding: 14px 20px !important;
  box-shadow: var(--shadow-sm) !important;
  border-radius: var(--radius-lg) !important;
}

.dashboard-search {
  width: min(var(--page-max), calc(100% - 16px));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-top: 4px;
}

.dashboard-search input[type="text"] {
  flex: 1 1 auto;
  margin-bottom: 0;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  min-width: 0;
}

.dashboard-search .search-btn {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  border-radius: var(--radius-sm);
  margin: 0;
}

.dashboard-search .search-btn svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  flex-shrink: 0;
}

.control-block {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--content-pad);
  box-shadow: var(--shadow-md);
  transition: box-shadow 0.18s;
}

.control-block:hover {
  box-shadow: var(--shadow-lg);
}

.control-block form {
  background: transparent;
  border: none;
  padding: 0;
  box-shadow: none;
}

/* Action grid dashboard */
.dashboard-controls .centered-table {
  padding: 16px;
  overflow: hidden;
}

.dashboard-controls .centered-table table,
.dashboard-controls .centered-table tbody {
  display: block;
  width: 100%;
}

.dashboard-controls .centered-table tr {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  align-items: stretch;
}

.dashboard-controls .centered-table td {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  min-width: 0;
  padding: 12px 6px !important;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #faf8f5, var(--bg)) !important;
  border: 1px solid var(--border) !important;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, box-shadow 0.18s, transform 0.18s;
  box-shadow: var(--shadow-sm);
}

.dashboard-controls .centered-table td:hover {
  background: linear-gradient(180deg, #fff, #faf8f5) !important;
  border-color: var(--primary-muted) !important;
  box-shadow: 0 6px 20px rgba(30,58,95,0.12) !important;
  transform: translateY(-2px);
}

.dashboard-controls .centered-table img {
  width: 56px;
  height: 56px;
  max-width: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.08));
  transition: transform 0.18s;
}

.dashboard-controls .centered-table td:hover img {
  transform: scale(1.06);
}

.dashboard-controls .centered-table .caption {
  margin-top: 0;
  max-width: 100%;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
  word-break: break-word;
  overflow-wrap: anywhere;
  color: var(--primary);
}

/* ============================================================
   PDF MANAGEMENT POPUP (grande)
   ============================================================ */
#pdfManagementPopup {
  width: min(90vw, 1100px);
  max-height: 85vh;
}

.sort-btn-container {
  display: inline-flex;
  gap: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

.folder-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0;
}

/* Sidebar verticale — usata in dashboard e userpanel */
.folder-list-sidebar {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.folder-item {
  display: block;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.folder-item:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-left-color: var(--accent);
}

.folder-item.selected {
  background: var(--accent-soft);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 700;
}


/* ============================================================
   PDF ROW & FOLDERS (userpanel / trash)
   ============================================================ */
.pdf-row {
  display: flex;
  gap: 20px;
  width: min(var(--page-max), calc(100% - 16px));
}

.pdf-folders {
  flex: 0 0 240px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 16px;
  box-shadow: var(--shadow-sm);
}

.pdf-table {
  flex: 1 1 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
  position: relative;
}

/* ============================================================
   MAIN ACTIONS BAR
   ============================================================ */
.main-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  width: min(var(--page-max), calc(100% - 16px));
  margin-bottom: 4px;
}

.main-actions button,
.main-actions a button {
  font-size: 13px;
  padding: 8px 16px;
}

/* ============================================================
   MOBILE ACTION BAR
   Desktop: bottoni normali in riga
   Mobile (≤760px): menu a tendina collassabile
   ============================================================ */
.mobile-action-bar {
  width: 100%;
  margin-bottom: 16px;
}

/* ---- DESKTOP: trigger nascosto, bottoni visibili in riga ---- */
.mobile-action-trigger {
  display: none !important;
}

.mobile-action-menu {
  display: flex;
  flex-direction: row;       /* riga orizzontale esplicita */
  flex-wrap: wrap;           /* va a capo se non c'è spazio */
  justify-content: center;   /* bottoni centrati orizzontalmente */
  align-items: flex-start;   /* non stirare in altezza */
  gap: 8px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.mobile-action-menu button {
  flex: 0 0 auto;  /* non crescere, non restringersi */
  width: auto;     /* larghezza naturale del bottone */
  font-size: 13px;
  padding: 8px 14px;
  margin: 0;
}

/* ---- MOBILE: trigger visibile, menu collassato di default ---- */
@media (max-width: 760px) {
  .mobile-action-trigger {
    display: flex !important;
    align-items: center;
    gap: 8px;
    width: 100%;
    justify-content: center;
    font-size: 14px;
    padding: 11px 20px;
    border-radius: var(--radius-sm);
    margin: 0;
  }

  .mobile-action-menu {
    /* position: static — NON absolute, per evitare il clipping
       di overflow-y: auto su .popup e qualsiasi contenitore padre */
    display: none;
    flex-direction: column;
    gap: 0;
    padding: 4px 0;
    margin-top: 6px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    background: var(--surface);
    border: 1px solid var(--border);
  }

  .mobile-action-bar.open .mobile-action-menu {
    display: flex;
  }

  .mobile-action-menu button {
    flex: none;
    width: 100% !important;
    text-align: left;
    padding: 12px 16px;
    font-size: 14px;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    border-bottom: 1px solid var(--border);
    background: var(--surface) !important;
    color: var(--text) !important;
    font-weight: 500;
  }

  .mobile-action-menu button:last-child {
    border-bottom: none;
  }

  /* Hover su desktop mobile (mouse) */
  .mobile-action-menu button:hover {
    background: linear-gradient(180deg, var(--primary-light) 0%, var(--primary) 100%) !important;
    color: #fff !important;
    transform: none !important;
    box-shadow: none !important;
    border-bottom-color: rgba(255,255,255,0.15) !important;
  }

  /* Tap su touchscreen (active = feedback visivo al tocco) */
  .mobile-action-menu button:active {
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-hover) 100%) !important;
    color: #fff !important;
    transform: none !important;
    box-shadow: none !important;
    border-bottom-color: rgba(255,255,255,0.15) !important;
  }
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 10px 0;
  justify-content: center;
  align-items: center;
}

.pagination button {
  min-width: 36px;
  padding: 6px 10px !important;
  font-size: 12px !important;
  border-radius: var(--radius-xs) !important;
  background: var(--surface-alt) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  box-shadow: none !important;
  font-weight: 600 !important;
}

.pagination button.active,
.pagination button:hover {
  background: var(--primary) !important;
  color: #fff !important;
  border-color: var(--primary) !important;
}

.pagination button.active {
  pointer-events: none;
}

/* Frecce prev/next */
.pagination button.pg-arrow {
  min-width: 32px;
  font-size: 16px !important;
  padding: 4px 10px !important;
  font-weight: 700 !important;
}

.pagination button.pg-arrow:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

/* Puntini di separazione */
.pagination .pg-dots {
  display: inline-flex;
  align-items: center;
  padding: 0 4px;
  font-size: 14px;
  color: var(--text-muted);
  user-select: none;
  line-height: 1;
}

/* Mobile: bottoni più compatti */
@media (max-width: 760px) {
  .pagination button {
    min-width: 32px !important;
    padding: 5px 8px !important;
    font-size: 11px !important;
  }
  .pagination button.pg-arrow {
    min-width: 30px !important;
    font-size: 15px !important;
    padding: 4px 8px !important;
  }
}

/* ============================================================
   CHAT PAGE
   ============================================================ */
.chat-page .container {
  padding: 28px 32px 72px;
  width: min(900px, calc(100% - 16px));
}

#chatPopup {
  background: transparent;
  padding: 0;
  position: relative;
  width: 100%;
}

.close-chat {
  position: absolute;
  top: 0;
  right: 0;
  background: transparent !important;
  border: none !important;
  font-size: 22px !important;
  color: var(--text-muted) !important;
  cursor: pointer !important;
  padding: 4px 8px !important;
  box-shadow: none !important;
  line-height: 1 !important;
}

#chatLog {
  height: 380px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--surface-alt);
  margin: 12px 0;
  scroll-behavior: smooth;
}

#onlineUsersSelect {
  margin: 10px 0;
  width: 100%;
}

#emoji-picker {
  display: none;
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  z-index: 9000;
  box-shadow: var(--shadow-lg);
  width: 280px;
  max-height: 200px;
  overflow-y: auto;
  line-height: 1.8;
}

#emoji-picker span {
  font-size: 20px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.12s;
  display: inline-block;
}
#emoji-picker span:hover { background: var(--bg-2); }

#file-browser {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-top: 8px;
  max-height: 150px;
  overflow-y: auto;
}

#server-file-list { list-style: none; padding: 0; }
#server-file-list li {
  padding: 6px 8px;
  font-size: 13px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  color: var(--primary);
  transition: background 0.13s;
}
#server-file-list li:hover { background: var(--bg-2); }

/* ============================================================
   AI WIDGET (FRIDAY)
   ============================================================ */
#aiWidget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
}

#aiPopup {
  width: min(460px, 92vw) !important;
  max-height: min(80vh, 680px);
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-xl) !important;
  box-shadow: var(--shadow-popup) !important;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.header,
.ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px !important;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  min-height: 54px;
}

.header span,
.ai-header span {
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.01em;
}

.header button,
.ai-header button {
  background: rgba(255,255,255,0.16) !important;
  color: #fff !important;
  border: none !important;
  font-size: 18px !important;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs) !important;
  padding: 0 !important;
  box-shadow: none !important;
  display: flex;
  align-items: center;
  justify-content: center;
}

#aiChatBox {
  padding: 14px !important;
  font-size: 14px !important;
  line-height: 1.6 !important;
  color: var(--text);
  overflow-y: auto;
  flex: 1;
  scroll-behavior: smooth;
}

#aiChatBox > div {
  display: block;
  padding: 11px 13px !important;
  margin-bottom: 10px !important;
  line-height: 1.6 !important;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  border-radius: var(--radius-md) !important;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

#aiChatBox > div:nth-child(odd) {
  background: linear-gradient(180deg, #faf8f5 0%, #f3f0eb 100%);
  border-color: var(--border);
}

#aiChatBox > div:nth-child(even) {
  background: linear-gradient(180deg, #f0f4fb 0%, #e8eef8 100%);
  border-color: rgba(30,58,95,0.16);
}

#aiCountdown {
  font-size: 12px !important;
  line-height: 1.4;
  color: var(--text-muted) !important;
  padding: 4px 14px 8px !important;
  text-align: center;
}

#aiProgressBar {
  width: calc(100% - 28px) !important;
  margin: 0 14px 10px !important;
}

#aiPopup > div[style*="border-top"] {
  padding: 12px 14px !important;
  border-top: 1px solid var(--border) !important;
  background: var(--surface-alt);
}

#aiForm {
  display: flex !important;
  align-items: center;
  gap: 8px !important;
}

#aiInput {
  flex: 1 1 auto;
  min-width: 0;
  margin-bottom: 0 !important;
  padding: 10px 12px !important;
  font-size: 14px !important;
  border-radius: var(--radius-sm) !important;
}

#aiForm button[type="submit"],
#aiPopup .ai-submit,
#aiPopup button[type="submit"] {
  flex: 0 0 auto;
  min-width: 80px;
  padding: 9px 12px !important;
  font-size: 12px !important;
  border-radius: var(--radius-sm) !important;
}

#aiPopup > .ai-toggle {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  width: auto !important;
  margin: 0 0 10px 14px;
  padding: 0 !important;
  vertical-align: middle;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

#aiPopup > .ai-toggle + .ai-toggle { margin-left: 14px; }

#aiPopup .ai-toggle input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  flex: 0 0 auto;
}

#aiPopup .ai-toggle span {
  font-size: 12px;
  line-height: 1.2;
  font-weight: 700;
  color: var(--text-soft);
  white-space: nowrap;
}

.ai-actions {
  display: flex;
  flex-wrap: nowrap !important;
  justify-content: space-between;
  align-items: stretch;
  gap: 6px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
}

.ai-actions button {
  flex: 1 1 0;
  min-width: 0;
  min-height: 36px;
  margin: 0 !important;
  padding: 6px 8px !important;
  font-size: 11px !important;
  line-height: 1.15;
  border-radius: var(--radius-sm) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: normal;
  word-break: break-word;
  background: linear-gradient(180deg, #17a2b8, #138496) !important;
  border-color: rgba(19,132,150,0.4) !important;
  box-shadow: none !important;
}
.ai-actions button:hover { background: linear-gradient(180deg, #138496, #117a8b) !important; }

/* ============================================================
   2FA / OTP PAGE
   ============================================================ */
.twofa-page {
  background: linear-gradient(135deg, #0f1e30 0%, #1e3a5f 60%, #16304f 100%);
  padding-top: var(--nav-height) !important;
  justify-content: center;
  min-height: 100vh;
}

.twofa-page::before { display: none; }

.twofa-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
  flex: 1;
}

.twofa-card {
  background: rgba(255,255,255,0.97);
  border-radius: var(--radius-xl);
  padding: 44px 48px 40px;
  width: min(480px, calc(100vw - 32px));
  box-shadow:
    0 32px 80px rgba(0,0,0,0.30),
    0 8px 24px rgba(0,0,0,0.18),
    inset 0 1px 0 rgba(255,255,255,0.9);
  text-align: center;
  animation: cardReveal 0.4s ease;
}

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

.twofa-brand img {
  max-width: 80px;
  height: auto;
  margin-bottom: 18px;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.12));
}

.twofa-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
  text-align: center;
}

.twofa-subtitle {
  color: var(--text-soft);
  font-size: 14px;
  margin-bottom: 28px;
  line-height: 1.5;
}

.twofa-alert {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(185,28,28,0.25);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 16px;
  text-align: left;
}

.twofa-info {
  background: #f0f4fb;
  color: var(--primary);
  border: 1px solid rgba(30,58,95,0.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 16px;
}

.otp-inputs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}

.otp-box {
  height: 62px !important;
  text-align: center;
  font-size: 28px !important;
  font-weight: 800 !important;
  border: 2px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  padding: 0 !important;
  margin-bottom: 0 !important;
  width: 100% !important;
  transition: border-color 0.16s, box-shadow 0.16s !important;
  caret-color: transparent;
}

.otp-box:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(30,58,95,0.14) !important;
  background: #f0f4fb;
}

.twofa-submit {
  width: 100%;
  padding: 14px 20px !important;
  font-size: 15px !important;
  border-radius: var(--radius-sm) !important;
  letter-spacing: 0.02em;
}

.twofa-submit:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

/* ============================================================
   SEARCH PAGE
   ============================================================ */
.search-page > form {
  padding: 20px var(--content-pad);
  margin-bottom: 4px;
}

.search-page > form label { display: inline; margin-right: 10px; }
.search-page > form input[type="text"] { width: auto; min-width: 280px; display: inline-block; margin-bottom: 0; margin-right: 8px; }
.search-page > form button { display: inline-block; margin: 0; }

.table-container {
  padding: var(--content-pad);
  width: min(var(--page-max), calc(100% - 16px));
}

/* ============================================================
   CREATE PDF PAGE
   ============================================================ */
.create-pdf-page #pdfForm {
  padding: var(--content-pad) 32px;
  width: min(var(--page-max), calc(100% - 16px));
}

.create-pdf-page #pdfForm label {
  font-size: 14px;
  margin-bottom: 8px;
}

.create-pdf-page #pdfForm input[type="text"] {
  margin-bottom: 16px;
}

/* ============================================================
   SIGN PDF PAGE
   ============================================================ */
body:not([class]) {
  padding-top: 64px;
}

body:not([class]) > form {
  width: min(520px, calc(100% - 24px));
}

/* ============================================================
   MENU DROPDOWN — forma compatta (stile "riga azioni") per pagine senza padding-top rimappato
   ============================================================ */
.menu-dropdown { position: fixed; }

/* ============================================================
   COUNTDOWN POPUP
   ============================================================ */
.countdown-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 36px 44px;
  z-index: calc(var(--z-popup) + 100);
  box-shadow: var(--shadow-popup);
  text-align: center;
  display: none;
}

.countdown-popup h2 {
  margin-bottom: 12px;
  color: var(--primary);
}

.countdown-popup #countdown {
  font-size: 3rem;
  font-weight: 800;
  color: var(--accent);
  font-family: var(--font-display);
  display: block;
  margin-top: 8px;
}

/* ============================================================
   PANNELLI INLINE DASHBOARD (PDF Management + Cestino)
   Mostrati nel flusso della pagina, sotto i controlli,
   con lo stesso stile della dashboard — no fixed/floating.
   ============================================================ */
#pdfManagementPopup,
#trashPopup {
  position: static !important;
  top: auto !important;
  left: auto !important;
  transform: none !important;
  max-width: 100% !important;
  width: min(var(--page-max), calc(100% - 16px)) !important;
  max-height: none !important;
  box-shadow: none !important;
  border-radius: var(--radius-lg) !important;
  animation: none !important;
  margin-top: 0;
  /* Bordo superiore accentuato per separare visivamente dal contenuto sopra */
  border-top: 3px solid var(--primary) !important;
  padding: 24px 28px !important;
}

/* delete-user popup variant */
.delete-user-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px 32px;
  z-index: calc(var(--z-popup) + 50);
  width: min(400px, calc(100vw - 32px));
  box-shadow: var(--shadow-popup);
  display: none;
}

.delete-user-popup h2 { font-family: var(--font-display); color: var(--danger); margin-bottom: 12px; }

/* ============================================================
   SPINNER OVERLAY
   ============================================================ */
#spinnerOverlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 28, 0.52);
  z-index: var(--z-spinner);
  display: none;
}

.spinner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.spinner::after {
  content: "";
  display: inline-block;
  width: var(--spinner-size);
  height: var(--spinner-size);
  border: var(--spinner-border) solid rgba(214, 210, 205, 0.38);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.spinner.sm { --spinner-size: 28px; --spinner-border: 4px; }
.spinner.lg { --spinner-size: 64px; --spinner-border: 6px; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   CONFIRM BUTTONS
   ============================================================ */
.confirm-buttons,
.two-factor-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.cancel-button { margin-top: 4px; }

/* ============================================================
   SHARE POPUP / SEARCH IN POPUP
   ============================================================ */
#userSearchContainer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#userSearchContainer button {
  padding: 6px 12px !important;
  font-size: 12px !important;
}

#userSearchContainer input {
  flex: 1;
  min-width: 140px;
  margin-bottom: 0 !important;
}

#userSearchResults {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 100px;
  overflow-y: auto;
  list-style: none;
  padding: 4px 0;
  margin-bottom: 10px;
}

#userSearchResults li {
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.13s;
  color: var(--primary);
}
#userSearchResults li:hover { background: var(--bg-2); }

/* ============================================================
   SIGNED PDF SUCCESS / CONFIRM SIGN POPUP
   ============================================================ */
#signedPdfSuccessPopup,
#confirmSignPopup {
  text-align: center;
}

#signedPdfSuccessPopup img,
#confirmSignPopup img { margin: 10px auto; display: block; }

/* ============================================================
   PASSWORD ACTIONS
   ============================================================ */
.password-actions { display: flex; justify-content: center; }

/* ============================================================
   MISC UTILITY
   ============================================================ */
.qr-code img {
  max-width: 220px;
  height: auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.foldersListContainer {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-bottom: 12px;
  min-height: 42px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1180px) {
  .dashboard-controls .centered-table tr { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .pdf-row { flex-direction: column; }
  .pdf-folders, .pdf-table { flex: 1 1 auto; }
  .popup.share,
  .popup.delete {
    right: auto;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) !important;
    width: min(92vw, 460px);
  }
}

@media (max-width: 760px) {
  body { padding-left: 10px; padding-right: 10px; }
  .dashboard-controls { grid-template-columns: 1fr; }
  .dashboard-controls .control-block:nth-child(2) { grid-column: auto; }
  .dashboard-controls .centered-table tr { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .dashboard-controls .centered-table img { width: 52px; height: 52px; }
  .menu-btn, .dropbtn { padding: 7px 12px !important; font-size: 12px !important; }
  .chat-page .container { padding: 16px 14px 66px; }
  .dashboard-search { flex-wrap: wrap; }
  .dashboard-search input[type="text"] { width: 100%; }
  .dashboard-search .search-btn { width: 100%; justify-content: center; }
  #aiPopup { padding: 14px; }
  #aiPopup { width: min(92vw, 360px) !important; }
  .main-actions button { font-size: 12px !important; padding: 7px 12px !important; }
}

@media (max-width: 520px) {
  #aiPopup { width: min(94vw, 420px) !important; }
  #aiPopup > .ai-toggle { margin-bottom: 8px; }
  #aiPopup .ai-actions { gap: 5px; padding: 10px 10px 12px; }
  #aiPopup .ai-actions button { font-size: 10px !important; padding: 6px 6px !important; }
}

@media (max-width: 480px) {
  .dashboard-controls .centered-table tr { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .otp-inputs { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .otp-box { height: 56px !important; font-size: 24px !important; }
  .twofa-card { padding: 28px 20px; }
  .popup, .countdown-popup, .delete-user-popup { padding: 20px; border-radius: var(--radius-lg); }
  h1 { margin-bottom: 18px; }
  .login-page .container { padding: 32px 24px; }
}

@media (max-width: 390px) {
  #aiPopup { width: min(96vw, 360px) !important; }
  #aiPopup .ai-actions button { font-size: 9.5px !important; line-height: 1.1; }
}

/* ============================================================
   TABELLE PDF — LAYOUT A CARD SU MOBILE (≤600px)
   Ogni riga <tr> diventa una card autonoma.
   Le intestazioni <thead> vengono nascoste.
   Ogni cella mostra un'etichetta tramite ::before (CSS-only).
   Funziona senza modificare HTML/JSP.
   ============================================================ */
@media (max-width: 600px) {

  /* ---- Wrapper scroll orizzontale disattivato: usiamo card ---- */
  #pdfTable,
  #signedPdfTable,
  #pdfManagementTable,
  #trashTable {
    border: none;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    margin-top: 8px;
    overflow: visible;
  }

  /* ---- Nascondi intestazioni colonne ---- */
  #pdfTable thead,
  #signedPdfTable thead,
  #pdfManagementTable thead,
  #trashTable thead {
    display: none;
  }

  /* ---- Ogni riga → card (userpanel: grid con Data+Seleziona affiancati) ---- */
  #pdfTable tbody tr,
  #signedPdfTable tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;   /* sinistra flessibile, destra per checkbox */
    grid-template-rows: auto auto;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
  }

  /* Nome: piena larghezza (entrambe le colonne) */
  #pdfTable tbody td:nth-child(1),
  #signedPdfTable tbody td:nth-child(1) {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  /* Data: colonna sinistra, seconda riga */
  #pdfTable tbody td:nth-child(2),
  #signedPdfTable tbody td:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
    border-bottom: none;
  }

  /* Seleziona: colonna destra, seconda riga — affiancata alla Data */
  #pdfTable tbody td:nth-child(3),
  #signedPdfTable tbody td:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
    border-bottom: none;
    border-left: 1px solid var(--border);
    justify-content: center;
    align-items: center;
    padding: 8px 16px;
    background: var(--surface-alt);
  }

  /* ---- Ogni riga → card (dashboard: grid con Azioni+Seleziona affiancati) ---- */
  #pdfManagementTable tbody tr,
  #trashTable tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;   /* sinistra flessibile, destra per checkbox */
    grid-template-rows: auto auto auto;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
  }

  /* Nome: piena larghezza (entrambe le colonne grid) */
  #pdfManagementTable tbody td:nth-child(1),
  #trashTable tbody td:nth-child(1) {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  /* Data: piena larghezza */
  #pdfManagementTable tbody td:nth-child(2),
  #trashTable tbody td:nth-child(2) {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  /* Azioni: colonna sinistra, terza riga */
  #pdfManagementTable tbody td:nth-child(3),
  #trashTable tbody td:nth-child(3) {
    grid-column: 1;
    grid-row: 3;
    flex-direction: row;
    align-items: center;
    padding: 8px 12px;
    border-bottom: none;
  }

  /* Seleziona: colonna destra, terza riga — affiancata alle Azioni */
  #pdfManagementTable tbody td:nth-child(4),
  #trashTable tbody td:nth-child(4) {
    grid-column: 2;
    grid-row: 3;
    border-bottom: none;
    border-left: 1px solid var(--border);
    justify-content: center;
    align-items: center;
    padding: 8px 16px;
    background: var(--surface-alt);
  }

  /* ---- Ogni cella → riga flex con etichetta ---- */
  #pdfTable tbody td,
  #signedPdfTable tbody td,
  #pdfManagementTable tbody td,
  #trashTable tbody td {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    border-bottom: 1px solid var(--border);
    white-space: normal;
    text-align: left;
    font-size: 13px;
  }

  /* Ultima cella: niente bordo inferiore */
  #pdfTable tbody tr td:last-child,
  #signedPdfTable tbody tr td:last-child,
  #pdfManagementTable tbody tr td:last-child,
  #trashTable tbody tr td:last-child {
    border-bottom: none;
  }

  /* ---- Etichette comuni via ::before ---- */
  #pdfTable tbody td::before,
  #signedPdfTable tbody td::before,
  #pdfManagementTable tbody td::before,
  #trashTable tbody td::before {
    font-weight: 700;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    min-width: 64px;
    flex-shrink: 0;
    line-height: 1.3;
  }

  /* ---- pdfTable / signedPdfTable: 3 colonne (Nome | Data | Seleziona) ---- */
  #pdfTable tbody td:nth-child(1)::before,
  #signedPdfTable tbody td:nth-child(1)::before { content: "Nome"; }

  #pdfTable tbody td:nth-child(2)::before,
  #signedPdfTable tbody td:nth-child(2)::before { content: "Data"; }

  /* Seleziona (td:3): gestita dal grid definito sopra */
  #pdfTable tbody td:nth-child(3)::before,
  #signedPdfTable tbody td:nth-child(3)::before { content: none; min-width: 0; }

  /* ---- pdfManagementTable / trashTable: etichette Nome e Data ---- */
  #pdfManagementTable tbody td:nth-child(1)::before { content: "Nome"; }
  #pdfManagementTable tbody td:nth-child(2)::before { content: "Data"; }
  #pdfManagementTable tbody td:nth-child(3)::before,
  #pdfManagementTable tbody td:nth-child(4)::before { content: none; min-width: 0; }

  #trashTable tbody td:nth-child(1)::before { content: "Nome"; }
  #trashTable tbody td:nth-child(2)::before { content: "Data"; }
  #trashTable tbody td:nth-child(3)::before,
  #trashTable tbody td:nth-child(4)::before { content: none; min-width: 0; }

  /* ---- Checkbox: non serve il margin:auto su card layout ---- */
  #pdfTable td input[type="checkbox"],
  #signedPdfTable td input[type="checkbox"],
  #pdfManagementTable td input[type="checkbox"],
  #trashTable td input[type="checkbox"] {
    margin: 0;
    width: 18px;
    height: 18px;
  }

  /* ---- Azioni su mobile: elimina il dropdown, mostra i bottoni inline ---- */

  /* La cella Azioni occupa tutta la larghezza, senza etichetta */
  #pdfManagementTable tbody td:nth-child(3),
  #trashTable tbody td:nth-child(3) {
    flex-direction: column;
    align-items: stretch;
    padding: 10px 14px;
    gap: 0;
  }

  /* Nascondi il bottone "Azioni" — non serve il trigger del dropdown */
  #pdfManagementTable td .dropdown .dropbtn,
  #trashTable td .dropdown .dropbtn {
    display: none !important;
  }

  /* Il wrapper .dropdown diventa un contenitore statico full-width */
  #pdfManagementTable td .dropdown,
  #trashTable td .dropdown {
    position: static;
    display: block;
    width: 100%;
  }

  /* Il menu .dropdown-content diventa sempre visibile, statico, a griglia */
  #pdfManagementTable td .dropdown-content,
  #trashTable td .dropdown-content {
    display: flex !important;       /* sempre visibile: niente position:absolute */
    position: static !important;
    flex-wrap: nowrap;              /* tutti i bottoni sulla stessa riga */
    gap: 5px;
    padding: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    min-width: 0;
    overflow: visible;
    width: 100%;
  }

  /* Ogni voce del menu → bottone compatto e touch-friendly, sulla stessa riga */
  #pdfManagementTable td .dropdown-content button,
  #pdfManagementTable td .dropdown-content a,
  #trashTable td .dropdown-content button,
  #trashTable td .dropdown-content a {
    display: inline-flex !important;  /* batte display:block !important globale */
    align-items: center !important;
    justify-content: center !important;
    flex: 0 0 auto !important;
    width: auto !important;           /* batte width:100% !important globale */
    padding: 6px 10px !important;
    border-radius: var(--radius-xs) !important;
    border: 1px solid var(--border) !important;
    background: var(--surface-alt) !important;
    color: var(--text) !important;
    font-size: 10px !important;
    font-weight: 600 !important;
    text-align: center !important;
    cursor: pointer;
    white-space: nowrap !important;
    box-shadow: var(--shadow-sm) !important;
    transition: background 0.14s, color 0.14s !important;
    line-height: 1.2 !important;
  }

  #pdfManagementTable td .dropdown-content button:hover,
  #pdfManagementTable td .dropdown-content a:hover,
  #trashTable td .dropdown-content button:hover,
  #trashTable td .dropdown-content a:hover {
    background: var(--accent-soft) !important;
    color: var(--primary) !important;
  }

  /* Bottone "Cancella" / "Elimina" → rosso */
  #pdfManagementTable td .dropdown-content button[onclick*="confirm"],
  #pdfManagementTable td .dropdown-content button[onclick*="Cancella"],
  #trashTable td .dropdown-content button[onclick*="confirm"],
  #trashTable td .dropdown-content button[onclick*="Elimina"],
  #trashTable td .dropdown-content button[onclick*="permanentDelete"] {
    border-color: var(--danger) !important;
    color: var(--danger) !important;
    background: var(--danger-soft) !important;
  }

  /* Seleziona (td:4): gestita dal grid definito sopra */

  /* ---- Cartella sidebar: compatta su mobile ---- */
  .pdf-folders {
    padding: 12px;
  }
  .folder-item {
    font-size: 12px;
    padding: 7px 10px;
  }

  /* ---- Tabella delle righe "nessun file" (colSpan) ---- */
  #pdfTable tbody tr td[colspan],
  #signedPdfTable tbody tr td[colspan],
  #pdfManagementTable tbody tr td[colspan],
  #trashTable tbody tr td[colspan] {
    display: block;
    text-align: center;
  }
  #pdfTable tbody tr td[colspan]::before,
  #signedPdfTable tbody tr td[colspan]::before,
  #pdfManagementTable tbody tr td[colspan]::before,
  #trashTable tbody tr td[colspan]::before { content: none; }
}


/* ============================================================
   NUOVA STRUTTURA NAV — pulsanti a sinistra, brand centrato,
   utente loggato a destra
   ============================================================ */
.nav-left-group {
  display: flex;
  align-items: center;
  align-self: stretch;      /* occupa tutta l'altezza della navbar */
  align-items: stretch;     /* i figli si estendono all'altezza completa */
  gap: 4px;
  z-index: 1;
}

.nav-menu-wrap {
  position: relative;
  display: flex;
  align-items: center;      /* centra il bottone verticalmente */
  align-self: stretch;      /* si estende per tutta l'altezza navbar (64px) */
}

/* Dropdown subito sotto il wrapper — nessun gap, il mouse non esce dall'area hover */
.nav-menu-wrap .menu-dropdown-content {
  top: 100%;
  left: 0;
}

.nav-user-wrap {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.10);
  color: rgba(255,255,255,0.92);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-ui);
  transition: background 0.18s, border-color 0.18s;
  white-space: nowrap;
  z-index: 1;
  letter-spacing: 0.01em;
  flex-shrink: 0;
}
.nav-user-wrap:hover {
  background: rgba(255,255,255,0.20);
  border-color: rgba(255,255,255,0.30);
}

.nav-user-photo {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.35);
  flex-shrink: 0;
  background: rgba(255,255,255,0.15);
}

.nav-user-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-page-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.60);
  padding-right: 10px;
  border-right: 1px solid rgba(255,255,255,0.22);
  margin-right: 2px;
  white-space: nowrap;
  flex-shrink: 0;
}


/* ============================================================
   POPUP PROFILO UTENTE
   ============================================================ */
#userProfilePopup {
  width: min(500px, calc(100vw - 32px));
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

.profile-photo-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.profile-photo-large {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border-strong);
  box-shadow: var(--shadow-md);
  background: var(--bg-2);
}

.profile-photo-upload-label {
  cursor: pointer;
  background: rgba(30,58,95,0.09);
  color: var(--primary);
  border: 1px solid rgba(30,58,95,0.22);
  border-radius: var(--radius-xs);
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  display: inline-block;
  transition: background 0.15s;
}
.profile-photo-upload-label:hover { background: rgba(30,58,95,0.15); }

.profile-section-divider {
  border-top: 1px solid var(--border);
  margin: 18px 0 14px;
  padding-top: 14px;
}
.profile-section-divider h3 { margin-bottom: 12px; }

.profile-save-btn { width: 100%; margin-top: 4px; margin-bottom: 0; }

.profile-pwd-btn {
  width: 100%;
  background: linear-gradient(180deg, #2d9b6b 0%, var(--success) 100%) !important;
  border-color: rgba(35,86,57,.45) !important;
}

/* ============================================================
   PROFILO UTENTE — blocco dati in sola lettura
   ============================================================ */
.profile-info-block {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 4px;
}
.profile-info-row {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  font-size: 13.5px;
}
.profile-info-row:last-child { border-bottom: none; }
.profile-info-label {
  font-weight: 700;
  color: var(--text-soft);
  min-width: 80px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}
.profile-info-value {
  color: var(--text);
  font-weight: 500;
  word-break: break-all;
}
