/* ===========================================================
   CGIL DEI COLLI — Gestione Iscritti
   Stile coerente con MiaApp, palette a tema CGIL (rosso/grigio).
   =========================================================== */

:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #1f2937;
  --text-soft: #555;
  --muted: #6b7280;
  --border: #cfd4e0;
  --border-soft: #e5e7eb;

  --brand: #c1272d;          /* rosso CGIL */
  --brand-dark: #9b1f25;
  --brand-soft: #fde7e8;

  --accent: #2563eb;
  --accent-dark: #1d4ed8;

  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --ok-dark: #15803d;
  --warn: #f59e0b;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;

  --shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.08);
  --radius: 10px;
  --radius-sm: 6px;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --card: #1e293b;
  --text: #e5e7eb;
  --text-soft: #cbd5e1;
  --muted: #94a3b8;
  --border: #334155;
  --border-soft: #1e293b;
  --brand-soft: #3f1719;
  --ok-soft: #14301d;
  --warn-soft: #3a2a0a;
  --danger-soft: #3a1414;
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html { font-size: 13px; }

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  min-height: 100vh;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

/* ============== Header / Topbar ============== */
.topbar {
  background: linear-gradient(90deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: white;
  padding: 10px 18px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.3px;
}

.topbar-brand-logo {
  width: 34px; height: 34px;
  background: white;
  color: var(--brand);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 0.85rem;
  letter-spacing: -0.5px;
}

.topbar-brand-sub {
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0.85;
  line-height: 1.1;
}

.topbar-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-left: 8px;
}

.topbar-nav a {
  color: white;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 500;
  transition: background 0.15s;
}

.topbar-nav a:hover { background: rgba(255,255,255,0.15); }
.topbar-nav a.active { background: rgba(255,255,255,0.22); }

.topbar-search {
  margin-left: auto;
  position: relative;
}

.topbar-search input {
  padding: 6px 10px 6px 30px;
  border-radius: 6px;
  border: 0;
  background: rgba(255,255,255,0.18);
  color: white;
  font-size: 0.88rem;
  width: 220px;
}

.topbar-search input::placeholder { color: rgba(255,255,255,0.75); }
.topbar-search input:focus {
  outline: none;
  background: rgba(255,255,255,0.28);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.4);
}

.topbar-search::before {
  content: "🔍";
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  opacity: 0.7;
}

.topbar-search-results {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 320px;
  max-height: 400px;
  overflow: auto;
  background: var(--card);
  color: var(--text);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 200;
}

.topbar-search-results.open { display: block; }

.topbar-search-results .result {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  font-size: 0.88rem;
}

.topbar-search-results .result:last-child { border-bottom: 0; }
.topbar-search-results .result:hover { background: var(--brand-soft); }
.topbar-search-results .result-name { font-weight: 600; }
.topbar-search-results .result-meta { color: var(--muted); font-size: 0.8rem; }
.topbar-search-results .empty { padding: 14px; color: var(--muted); text-align: center; }

.theme-toggle {
  background: rgba(255,255,255,0.18);
  color: white;
  border: 0;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.88rem;
}
.theme-toggle:hover { background: rgba(255,255,255,0.28); }

