:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --sidebar-width: 260px;
  --radius: 12px;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.05);
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow-x: hidden;
}

/* APP LAYOUT */
.app {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #1e1b4b 0%, #312e81 100%);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.25rem;
  font-weight: 700;
}

.logo i {
  font-size: 1.5rem;
  color: #a5b4fc;
}

.close-sidebar {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  border-radius: 10px;
  margin-bottom: 4px;
  transition: all 0.2s;
  font-weight: 500;
}

.nav-item:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}

.nav-item.active {
  background: rgba(255,255,255,0.15);
  color: white;
}

.nav-item i {
  width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #818cf8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.user-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.user-role {
  font-size: 0.75rem;
  opacity: 0.7;
}

/* MAIN */
.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: white;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--text);
  cursor: pointer;
}

.topbar-title {
  font-size: 1.25rem;
  font-weight: 700;
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.month-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}

.month-selector button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
}

.month-selector button:hover {
  color: var(--primary);
}

.search-box {
  position: relative;
}

.search-box i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.search-box input {
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 220px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-box input:focus {
  border-color: var(--primary);
}

/* CONTENT */
.content {
  padding: 24px;
  flex: 1;
}

.page {
  display: none;
}

.page.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

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

/* STATS */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  gap: 16px;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}

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

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: white;
  flex-shrink: 0;
}

