:root {
  --netcom-blue: #0b3a7e;
  --netcom-blue-2: #1f5fbf;
  --netcom-blue-light: #e8f0fb;
  --netcom-gray: #f3f6fb;
  --netcom-sidebar-width: 260px;
  --netcom-topbar-height: 60px;
  --netcom-radius: 12px;
  --netcom-shadow: 0 2px 12px rgba(11, 58, 126, 0.08);
}

/* Base */
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: #1a2b42;
}

.app-body {
  background: var(--netcom-gray);
  overflow-x: hidden;
}

.auth-body {
  background: linear-gradient(135deg, var(--netcom-blue) 0%, var(--netcom-blue-2) 100%);
  min-height: 100vh;
}

/* App shell */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--netcom-sidebar-width);
  background: linear-gradient(180deg, var(--netcom-blue) 0%, #082d63 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1040;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  padding: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand-logo {
  width: 100%;
  background: #fff;
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  line-height: 0;
  box-sizing: border-box;
}

.sidebar-brand-text {
  text-align: center;
}

.netcom-logo {
  display: block;
  object-fit: contain;
}

.netcom-logo--sidebar {
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 36px;
}

.netcom-logo--auth {
  width: 100%;
  max-width: 200px;
  height: auto;
  max-height: 48px;
  margin: 0 auto;
}

.auth-logo-wrap {
  display: flex;
  justify-content: center;
  padding: 0.25rem 0;
}

.sidebar-brand-title {
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1.2;
}

.sidebar-brand-sub {
  font-size: 0.72rem;
  opacity: 0.75;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.5rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.85rem;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  border-radius: 8px;
  margin-bottom: 2px;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.sidebar-link.active {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-weight: 600;
}

.sidebar-link i {
  font-size: 1.1rem;
  width: 1.25rem;
  text-align: center;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0.5;
  font-size: 0.75rem;
}

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

.topbar {
  height: var(--netcom-topbar-height);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 1030;
  box-shadow: var(--netcom-shadow);
}

.topbar-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--netcom-blue);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.app-content {
  flex: 1;
  padding: 1.5rem;
}

.sidebar-toggle {
  color: var(--netcom-blue);
  padding: 0;
}

/* Auth */
.auth-main {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem 1rem;
}

.auth-card-wrapper {
  width: 100%;
  max-width: 420px;
}

.auth-card {
  background: #fff;
  border-radius: var(--netcom-radius);
  padding: 2rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

/* Page header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--netcom-blue);
  margin-bottom: 0.25rem;
}

.page-subtitle {
  color: #64748b;
  margin-bottom: 0;
  font-size: 0.9rem;
}

.page-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Cards */
.card {
  border: none;
  border-radius: var(--netcom-radius);
  box-shadow: var(--netcom-shadow);
}

.card-filter {
  background: #fff;
}

.card-header {
  background: transparent;
  border-bottom: 1px solid #eef2f7;
  padding: 0.85rem 1.25rem;
  font-weight: 600;
}

/* Buttons */
.btn-primary {
  background: var(--netcom-blue-2);
  border-color: var(--netcom-blue-2);
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--netcom-blue);
  border-color: var(--netcom-blue);
}

.btn-netcom {
  background: var(--netcom-blue);
  color: #fff;
  border: none;
}

.btn-netcom:hover {
  background: var(--netcom-blue-2);
  color: #fff;
}

.btn-outline-primary {
  color: var(--netcom-blue-2);
  border-color: var(--netcom-blue-2);
}

.btn-outline-primary:hover {
  background: var(--netcom-blue-2);
  border-color: var(--netcom-blue-2);
}

.bg-netcom {
  background: linear-gradient(90deg, var(--netcom-blue), var(--netcom-blue-2)) !important;
}

.progress-bar.bg-netcom {
  background: var(--netcom-blue-2) !important;
}

/* KPI cards */
.kpi-card {
  border-left: 4px solid #e2e8f0;
}