/* ============== Layout ============== */
.container {
  max-width: 1200px;
  margin: 20px auto;
  padding: 0 16px 40px;
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

h1 {
  margin: 0 0 4px;
  font-size: 1.7rem;
  color: var(--text);
}

.subtitle {
  margin: 0 0 10px;
  color: var(--text-soft);
  font-size: 0.95rem;
}

.card {
  background: var(--card);
  padding: 16px 18px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.card h2 {
  margin: 0 0 6px;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card h3 {
  margin: 16px 0 6px;
  font-size: 1.05rem;
}

.section-description {
  margin: 0 0 12px;
  font-size: 0.88rem;
  color: var(--text-soft);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 18px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

/* ============== KPI cards ============== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--brand);
}

.kpi.kpi-ok { border-left-color: var(--ok); }
.kpi.kpi-danger { border-left-color: var(--danger); }
.kpi.kpi-warn { border-left-color: var(--warn); }
.kpi.kpi-accent { border-left-color: var(--accent); }

.kpi-label {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.kpi-hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 4px;
}

/* ============== Forms ============== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px 14px;
  margin-bottom: 10px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group.full { grid-column: 1 / -1; }

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

.form-group input,
.form-group select,
.form-group textarea {
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
}

.form-group textarea { min-height: 80px; resize: vertical; }

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.form-group .hint {
  font-size: 0.78rem;
  color: var(--muted);
}

.input-error {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.25) !important;
}

/* ============== Buttons ============== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: var(--border-soft); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--brand);
  color: white;
  border-color: var(--brand-dark);
}
.btn-primary:hover { background: var(--brand-dark); }

.btn-accent {
  background: var(--accent);
  color: white;
  border-color: var(--accent-dark);
}
.btn-accent:hover { background: var(--accent-dark); }

.btn-ok {
  background: var(--ok);
  color: white;
  border-color: var(--ok-dark);
}
.btn-ok:hover { background: var(--ok-dark); }

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.btn-danger:hover { background: #991b1b; }

.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover { background: var(--border-soft); }

.btn-sm { padding: 4px 10px; font-size: 0.82rem; }
.btn-lg { padding: 10px 18px; font-size: 1rem; }

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}

.actions-row .spacer { flex: 1; }

/* Barra azioni massive (comparsa quando ci sono selezioni in lista) */
.bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
  padding: 10px 14px;
  background: var(--brand-soft);
  border: 1px solid var(--brand);
  border-radius: var(--radius-sm);
  color: var(--brand-dark);
}
.bulk-actions .spacer { flex: 1; }
.bulk-actions strong { color: var(--brand-dark); }
[data-theme="dark"] .bulk-actions { color: #fecaca; }
[data-theme="dark"] .bulk-actions strong { color: #fecaca; }

/* ============== Tables ============== */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  background: var(--card);
}

.data-table th,
.data-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
}

.data-table th {
  background: var(--border-soft);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-soft);
  position: sticky;
  top: 0;
}

.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:hover { background: var(--brand-soft); }

/* Riga con avviso (es. senza presidio assegnato in anteprima import) */
.data-table tr.row-warn {
  background: var(--warn-soft);
}
.data-table tr.row-warn:hover { background: var(--warn-soft); filter: brightness(0.98); }
.data-table tr.row-warn td { border-bottom-color: var(--warn); }

/* Input/select inline all'interno della tabella (es. preview import) */
.preview-input,
.preview-presidio {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 4px 2px;
}
.preview-input:focus,
.preview-presidio:focus {
  outline: 2px solid var(--brand);
  background: var(--card);
  border-radius: 4px;
}
.preview-presidio {
  appearance: menulist;
  padding: 2px 4px;
}

.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--text); }
.data-table th.sortable::after {
  content: "↕";
  margin-left: 4px;
  opacity: 0.35;
}
.data-table th.sortable.asc::after { content: "▲"; opacity: 1; }
.data-table th.sortable.desc::after { content: "▼"; opacity: 1; }

.empty-state {
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
}

/* ============== Badges & tags ============== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--border-soft);
  color: var(--text);
}
.badge-ok { background: var(--ok-soft); color: var(--ok-dark); }
.badge-danger { background: var(--danger-soft); color: #991b1b; }
.badge-warn { background: var(--warn-soft); color: #92400e; }
.badge-accent { background: #dbeafe; color: var(--accent-dark); }
.badge-brand { background: var(--brand-soft); color: var(--brand-dark); }

[data-theme="dark"] .badge-accent { background: #1e3a8a; color: #bfdbfe; }
[data-theme="dark"] .badge-danger { color: #fecaca; }

.tag-presidio {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--border-soft);
  color: var(--text);
}

.tag-presidio::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--presidio-color, var(--muted));
}

/* ============== Movimenti (nuovi/usciti) ============== */
.movimenti-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 18px;
}

