:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-2: #1e40af;
  --border: #dbe3f0;
  --ok: #065f46;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.container {
  max-width: 980px;
  margin: 2rem auto;
  padding: 0 1rem 2rem;
}

h1 {
  margin-bottom: 0.25rem;
}

.subtitle {
  margin-top: 0;
  color: var(--muted);
}

.page-link {
  display: inline-block;
  margin-top: 0.25rem;
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 600;
}

.page-link:hover {
  text-decoration: underline;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  margin-top: 1rem;
}

.grid {
  display: grid;
  gap: 0.75rem;
}

.grid.one { grid-template-columns: 1fr; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid.four { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.92rem;
}

input, select, button {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  font-size: 0.95rem;
}

input:focus, select:focus {
  outline: 2px solid #bfdbfe;
  border-color: var(--accent);
}

.actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.75rem;
}

.actions.compact {
  margin-top: 1.55rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

button {
  cursor: pointer;
  background: var(--accent);
  color: white;
  border: none;
}

button:hover { background: var(--accent-2); }

button.secondary {
  background: #eef2ff;
  color: #1e3a8a;
  border: 1px solid #c7d2fe;
}

.hidden { display: none; }

.mode-box {
  padding: 0.65rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  margin-top: 0.25rem;
}

.results-list {
  display: grid;
  gap: 0.75rem;
}

.result-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  background: #fafcff;
}

.result-item h3 {
  margin: 0 0 0.35rem;
}

.result-collapse-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.2rem;
}

.result-collapse-head h3 {
  margin: 0;
}

.toggle-room-result {
  padding: 0.32rem 0.62rem;
  font-size: 0.82rem;
  border-radius: 8px;
}

.result-collapse-body {
  margin-top: 0.35rem;
}

.result-item ul {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
}

.quote-diagram {
  margin-top: 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 0.4rem;
  overflow-x: auto;
}

.quote-diagram svg {
  width: 100%;
  min-width: 560px;
  height: auto;
  color: #334155;
  letter-spacing: 0.1px;
}

.quote-diagram rect,
.quote-diagram line,
.quote-diagram path,
.quote-diagram circle {
  stroke: currentColor;
  stroke-width: 1.15;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.quote-diagram text {
  fill: currentColor;
  font-size: 10.8px;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
}

.quote-diagram .tech-fill {
  fill: #efe8dd;
  stroke: #4b5563;
}

.quote-diagram .tech-bg {
  fill: #e8ded1;
  stroke: #c7b8a4;
}

.quote-diagram .manifold {
  fill: #d8d5d0;
  stroke: #4b5563;
}

.quote-diagram .tube-front,
.quote-diagram .tube-side {
  fill: #f7f5f2;
  stroke: #4b5563;
}

.quote-diagram .cap {
  fill: #e7e3dd;
  stroke: #374151;
}

.quote-diagram .cap-core {
  fill: none;
  stroke: #374151;
}

.quote-diagram .guide {
  stroke: #6b7280;
  stroke-dasharray: 4 3;
}

.quote-diagram .dim-line {
  stroke: #1f2937;
}

.ok { color: var(--ok); font-weight: 600; }
.empty { color: var(--muted); }

.summary p { margin: 0.35rem 0; }

.table-wrap {
  overflow-x: auto;
}

.line-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

.line-table th,
.line-table td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.5rem;
  font-size: 0.9rem;
  text-align: left;
  white-space: nowrap;
}

.line-table thead th {
  background: #eef2ff;
}

.line-table tfoot td {
  background: #f8fafc;
}

.line-actions-cell {
  width: 108px;
  min-width: 108px;
  text-align: center;
  white-space: nowrap;
}

.line-actions-trigger {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  height: 34px;
  padding: 0 .55rem;
  border-radius: 10px;
  border: 1px solid #dbe3f0;
  background: #ffffff;
  color: #1e3a8a;
  font-size: .8rem;
  font-weight: 700;
  line-height: 1;
  transition: all .16s ease;
}