.stat-icon.blue { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.stat-icon.green { background: linear-gradient(135deg, #34d399, #10b981); }
.stat-icon.orange { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
.stat-icon.purple { background: linear-gradient(135deg, #a78bfa, #8b5cf6); }

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-change {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.stat-change.positive {
  color: var(--success);
}

/* CARDS */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-header h3 i {
  color: var(--primary);
}

.card-body {
  padding: 16px 20px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.mt-15 { margin-top: 15px; }
.mt-20 { margin-top: 20px; }

/* TOP LIST */
.top-item, .alert-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.top-item:last-child, .alert-item:last-child {
  border-bottom: none;
}

.rank {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.rank.gold { background: #fef3c7; color: #d97706; }
.rank.silver { background: #f1f5f9; color: #64748b; }
.rank.bronze { background: #ffedd5; color: #c2410c; }

.person-info {
  flex: 1;
}

.person-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.person-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.person-points {
  font-weight: 700;
  color: var(--primary);
}

.progress-mini {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  margin-top: 4px;
  overflow: hidden;
}

.progress-mini-fill {
  height: 100%;
  border-radius: 3px;
}

.progress-mini-fill.green { background: var(--success); }
.progress-mini-fill.orange { background: var(--warning); }
.progress-mini-fill.red { background: var(--danger); }

/* MEETING STATS */
.meeting-stats {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.meeting-stat {
  display: grid;
  grid-template-columns: 140px 1fr 100px;
  align-items: center;
  gap: 12px;
}

.meeting-label {
  font-weight: 500;
  font-size: 0.9rem;
}

.progress-bar {
  height: 10px;
  background: var(--bg);
  border-radius: 5px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.5s ease;
}

.progress-fill.green { background: var(--success); }
.progress-fill.blue { background: var(--info); }

.meeting-value {
  text-align: right;
  font-weight: 600;
  font-size: 0.9rem;
}

/* ALBERO */
.albero-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.filters select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: white;
  outline: none;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  cursor: pointer;
}

.albero-container {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  overflow-x: auto;
  min-height: 400px;
}

/* TREE NODE */
.tree-node {
  margin-left: 0;
}

.tree-node .tree-node {
  margin-left: 28px;
  border-left: 2px solid #e2e8f0;
  padding-left: 16px;
}

.node-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  max-width: 520px;
}

.node-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.12);
  transform: translateX(4px);
}

.node-card .toggle {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.2s;
}

.node-card .toggle.open {
  transform: rotate(90deg);
}

.node-avatar {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: white;
  flex-shrink: 0;
}

.node-info {
  flex: 1;
  min-width: 0;
}

.node-name {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node-meta {
  display: flex;
  gap: 8px;
  margin-top: 3px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
}

.node-stats {
  display: flex;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.node-stats strong {
  color: var(--text);
  font-weight: 700;
}

.node-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.node-status.green { background: var(--success); }
.node-status.orange { background: var(--warning); }
.node-status.red { background: var(--danger); }

.meeting-icons {
  display: flex;
  gap: 6px;
}

.meeting-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
}

.meeting-icon.yes {
  background: #d1fae5;
  color: #059669;
}

.meeting-icon.no {
  background: #f1f5f9;
  color: #94a3b8;
}

.children {
  display: none;
}

.children.open {
  display: block;
}

/* PERSONA PAGE */
.back-btn {
  margin-bottom: 16px;
}

.persona-header {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.persona-avatar-lg {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
}

.persona-title h2 {
  font-size: 1.5rem;
  margin-bottom: 6px;
}

.persona-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tabs {
  display: flex;
  gap: 4px;
  background: white;
  padding: 6px;
  border-radius: 10px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  width: fit-content;
}

.tab {
  padding: 8px 20px;
  border: none;
  background: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
}

.tab.active {
  background: var(--primary);
  color: white;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* TABLES */
.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th {
  text-align: left;
  padding: 12px 14px;
  background: var(--bg);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

.data-table.editable input {
  width: 80px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
}

.data-table.editable input:focus {
  outline: none;
  border-color: var(--primary);
}

/* FORMS */
.form-card {
  background: white;
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  max-width: 640px;
}

.form-card.large {
  max-width: 720px;
}

.form-card h3 {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-card h3 i {
  color: var(--primary);
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
}

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

.switch-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
}

.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #cbd5e1;
  border-radius: 26px;
  transition: 0.3s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}

.switch input:checked + .slider {
  background: var(--success);
}

.switch input:checked + .slider:before {
  transform: translateX(22px);
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-ghost {
  background: none;
  color: var(--text-muted);
  padding: 8px 12px;
}

.btn-ghost:hover {
  color: var(--primary);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* CARRIERA */
.carriera-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.ruolo-item, .formazione-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 10px;
  background: var(--bg);
  margin-bottom: 8px;
}

.ruolo-color {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  flex-shrink: 0;
}

.ruolo-name {
  flex: 1;
  font-weight: 600;
}

/* ANAGRAFICA */
.anagrafica-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  background: white;
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.anagrafica-item label {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 2px;
}

.anagrafica-item div {
  font-weight: 600;
}

.placeholder-text {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
  line-height: 1.7;
}

/* TOAST */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: white;
  padding: 14px 24px;
  border-radius: 10px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1000;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* RESPONSIVE */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dashboard-grid, .carriera-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .close-sidebar {
    display: block;
  }
  .main {
    margin-left: 0;
  }
  .menu-toggle {
    display: block;
  }
  .search-box input {
    width: 140px;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .topbar-actions {
    gap: 8px;
  }
  .month-selector span {
    font-size: 0.8rem;
  }
  .anagrafica-grid {
    grid-template-columns: 1fr;
  }
  .meeting-stat {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .meeting-value {
    text-align: left;
  }
  .node-card {
    max-width: 100%;
  }
}

/* New badges */
.badge-ft {
  display: inline-block;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}
.badge-pt {
  display: inline-block;
  background: #f1f5f9;
  color: #64748b;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}
.badge-inattivo {
  display: inline-block;
  background: #fee2e2;
  color: #b91c1c;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
}
.node-card.inactive {
  opacity: 0.55;
  background: #f8fafc;
}
.meeting-icon.eligible {
  background: #fef3c7;
  color: #d97706;
}


/* ========== STRUTTOGRAMMA / ORG CHART ========== */
.albero-container {
  background: #f8fafc;
  padding: 32px 20px;
  overflow: auto;
}
.tree-node {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.tree-node > .node-card {
  position: relative;
}
/* Linea verticale di collegamento */
.tree-node .children {
  position: relative;
  margin-left: 32px;
  padding-left: 24px;
  border-left: 2px solid #cbd5e1;
}
.tree-node .children::before {
  content: "";
  position: absolute;
  top: 0;
  left: -2px;
  width: 24px;
  height: 28px;
  border-bottom: 2px solid #cbd5e1;
}
.node-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  min-width: 280px;
  max-width: 340px;
}
.node-card:hover {
  box-shadow: 0 6px 16px rgba(0,0,0,0.1);
}


/* ========== ORG CHART / TREE CHART TOP-DOWN ========== */
.org-chart {
  display: flex;
  justify-content: center;
  padding: 20px 10px 40px;
  overflow-x: auto;
  min-height: 400px;
}
.org-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  padding: 0 8px;
}
.org-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 14px;
  min-width: 150px;
  max-width: 180px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0,0,0,0.07);
  transition: all 0.2s;
  position: relative;
  z-index: 2;
}
.org-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
  border-color: #94a3b8;
}
.org-card.inactive {
  opacity: 0.5;
  background: #f8fafc;
}
.org-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  margin: 0 auto 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.8rem;
}
.org-name {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.org-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  justify-content: center;
  margin-bottom: 6px;
}
.org-stats {
  display: flex;
  justify-content: center;
  gap: 10px;
  font-size: 0.75rem;
  color: #64748b;
}
.org-status {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.org-status.green { background: #10b981; }
.org-status.orange { background: #f59e0b; }
.org-status.red { background: #ef4444; }

/* Children connector */
.org-children {
  display: flex;
  justify-content: center;
  padding-top: 30px;
  position: relative;
}
/* Vertical line from parent to children bar */
.org-children::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 30px;
  background: #cbd5e1;
  transform: translateX(-50%);
}
/* Horizontal bar connecting siblings */
.org-node:not(:only-child) > .org-children::after {
  content: none;
}
.org-children > .org-node {
  position: relative;
  padding-top: 0;
}
/* Vertical line up to horizontal bar for each child */
.org-children > .org-node::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 0;
  background: #cbd5e1;
}
/* Horizontal connector between children */
.org-children > .org-node:not(:first-child):not(:last-child)::after,
.org-children > .org-node:first-child:not(:only-child)::after,
.org-children > .org-node:last-child:not(:only-child)::after {
  content: "";
  position: absolute;
  top: 0;
  height: 2px;
  background: #cbd5e1;
}
.org-children > .org-node:first-child:not(:only-child)::after {
  left: 50%;
  right: 0;
}
.org-children > .org-node:last-child:not(:only-child)::after {
  left: 0;
  right: 50%;
}
.org-children > .org-node:not(:first-child):not(:last-child)::after {
  left: 0;
  right: 0;
}


/* Inattivi più evidenti in grigio */
.org-card.inactive {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  opacity: 0.85;
  filter: grayscale(0.6);
}
.org-card.inactive .org-name {
  color: #64748b;
}
.org-card.inactive .org-stats {
  color: #94a3b8;
}


.btn-danger {
  background: #ef4444;
  color: white;
}
.btn-danger:hover {
  background: #dc2626;
}


.org-diff {
  font-size: 0.7rem;
  font-weight: 700;
  color: #b45309;
  background: #fef3c7;
  padding: 2px 8px;
  border-radius: 6px;
  margin-bottom: 4px;
  white-space: nowrap;
}
.org-diff.zero {
  color: #94a3b8;
  background: #f1f5f9;
}


/* ========== LOGIN ========== */
.login-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(145deg, #1e1b4b 0%, #312e81 50%, #1e3a5f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}
.login-card {
  background: white;
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.3);
}
.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo-icon {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: white;
  font-size: 1.6rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  letter-spacing: -1px;
}
.login-logo h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: #1e1b4b;
  margin: 0 0 4px;
}
.login-subtitle {
  color: #64748b;
  font-size: 0.9rem;
  margin: 0;
}
.login-form .form-group {
  margin-bottom: 16px;
}
.login-btn {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  margin-top: 8px;
}
.login-error {
  background: #fef2f2;
  color: #dc2626;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 12px;
  font-weight: 500;
}
.btn-link {
  background: none;
  border: none;
  color: #4f46e5;
  font-size: 0.85rem;
  cursor: pointer;
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 16px;
  padding: 8px;
}
.btn-link:hover { text-decoration: underline; }
.forgot-box {
  margin-top: 8px;
}
.forgot-box p {
  font-size: 0.85rem;
  color: #64748b;
  margin-bottom: 12px;
  line-height: 1.5;
}
.forgot-box input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.95rem;
}