.movimento-col {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.movimento-col.nuovi { border-top: 4px solid var(--ok); }
.movimento-col.usciti { border-top: 4px solid var(--danger); }

.movimento-col h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
}

.movimento-col .count {
  background: var(--border-soft);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-soft);
}

.movimento-col.nuovi .count { background: var(--ok-soft); color: var(--ok-dark); }
.movimento-col.usciti .count { background: var(--danger-soft); color: #991b1b; }

.movimento-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.movimento-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border-left: 3px solid transparent;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s, transform 0.05s;
}

.movimento-item:hover { background: var(--border-soft); transform: translateX(2px); }

.movimento-col.nuovi .movimento-item { border-left-color: var(--ok); }
.movimento-col.usciti .movimento-item { border-left-color: var(--danger); }

.movimento-icon {
  font-size: 1.2rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: bold;
  flex-shrink: 0;
}
.movimento-col.nuovi .movimento-icon { background: var(--ok-soft); color: var(--ok-dark); }
.movimento-col.usciti .movimento-icon { background: var(--danger-soft); color: #991b1b; }

.movimento-body { flex: 1; min-width: 0; }
.movimento-name { font-weight: 600; font-size: 0.95rem; }
.movimento-meta { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }

/* ============== Feed (ultime variazioni) ============== */
.feed {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.feed-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  text-decoration: none;
  color: inherit;
}
.feed-item:hover { background: var(--border-soft); }

.feed-dot {
  width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0;
}
.feed-dot.ok { background: var(--ok); }
.feed-dot.danger { background: var(--danger); }

.feed-text { flex: 1; }
.feed-date { color: var(--muted); font-size: 0.78rem; }

/* ============== Toast / notifications ============== */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--text);
  color: white;
  padding: 10px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  min-width: 200px;
  max-width: 360px;
  animation: toast-in 0.2s ease-out;
}

.toast.ok { background: var(--ok-dark); }
.toast.danger { background: var(--danger); }
.toast.warn { background: #b45309; }

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

/* ============== Modal ============== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-lg);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
}

.modal h2 { margin-top: 0; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

/* ============== Timeline ============== */
.timeline {
  list-style: none;
  padding: 0;
  margin: 0;
  position: relative;
  padding-left: 22px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding: 6px 0 14px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -19px;
  top: 10px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--muted);
  border: 2px solid var(--card);
}

.timeline-item.ok::before { background: var(--ok); }
.timeline-item.danger::before { background: var(--danger); }

.timeline-title { font-weight: 600; font-size: 0.92rem; }
.timeline-meta { font-size: 0.8rem; color: var(--muted); }

/* ============== Documenti ============== */
.docs-categories {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.doc-category {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--card);
}

.doc-category-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.doc-category-title { font-weight: 600; font-size: 0.92rem; }

.doc-list {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.doc-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  padding: 4px 6px;
  border-radius: 4px;
}
.doc-item:hover { background: var(--border-soft); }
.doc-item a { color: var(--accent); text-decoration: none; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 18px;
  text-align: center;
  color: var(--muted);
  transition: background 0.15s, border-color 0.15s;
  cursor: pointer;
}
.dropzone:hover, .dropzone.drag-over {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-dark);
}