.line-actions-trigger:hover {
  background: #eef2ff;
  border-color: #c7d2fe;
  transform: translateY(-1px);
}

.floating-actions-menu {
  position: fixed;
  z-index: 1200;
  min-width: 260px;
  padding: 0.5rem;
  border-radius: 14px;
  border: 1px solid #dbe3f0;
  background: #ffffff;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.2);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top left;
  transition: opacity .16s ease, transform .16s ease;
}

.floating-actions-menu.hidden {
  display: none;
}

.floating-actions-menu.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.floating-actions-menu.is-closing {
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
}

.floating-actions-menu .line-action-btn {
  opacity: 1;
  transform: none;
}

.floating-actions-menu.is-open .line-action-btn {
  animation: menuItemIn .22s cubic-bezier(.22,.61,.36,1) forwards;
}

.floating-actions-menu.is-open .line-action-btn:nth-child(1) { animation-delay: .02s; }
.floating-actions-menu.is-open .line-action-btn:nth-child(2) { animation-delay: .05s; }
.floating-actions-menu.is-open .line-action-btn:nth-child(3) { animation-delay: .08s; }
.floating-actions-menu.is-open .line-action-btn:nth-child(4) { animation-delay: .11s; }

@keyframes menuItemIn {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .floating-actions-menu,
  .floating-actions-menu .line-action-btn {
    transition: none !important;
    animation: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
}

.line-action-btn {
  width: 100%;
  text-align: left;
  background: #f8fafc;
  border: 1px solid var(--border);
  color: #1f2937;
  border-radius: 10px;
  padding: 0.48rem 0.62rem;
  font-size: 0.82rem;
}

.line-action-btn:hover {
  background: #f8fafc;
}

.line-action-btn.danger {
  color: #991b1b;
  border-color: #fecaca;
  background: #fef2f2;
}

.line-action-btn.danger:hover {
  background: #fee2e2;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-panel {
  width: min(980px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 1rem;
}

/* Glass-style per il modal di ripristino sessione */
.modal-panel.glass {
  width: min(440px, 100%);
  text-align: center;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 8px 40px rgba(15, 23, 42, 0.22), 0 1.5px 4px rgba(99,102,241,0.08);
  border-radius: 18px;
  padding: 2rem 2rem 1.5rem;
  animation: glassIn 0.22s cubic-bezier(.4,0,.2,1);
}

@keyframes glassIn {
  from { opacity: 0; transform: translateY(-18px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)     scale(1);    }
}

.restore-icon {
  font-size: 2.8rem;
  margin-bottom: 0.4rem;
  line-height: 1;
}

.restore-info {
  margin: 1rem auto 1.2rem;
  background: rgba(238,242,255,0.80);
  border: 1px solid rgba(99,102,241,0.18);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-size: 0.93rem;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.restore-info span { color: var(--text-muted, #64748b); }
.restore-info strong { color: var(--text, #1e293b); }

.restore-actions {
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0;
}

.option-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.4rem;
}

.option-table th,
.option-table td {
  border: 1px solid var(--border);
  padding: 0.45rem;
  font-size: 0.88rem;
  text-align: left;
}

.option-table thead th {
  background: #eef2ff;
}

.option-table tbody tr[data-opt-idx]:hover {
  background: #eff6ff;
  outline: 2px solid #6366f1;
  outline-offset: -2px;
}
.option-table tbody tr[data-opt-idx]:active {
  background: #e0e7ff;
}

.cod-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.cod-badge.coded {
  color: #065f46;
  background: #d1fae5;
  border-color: #6ee7b7;
}

.cod-badge.missing {
  color: #991b1b;
  background: #fee2e2;
  border-color: #fca5a5;
}

.cod-badge.theoretical {
  color: #92400e;
  background: #fef3c7;
  border-color: #fcd34d;
}

/* Riga teorica nella tabella lineare */
.row-theoretical {
  background: #fffbeb !important;
}
.row-theoretical td {
  color: #92400e;
}

/* Anteprima selezione diretta */
.direct-preview {
  margin-top: .75rem;
  padding: .85rem 1.1rem;
  border-radius: 10px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  font-size: .9rem;
  line-height: 1.6;
}
.direct-preview .dp-label { color: #6b7280; }
.direct-preview strong { color: #1e3a8a; }
.direct-preview .dp-warn { color: #b45309; font-weight: 600; }

/* ── Navbar ──────────────────────────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 200;
  background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 100%);
  box-shadow: 0 2px 12px rgba(30,58,138,.35);
  font-size: 0.9rem;
}

.navbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  white-space: nowrap;
}

.navbar-brand span { font-size: 1.25rem; }

.navbar-links {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.navbar-links a {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: #bfdbfe;
  text-decoration: none;
  padding: 0.38rem 0.75rem;
  border-radius: 8px;
  transition: background .15s, color .15s;
  white-space: nowrap;
  font-weight: 500;
}

.navbar-links a:hover,
.navbar-links a.active {
  background: rgba(255,255,255,.14);
  color: #fff;
}

.navbar-links .nav-sep {
  width: 1px;
  height: 22px;
  background: rgba(255,255,255,.18);
  margin: 0 0.25rem;
}

/* Dropdown admin */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-btn {
  display: flex;
  align-items: center;
  gap: .35rem;
  background: none;
  border: none;
  color: #bfdbfe;
  padding: .38rem .75rem;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.nav-dropdown-btn:hover,
.nav-dropdown-btn.active {
  background: rgba(255,255,255,.14);
  color: #fff;
}
.nav-dropdown-arrow {
  font-size: .7rem;
  opacity: .75;
  transition: transform .2s;
}
.nav-dropdown.open .nav-dropdown-arrow {
  transform: rotate(180deg);
}

.nav-dropdown-menu.open ~ .nav-dropdown-btn .nav-dropdown-arrow,
.nav-dropdown-btn[aria-expanded="true"] .nav-dropdown-arrow {
  transform: rotate(180deg);
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: #1e3a8a;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
  padding: .4rem 0;
  list-style: none;
  margin: 0;
  z-index: 300;
}
.nav-dropdown.open .nav-dropdown-menu { display: block; }

.nav-dropdown-menu li a {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .55rem 1rem;
  color: #bfdbfe;
  text-decoration: none;
  font-size: .88rem;
  font-weight: 500;
  transition: background .12s, color .12s;
  border-radius: 0;
}
.nav-dropdown-menu li a:hover,
.nav-dropdown-menu li a.active {
  background: rgba(255,255,255,.12);
  color: #fff;
}

@media (max-width: 768px) {
  .nav-dropdown-menu {
    position: static;
    box-shadow: none;
    border: none;
    border-top: 1px solid rgba(255,255,255,.1);
    border-radius: 0;
    padding: 0;
    background: transparent;
  }
  .nav-dropdown-menu li a {
    padding: .45rem .5rem .45rem 1.5rem;
  }
  .nav-dropdown-btn { padding: .55rem .5rem; }
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #bfdbfe;
  font-size: 0.85rem;
}

.navbar-user strong { color: #fff; }

.navbar-username {
  color: #bfdbfe;
  font-size: .85rem;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.navbar-username > span:first-child {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
}

.navbar-username strong { color: #fff; }

/* Username come pulsante dropdown (solo admin) */
.nav-user-btn strong { color: #fff; }
.nav-user-btn { font-size: .85rem; }

/* Info utente con nome società */
.nav-user-info {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.nav-user-info > span:first-child {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
}

.nav-user-company {
  font-size: 0.7rem;
  color: #000;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.2s, color 0.2s;
  text-decoration: underline;
  text-decoration-style: dotted;
}

.nav-user-company:hover {
  opacity: 1;
  color: #333;
}

/* Modal Dati Utente */
.user-modal {
  display: none;
  position: fixed;
  z-index: 10000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.user-modal-content {
  background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
  border-radius: 12px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: slideDown 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

@keyframes slideDown {
  from { transform: translateY(-50px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.user-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.user-modal-header h3 {
  margin: 0;
  color: #fff;
  font-size: 1.1rem;
}

.user-modal-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
  padding: 0;
  width: 30px;
  height: 30px;
  line-height: 1;
}

.user-modal-close:hover {
  opacity: 1;
}

.user-modal-body {
  padding: 1.25rem;
}

.user-info-row {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info-row:last-child {
  margin-bottom: 0;
}

.user-info-label {
  color: #bfdbfe;
  font-weight: 600;
  font-size: 0.9rem;
}

.user-info-value {
  color: #fff;
  font-size: 0.9rem;
}

.drop-section-title {
  padding: .3rem 1rem .2rem;
  font-size: .7rem;
  font-weight: 700;
  color: rgba(255,255,255,.4);
  text-transform: uppercase;
  letter-spacing: .06em;
  pointer-events: none;
  border-bottom: 1px solid rgba(255,255,255,.1);
  margin-bottom: .2rem;
}

.navbar-user .nav-save {
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.22);
  color: #fff;
  padding: 0.3rem 0.65rem;
  font-size: 0.82rem;
  border-radius: 7px;
}

.navbar-user .nav-save:hover { background: rgba(255,255,255,.26); }

.navbar-user .nav-load {
  background: transparent;
  border: 1px solid rgba(255,255,255,.22);
  color: #bfdbfe;
  padding: 0.3rem 0.65rem;
  font-size: 0.82rem;
  border-radius: 7px;
}

.navbar-user .nav-load:hover { background: rgba(255,255,255,.1); color: #fff; }

.nav-logout {
  color: #fca5a5;
  text-decoration: none;
  padding: 0.3rem 0.65rem;
  border: 1px solid rgba(252,165,165,.35);
  border-radius: 7px;
  font-size: 0.82rem;
  transition: background .15s;
}

.nav-logout:hover { background: rgba(239,68,68,.2); color: #fca5a5; text-decoration: none; }

/* hamburger – mobile */
.navbar-toggle {
  display: none;
  background: none;
  border: 1px solid rgba(255,255,255,.3);
  color: #fff;
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  font-size: 1.1rem;
  cursor: pointer;
}

.navbar-menu {
  display: contents;
}

@media (max-width: 768px) {
  .navbar-toggle { display: flex; align-items: center; }

  .navbar-menu {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    position: absolute;
    top: 52px;
    left: 0;
    right: 0;
    background: #1e3a8a;
    border-top: 1px solid rgba(255,255,255,.12);
    padding: 0.5rem 1rem 0.75rem;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
  }

  .navbar-menu.open { display: flex; }

  .navbar-links {
    flex-direction: column;
    align-items: stretch;
    gap: 0.15rem;
  }

  .navbar-links .nav-sep { display: none; }
  .navbar-links a { padding: 0.55rem 0.5rem; }

  .navbar-user {
    flex-wrap: wrap;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255,255,255,.12);
    margin-top: 0.25rem;
    gap: 0.4rem;
  }
}

/* ── Top bar legacy (rimosso, tenuto per compatibilità) ───────────────────── */
.top-bar { display: none; }

/* ── Tappi diagram modal ─────────────────────────────────────────────────── */
.tappi-diagram {
  display: flex;
  align-items: stretch;
  gap: 0;
  border: 2px solid #cbd5e1;
  border-radius: 14px;
  overflow: hidden;
  background: #f8fafc;
  min-height: 180px;
}

.tappi-side {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: .75rem .6rem;
  background: #eef2ff;
  gap: .6rem;
  min-width: 0;
  flex: 1;
}
.tappi-side-sx { border-right: 2px dashed #c7d2fe; }
.tappi-side-dx { border-left:  2px dashed #c7d2fe; }

.tappi-slot {
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.tappi-slot-label {
  font-size: .72rem;
  font-weight: 600;
  color: #4338ca;
  display: flex;
  align-items: center;
  gap: .35rem;
  white-space: nowrap;
}
.tappi-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: #4f46e5;
  color: #fff;
  border-radius: 50%;
  font-size: .7rem;
  font-weight: 700;
  flex-shrink: 0;
}
.tappi-select {
  font-size: .75rem;
  padding: .28rem .45rem;
  border: 1px solid #c7d2fe;
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  max-width: 200px;
  cursor: pointer;
}
.tappi-select:focus { outline: 2px solid #6366f1; }

/* IRSAP configuration cap labels (testo readonly nel diagramma) */
.irsap-cap-label {
  display: inline-block;
  font-size: .8rem;
  font-weight: 600;
  padding: .3rem .6rem;
  background: #e0f2fe;
  color: #0c4a6e;
  border: 1px solid #7dd3fc;
  border-radius: 7px;
  max-width: 200px;
  white-space: nowrap;
}

.tappi-body {
  flex: 2;
  display: flex;
  flex-direction: column;
  position: relative;
  background: #fff;
  border-left: 2px solid #e2e8f0;
  border-right: 2px solid #e2e8f0;
  min-width: 120px;
  padding: .5rem;
  justify-content: center;
  align-items: center;
}
.tappi-body-inner {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  padding: .4rem .75rem;
  background: linear-gradient(135deg, #e0e7ff 0%, #ede9fe 100%);
  border-radius: 10px;
  border: 1.5px solid #a5b4fc;
}
.tappi-body-tube {
  height: 12px;
  background: linear-gradient(90deg, #6366f1 0%, #818cf8 100%);
  border-radius: 6px;
  opacity: .7;
}
/* pallini connessione agli angoli */
.tappi-body-conn {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #4f46e5;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px #6366f1;
}
.tappi-conn-tl { top:  8px; left:  8px; }
.tappi-conn-tr { top:  8px; right: 8px; }
.tappi-conn-bl { bottom: 8px; left:  8px; }
.tappi-conn-br { bottom: 8px; right: 8px; }

/* ── Login page ─────────────────────────────────────────────────────────── */
body.login-page {
  min-height: 100vh;
  background: linear-gradient(145deg, #0f172a 0%, #1e3a8a 55%, #1d4ed8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow: hidden;
  position: relative;
}

/* Griglia puntini di sfondo */
.login-bg-grid {
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,.07) 1px, transparent 1px);
  background-size: 30px 30px;
  pointer-events: none;
  z-index: 0;
}

/* Cerchi sfumati decorativi */
.login-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
}
.login-orb-1 {
  width: 400px; height: 400px;
  background: rgba(59,130,246,.25);
  top: -100px; right: -80px;
}
.login-orb-2 {
  width: 350px; height: 350px;
  background: rgba(139,92,246,.15);
  bottom: -80px; left: -60px;
}

/* Contenitore centrale */
.login-wrap {
  width: min(420px, 100%);
  position: relative;
  z-index: 1;
  animation: loginFadeUp .45s cubic-bezier(.22,.68,0,1.2) both;
}

@keyframes loginFadeUp {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Hero branding */
.login-hero {
  text-align: center;
  margin-bottom: 1.75rem;
  color: #fff;
}

.login-logo {
  width: 72px; height: 72px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}

.login-logo-icon {
  font-size: 2.2rem;
  line-height: 1;
  filter: drop-shadow(0 2px 6px rgba(255,255,255,.3));
}

.login-hero h1 {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #fff;
}

.login-hero p {
  margin: 0.3rem 0 0;
  color: #93c5fd;
  font-size: 0.88rem;
}

/* Card */
.login-card {
  background: rgba(255,255,255,.97);
  border-radius: 22px;
  padding: 2rem 2rem 1.75rem;
  box-shadow:
    0 30px 60px rgba(0,0,0,.35),
    0 1px 0 rgba(255,255,255,.15) inset;
  border: 1px solid rgba(255,255,255,.12);
}

.login-card h2 {
  margin: 0 0 1.4rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: #1e3a8a;
}

/* Campi form */
.login-field {
  margin-bottom: 1rem;
}

.input-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.4rem;
  letter-spacing: 0.1px;
}

.input-group {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.95rem;
  pointer-events: none;
  z-index: 1;
}

.input-group input {
  width: 100%;
  padding: 0.72rem 0.85rem 0.72rem 2.55rem;
  border: 1.5px solid #dbe3f0;
  border-radius: 12px;
  font-size: 0.95rem;
  background: #f8fafc;
  color: #1f2937;
  transition: border-color .18s, box-shadow .18s, background .18s;
}

.input-group input::placeholder { color: #9ca3af; }

.input-group input:focus {
  border-color: #2563eb;
  background: #fff;
  box-shadow: 0 0 0 3.5px rgba(37,99,235,.14);
  outline: none;
}

/* Bottone submit */
.login-btn {
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.82rem;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: opacity .15s, transform .12s, box-shadow .15s;
  box-shadow: 0 4px 14px rgba(37,99,235,.45);
}

.login-btn:hover {
  opacity: .93;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(37,99,235,.55);
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
}

.login-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(37,99,235,.35);
}

/* Errore */
.login-error {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #991b1b;
  border-radius: 10px;
  padding: 0.6rem 0.85rem;
  margin-bottom: 1rem;
  font-size: 0.88rem;
  font-weight: 500;
}

/* Footer sotto la card */
.login-footer {
  text-align: center;
  margin-top: 1.25rem;
  color: rgba(147,197,253,.65);
  font-size: 0.76rem;
  letter-spacing: 0.2px;
}

/* ── Pagine users / register ────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: .25rem;
}

.page-header h1 { margin-bottom: .1rem; }

.btn-primary {
  display: inline-block;
  background: linear-gradient(135deg,#1e3a8a,#2563eb);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: .55rem 1.1rem;
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity .15s, transform .12s;
  white-space: nowrap;
}
.btn-primary:hover { opacity: .9; transform: translateY(-1px); }

.btn-outline {
  display: inline-block;
  background: transparent;
  color: var(--accent-2);
  border: 1.5px solid var(--accent);
  border-radius: 10px;
  padding: .5rem 1rem;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.btn-outline:hover { background: #eef2ff; }

.btn-cancel {
  display: inline-block;
  background: #f1f5f9;
  color: #374151;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .55rem 1rem;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}
.btn-cancel:hover { background: #e2e8f0; }

/* Alerts */
.alert {
  border-radius: 10px;
  padding: .65rem .9rem;
  font-size: .9rem;
  font-weight: 500;
  margin-bottom: .75rem;
}
.alert-ok {
  background: #d1fae5;
  border: 1px solid #6ee7b7;
  color: #065f46;
}
.alert-ok a { color: #065f46; font-weight: 700; margin-left: .5rem; }
.alert-err {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #991b1b;
}

/* Form campi */
.form-row {
  display: grid;
  gap: .75rem;
}
.form-row.four { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }

/* ── Filter bar ────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  align-items: center;
  margin-top: 1.1rem;
}
.filter-input {
  flex: 1;
  min-width: 200px;
  padding: .55rem .8rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: .92rem;
  background: #fff;
}
.filter-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
  outline: none;
}
.filter-select {
  padding: .55rem .7rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: .88rem;
  background: #fff;
  cursor: pointer;
}
.filter-select:focus {
  border-color: var(--accent);
  outline: none;
}

/* ── Paginazione ──────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: 1.1rem;
}
.pg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 .6rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 500;
  transition: background .12s, border-color .12s;
}
.pg-btn:hover { background: #eef2ff; border-color: var(--accent); color: var(--accent); }
.pg-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}
.pg-dots { color: var(--muted); padding: 0 .25rem; font-size: .9rem; }
.pg-info { margin-left: .5rem; color: var(--muted); font-size: .82rem; }

.form-field { display: flex; flex-direction: column; gap: .35rem; }

.field-label {
  font-size: .82rem;
  font-weight: 600;
  color: #374151;
  letter-spacing: .1px;
}
.field-label .req { color: #dc2626; }

.form-field input[type=text],
.form-field input[type=password] {
  width: 100%;
  padding: .65rem .8rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: .93rem;
  background: #f8fafc;
  color: #1f2937;
  transition: border-color .15s, box-shadow .15s;
}
.form-field input:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
  outline: none;
}

.field-hint { font-size: .8rem; color: var(--muted); }

/* Password con toggle */
.pw-wrap {
  position: relative;
  display: flex;
}
.pw-wrap input { flex: 1; padding-right: 2.6rem; }
.pw-toggle {
  position: absolute;
  right: .5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  font-size: .95rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.pw-toggle:hover { color: var(--accent); background: none; }

/* Checkbox custom */
.check-label {
  display: flex;
  align-items: center;
  gap: .55rem;
  cursor: pointer;
  font-size: .9rem;
  color: var(--text);
}
.check-label input[type=checkbox] {
  width: 1rem; height: 1rem;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Tabella utenti */
.users-table {
  width: 100%;
  border-collapse: collapse;
}
.users-table th {
  background: #eef2ff;
  padding: .6rem .85rem;
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: #1e3a8a;
  text-align: left;
  white-space: nowrap;
}
.users-table td {
  padding: .65rem .85rem;
  border-top: 1px solid var(--border);
  font-size: .9rem;
  vertical-align: middle;
}
.users-table tr:hover td { background: #f8faff; }
.users-table tr.row-self td { background: #f0f9ff; }

.td-id    { color: var(--muted); font-size: .8rem; width: 36px; text-align:center; }
.td-date  { color: var(--muted); font-size: .82rem; white-space: nowrap; }
.td-actions { padding: .45rem .6rem !important; width: 1%; white-space: nowrap; }
.td-actions div { display: flex; gap: .4rem; align-items: center; flex-wrap: nowrap; }

/* Badge ruolo */
.badge-admin {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #93c5fd;
}
.badge-user {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  background: #f3f4f6;
  color: #4b5563;
  border: 1px solid #d1d5db;
}
.badge-you {
  display: inline-block;
  padding: .1rem .45rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #6ee7b7;
  margin-left: .35rem;
}

/* Bottoni tabella */
.btn-edit {
  background: #eef2ff;
  color: #1e3a8a;
  border: 1px solid #c7d2fe;
  border-radius: 7px;
  padding: .3rem .65rem;
  font-size: .82rem;
  cursor: pointer;
  transition: background .15s;
}
.btn-edit:hover { background: #dbeafe; }

.btn-delete {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
  border-radius: 7px;
  padding: .3rem .65rem;
  font-size: .82rem;
  cursor: pointer;
  transition: background .15s;
}
.btn-delete:hover { background: #fecaca; }

/* Modal close button */
.modal-close-btn {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .25rem .6rem;
  cursor: pointer;
  font-size: .9rem;
  color: var(--muted);
}
.modal-close-btn:hover { background: #e2e8f0; color: var(--text); }

.badge-active {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}
.badge-inactive {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  background: #f3f4f6;
  color: #6b7280;
  border: 1px solid #d1d5db;
}
.badge-expired {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}
.badge-soon {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}

/* ── Cantieri salvati modal ─────────────────────────────────────────────── */
.cantieri-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 55vh;
  overflow-y: auto;
  margin-top: 0.5rem;
}

.cantiere-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  background: #fafcff;
}

.cantiere-item-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.cantiere-item-info .muted {
  font-size: 0.8rem;
  color: var(--muted);
}

.cantiere-item-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}