.kpi-card.kpi-primary { border-left-color: var(--netcom-blue-2); }
.kpi-card.kpi-success { border-left-color: #198754; }
.kpi-card.kpi-warning { border-left-color: #f08c00; }
.kpi-card.kpi-danger { border-left-color: #dc3545; }

.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--netcom-blue-light);
  color: var(--netcom-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.kpi-label {
  font-size: 0.8rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--netcom-blue);
  line-height: 1.2;
}

/* Badges */
.badge-lead-nuovo { background: #6c757d; }
.badge-lead-da_contattare { background: #0dcaf0; color: #000; }
.badge-lead-contattato { background: var(--netcom-blue-2); }
.badge-lead-qualificato { background: #6610f2; }
.badge-lead-opportunita { background: #f08c00; }
.badge-lead-cliente { background: #198754; }
.badge-lead-non_interessato { background: #adb5bd; }
.badge-lead-archiviato { background: #495057; }

.badge-priority-bassa { background: #e9ecef; color: #495057; }
.badge-priority-media { background: var(--netcom-blue-light); color: var(--netcom-blue); }
.badge-priority-alta { background: #fff3cd; color: #856404; }
.badge-priority-strategica,
.badge-priority-urgente { background: #f8d7da; color: #842029; }

.badge-campaign-bozza { background: #e9ecef; color: #495057; }
.badge-campaign-attiva { background: #198754; }
.badge-campaign-pausa { background: #f08c00; }
.badge-campaign-chiusa { background: #6c757d; }
.badge-campaign-archiviata { background: #adb5bd; }

.badge-ai-queued { background: #e9ecef; color: #495057; }
.badge-ai-running { background: var(--netcom-blue-2); }
.badge-ai-done { background: #198754; }
.badge-ai-failed { background: #dc3545; }

.badge-dedupe-da_valutare { background: #fff3cd; color: #856404; }
.badge-dedupe-duplicato { background: #f8d7da; color: #842029; }
.badge-dedupe-non_duplicato { background: #d1e7dd; color: #0f5132; }
.badge-dedupe-unito { background: var(--netcom-blue-light); color: var(--netcom-blue); }

.badge-audit-create { background: #d1e7dd; color: #0f5132; }
.badge-audit-update { background: var(--netcom-blue-light); color: var(--netcom-blue); }
.badge-audit-delete { background: #f8d7da; color: #842029; }

/* Detail view */
.detail-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  margin-bottom: 0.15rem;
}

.detail-value {
  font-weight: 500;
}

.text-pre-wrap {
  white-space: pre-wrap;
}

/* Timeline */
.timeline-item {
  display: flex;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #eef2f7;
}

.timeline-date {
  font-size: 0.8rem;
  color: #64748b;
  min-width: 130px;
}

/* Agenda */
.agenda-day-header {
  font-weight: 600;
  color: var(--netcom-blue);
  padding: 0.5rem 0;
  border-bottom: 2px solid var(--netcom-blue-light);
  margin-bottom: 0.5rem;
}

.agenda-item {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: #fff;
  border-radius: var(--netcom-radius);
  box-shadow: var(--netcom-shadow);
  margin-bottom: 0.5rem;
  border-left: 4px solid #e2e8f0;
}

.agenda-item.priority-alta,
.agenda-item.priority-urgente { border-left-color: #dc3545; }
.agenda-item.priority-media { border-left-color: var(--netcom-blue-2); }
.agenda-item.overdue { background: #fff5f5; }

.agenda-item-time {
  font-weight: 700;
  color: var(--netcom-blue);
  min-width: 48px;
  font-size: 0.9rem;
}

/* Import wizard */
.wizard-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.wizard-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  opacity: 0.4;
}

.wizard-step.active,
.wizard-step.completed {
  opacity: 1;
}

.wizard-step-num {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.wizard-step.active .wizard-step-num {
  background: var(--netcom-blue-2);
  color: #fff;
}

.wizard-step.completed .wizard-step-num {
  background: #198754;
  color: #fff;
}

.wizard-step-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-align: center;
}

.wizard-step-line {
  width: 60px;
  height: 2px;
  background: #e2e8f0;
  margin: 0 0.5rem;
  margin-bottom: 1.25rem;
}

.wizard-step-line.completed {
  background: #198754;
}

.upload-zone {
  border: 2px dashed #cbd5e1;
  border-radius: var(--netcom-radius);
  padding: 2rem;
  text-align: center;
  background: #f8fafc;
  transition: border-color 0.2s, background 0.2s;
}

.upload-zone.dragover {
  border-color: var(--netcom-blue-2);
  background: var(--netcom-blue-light);
}

.upload-zone input[type="file"] {
  max-width: 280px;
  margin: 0.5rem auto 0;
}

/* Dedupe */
.dedupe-entity {
  background: #f8fafc;
  border-radius: 8px;
  padding: 1rem;
}

.dedupe-entity-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 0.25rem;
}

/* Notifications */
.notification-unread {
  border-left: 4px solid var(--netcom-blue-2);
}

.notification-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.notification-icon-task { background: #fff3cd; color: #856404; }
.notification-icon-lead { background: var(--netcom-blue-light); color: var(--netcom-blue); }
.notification-icon-sistema { background: #e9ecef; color: #495057; }

/* Service cards */
.service-code {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--netcom-blue-2);
  font-weight: 600;
  letter-spacing: 0.05em;
}

/* Profile */
.profile-avatar {
  font-size: 4rem;
  color: var(--netcom-blue);
  line-height: 1;
}

/* Audit */
.audit-json {
  font-size: 0.75rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.5rem;
  max-height: 150px;
  overflow: auto;
}

/* Pagination */
.pagination .page-link {
  color: var(--netcom-blue);
}

.pagination .page-item.active .page-link {
  background: var(--netcom-blue-2);
  border-color: var(--netcom-blue-2);
}

/* Tables */
.table thead th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #64748b;
  font-weight: 600;
  border-bottom-width: 1px;
  background: #f8fafc;
}

/* Responsive */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .app-main {
    margin-left: 0;
  }

  .sidebar.open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: -1;
  }
}

@media (max-width: 575.98px) {
  .app-content {
    padding: 1rem;
  }

  .page-header {
    flex-direction: column;
  }

  .kpi-value {
    font-size: 1.4rem;
  }

  .wizard-steps {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .wizard-step-line {
    display: none;
  }
}