/* ============== Utility ============== */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: 6px; }
.gap { gap: 12px; }
.mt-sm { margin-top: 6px; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
.text-muted { color: var(--muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-sm { font-size: 0.85rem; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }

.stat-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--border-soft);
  overflow: hidden;
  margin-top: 4px;
}
.stat-bar-fill {
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
}

/* ============== Auth / Login ============== */
.auth-body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(193, 39, 45, 0.18), transparent 60%),
    radial-gradient(900px 500px at 120% 110%, rgba(155, 31, 37, 0.22), transparent 60%),
    linear-gradient(135deg, #1a0608 0%, #2b0a0e 50%, #10121a 100%);
  color: #f5f5f7;
  font-family: inherit;
}
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  box-sizing: border-box;
}
.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--card);
  color: var(--text);
  border-radius: 18px;
  padding: 32px 28px 24px;
  box-shadow:
    0 20px 60px -20px rgba(0, 0, 0, 0.55),
    0 8px 20px -12px rgba(193, 39, 45, 0.4);
  border: 1px solid var(--border-soft);
  position: relative;
  overflow: hidden;
}
.auth-card::before {
  content: "";
  position: absolute; inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--brand), var(--brand-dark));
}
.auth-brand {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 20px;
}
.auth-brand-logo {
  width: 56px; height: 56px;
  display: grid; place-items: center;
  background: var(--brand);
  color: white;
  font-weight: 800; font-size: 0.95rem; letter-spacing: 0.5px;
  border-radius: 12px;
  box-shadow: 0 4px 14px -4px rgba(193, 39, 45, 0.55);
}
.auth-brand h1 {
  margin: 0; font-size: 1.25rem; line-height: 1.2;
}
.auth-brand-sub {
  margin: 2px 0 0; color: var(--text-soft); font-size: 0.82rem;
}
.auth-locked-icon {
  text-align: center;
  font-size: 2.2rem;
  margin: 6px 0 14px;
  opacity: 0.85;
}
.auth-title {
  font-size: 1.15rem;
  margin: 0 0 6px;
}
.auth-hint {
  margin: 0 0 18px;
  color: var(--text-soft);
  font-size: 0.88rem;
  line-height: 1.45;
}
.auth-form { display: block; }
.auth-form .form-group {
  display: block;
  margin-bottom: 14px;
}
.auth-form .form-group > span,
.auth-form .form-group > label > span {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-soft);
}
.auth-form input[type="text"],
.auth-form input[type="password"],
.auth-form input[type="email"] {
  width: 100%;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-form input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(193, 39, 45, 0.18);
}
.auth-input-wrap { position: relative; }
.auth-input-wrap input { padding-right: 40px; }
.auth-eye {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--text-soft);
}
.auth-eye:hover { background: var(--border-soft); }
.auth-strength {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--text-soft);
  min-height: 1em;
}
.auth-strength.ok { color: #16a34a; }
.auth-strength.warn { color: #d97706; }
.auth-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-soft);
  margin: 6px 0 16px;
  cursor: pointer;
}
.auth-checkbox input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--brand);
  cursor: pointer;
}
.btn-block {
  width: 100%;
  justify-content: center;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-weight: 600;
}
.auth-links {
  display: flex;
  justify-content: center;
  margin-top: 14px;
}
.link-btn {
  background: transparent;
  border: none;
  color: var(--brand);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover { background: var(--brand-soft); }
.auth-footnote {
  margin-top: 14px;
  padding: 10px 12px;
  background: var(--warn-soft, #fef3c7);
  border-left: 3px solid var(--warn, #d97706);
  border-radius: 6px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text);
}
.auth-microcopy {
  margin-top: 20px;
  font-size: 0.75rem;
  color: var(--text-soft);
  text-align: center;
  line-height: 1.45;
}
.recovery-box {
  font-family: ui-monospace, "SF Mono", "Monaco", "Cascadia Code", monospace;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 3px;
  padding: 18px 14px;
  text-align: center;
  background: var(--brand-soft);
  color: var(--brand-dark);
  border: 2px dashed var(--brand);
  border-radius: 10px;
  margin: 14px 0;
  user-select: all;
  word-break: break-all;
}
[data-theme="dark"] .recovery-box { color: #fecaca; }

/* ============== User menu (topbar) ============== */
.user-menu {
  position: relative;
  margin-left: 8px;
}
.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 5px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  color: white;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.15s;
}
.user-menu-btn:hover { background: rgba(255, 255, 255, 0.2); }
.user-avatar {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: white;
  color: var(--brand);
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.user-name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-caret { font-size: 0.65rem; opacity: 0.8; }
.user-menu-drop {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 36px -8px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 200;
  overflow: hidden;
}
.user-menu.open .user-menu-drop {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.user-menu-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--brand-soft);
}
.user-menu-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-menu-sub {
  font-size: 0.75rem;
  color: var(--text-soft);
  margin-top: 2px;
}
.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  text-align: left;
  font-size: 0.88rem;
  font-family: inherit;
}
.user-menu-item:hover { background: var(--border-soft); }
.user-menu-item.active { background: var(--brand-soft); color: var(--brand-dark); }
.user-menu-item-danger { color: var(--danger); }
.user-menu-item-danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ============== Sigle sindacali: chip multi-valore (personale.html) ============== */
.sigla-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--border-soft);
  color: var(--text);
  margin: 2px 4px 2px 0;
  border: 1px solid transparent;
}
.sigla-chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--presidio-color, var(--muted));
  margin-right: 2px;
}
.sigla-chip-label { line-height: 1; }
.sigla-chip-x {
  appearance: none;
  border: none;
  background: transparent;
  color: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0 4px;
  margin-left: 2px;
  cursor: pointer;
  border-radius: 50%;
  opacity: 0.55;
}
.sigla-chip-x:hover { opacity: 1; background: rgba(0,0,0,0.08); }
[data-theme="dark"] .sigla-chip-x:hover { background: rgba(255,255,255,0.15); }
.sigla-chip-lock {
  font-size: 0.7rem;
  opacity: 0.6;
  margin-left: 2px;
}
.sigle-cell { min-width: 220px; }
.sigla-add select {
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--card);
  border: 1px dashed var(--border);
  color: var(--muted);
  cursor: pointer;
}
.sigla-add select:hover { color: var(--text); border-color: var(--text); }

.print-only { display: none; }

/* ============== Print ============== */
@media print {
  .topbar, .no-print { display: none !important; }
  .actions-row .btn, .actions-row button { display: none !important; }
  body { background: white; color: #000; }
  .card { box-shadow: none; border: 1px solid #ccc; page-break-inside: avoid; }
  .container { max-width: none; margin: 0; padding: 0; }
  .page-header .actions-row { display: none !important; }
  .print-only { display: block !important; }
  #print-header { margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid #999; }
  #print-header h2 { font-size: 16pt; }
  .data-table { font-size: 9pt; border-collapse: collapse; width: 100%; }
  .data-table th, .data-table td {
    border: 1px solid #999;
    padding: 4px 6px;
    text-align: left;
    vertical-align: top;
  }
  .data-table thead th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .table-wrapper { overflow: visible !important; }
  /* Chips in stampa: come bordi, senza pallino di colore */
  .sigla-chip { background: transparent !important; border: 1px solid #666; padding: 1px 6px; }
  .sigla-chip::before { display: none; }
  .tag-presidio { background: transparent !important; border: 1px solid #666; }
  .tag-presidio::before { display: none; }
  .badge { border: 1px solid #666; background: transparent !important; }
  /* Nascondi le sezioni di utility non pertinenti alla stampa */
  #card-elenco { box-shadow: none; border: none; padding: 0; }
  /* KPI/ripartizione: stampale leggibili ma senza fondini colorati */
  .kpi { box-shadow: none; border: 1px solid #bbb; background: white !important; }
  /* Il card "Come funziona" e la ripartizione extra NON stampati (usare .no-print sull'HTML per questo) */
}

/* ============== Responsive ============== */
@media (max-width: 640px) {
  .topbar-search input { width: 140px; }
  h1 { font-size: 1.35rem; }
  .kpi-value { font-size: 1.5rem; }
  .user-name { display: none; }
  .auth-card { padding: 24px 20px 20px; }
}
