/* =========================================================
   Extraweb Design System — Minfluencer webapp
   Adattato da extraweb-design-system/colors_and_type.css
   ========================================================= */

@font-face { font-family: 'Poppins'; font-weight: 400; src: url('/static/fonts/Poppins-Regular.ttf') format('truetype'); }
@font-face { font-family: 'Poppins'; font-weight: 500; src: url('/static/fonts/Poppins-Medium.ttf') format('truetype'); }
@font-face { font-family: 'Poppins'; font-weight: 600; src: url('/static/fonts/Poppins-SemiBold.ttf') format('truetype'); }
@font-face { font-family: 'Poppins'; font-weight: 700; src: url('/static/fonts/Poppins-Bold.ttf') format('truetype'); }

:root {
  --ew-magenta: #e4007d;
  --ew-magenta-hot: #ff0080;
  --ew-magenta-ink: #b8006a;
  --ew-magenta-soft: #ffe3f1;
  --ew-violet: #230159;
  --ew-violet-deep: #180040;
  --ew-violet-soft: #f4f1fa;
  --ew-white: #ffffff;
  --ew-off: #fafafa;
  --ew-gray-100: #f2f2f4;
  --ew-gray-200: #e5e5ea;
  --ew-gray-300: #cfcfd6;
  --ew-gray-500: #8a8a94;
  --ew-gray-700: #4a4a55;

  --lv-eccellente: #2E7D32;
  --lv-buono: #66BB6A;
  --lv-medio: #FBC02D;
  --lv-scarso: #FB8C00;
  --lv-critico: #C62828;
  --lv-calc: #607D8B;
  --lv-neutro: #9E9E9E;

  --font-sans: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--ew-violet);
  background: var(--ew-off);
}

h1 { font-size: 28px; font-weight: 600; color: var(--ew-violet); margin: 0 0 16px; }
h2 { font-size: 22px; font-weight: 600; color: var(--ew-violet); margin: 0 0 12px; }
h3 { font-size: 18px; font-weight: 600; color: var(--ew-violet); margin: 0 0 8px; }
h4 { font-size: 16px; font-weight: 600; color: var(--ew-violet); margin: 0; }
p { margin: 0 0 12px; color: var(--ew-gray-700); }
a { color: var(--ew-magenta); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============= Brand utilities ============= */
.ew-label {
  font-size: 11px; font-weight: 600;
  color: var(--ew-magenta);
  text-transform: uppercase;
  letter-spacing: 0.16em;
}
.ew-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 22px;
  font-family: inherit; font-weight: 600; font-size: 13px;
  letter-spacing: 0.02em;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
}
.ew-btn--primary { background: var(--ew-magenta); color: #fff; }
.ew-btn--primary:hover { background: var(--ew-magenta-hot); }
.ew-btn--dark { background: var(--ew-violet); color: #fff; }
.ew-btn--dark:hover { background: var(--ew-violet-deep); }
.ew-btn--ghost { background: transparent; color: var(--ew-violet); border-color: var(--ew-violet); }
.ew-btn--ghost:hover { background: var(--ew-violet); color: #fff; }

/* ============= LOGIN ============= */
.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--ew-violet) 0%, var(--ew-violet-deep) 100%);
}
.login-card {
  background: #fff;
  padding: 40px;
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(0,0,0,.3);
  width: 380px;
}
.login-card .logo {
  width: 56px; height: 56px;
  background: var(--ew-magenta); color: #fff;
  border-radius: 12px;
  font-weight: 700; font-size: 28px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
}
.login-card h1 { margin: 0 0 4px; }
.login-card form {
  display: flex; flex-direction: column; gap: 12px;
  margin-top: 20px;
}
.login-card input {
  padding: 12px 14px;
  border: 1px solid var(--ew-gray-200);
  border-radius: 8px;
  font-family: inherit; font-size: 14px;
}
.login-card input:focus { outline: none; border-color: var(--ew-magenta); }
.login-card .error {
  color: #fff; background: var(--lv-critico);
  padding: 10px 14px; border-radius: 6px;
  margin-bottom: 8px; font-size: 13px;
}
.login-card button { margin-top: 4px; }

/* ============= APP LAYOUT (sidebar + topbar) ============= */
.app {
  display: grid;
  grid-template-columns: 72px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
}

/* ============= SIDEBAR ============= */
.sidebar {
  grid-area: sidebar;
  background: var(--ew-violet);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 4px;
  /* Sticky: resta visibile mentre si scrolla la pagina */
  position: sticky;
  top: 0;
  height: 100vh;
  align-self: start;
}
.sidebar .logo {
  width: 40px; height: 40px;
  background: var(--ew-magenta);
  border-radius: 8px;
  margin-bottom: 24px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: 20px;
}
.sidebar .nav-vertical {
  display: flex; flex-direction: column; gap: 6px; width: 100%;
  align-items: center;
}
.sidebar a {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  position: relative;
  transition: background .15s, color .15s;
}
.sidebar a:hover { background: rgba(255,255,255,0.06); color: #fff; text-decoration: none; }
.sidebar a.active { background: var(--ew-magenta); color: #fff; }
.sidebar a .badge {
  position: absolute; top: 4px; right: 4px;
  background: var(--ew-magenta-hot); color: #fff;
  font-size: 10px; font-weight: 600;
  border-radius: 999px; padding: 1px 5px;
  line-height: 1;
}
.sidebar .spacer { flex: 1; }
.sidebar-logout { margin: 0; }
.user-avatar {
  width: 40px; height: 40px; border-radius: 999px;
  background: var(--ew-magenta-hot); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
  border: 0; cursor: pointer; font-family: inherit;
  transition: filter .15s;
}
.user-avatar:hover { filter: brightness(1.1); }

/* ============= TOPBAR ============= */
.topbar {
  grid-area: topbar;
  background: #fff;
  border-bottom: 1px solid var(--ew-gray-200);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 24px;
  /* Sticky: resta visibile mentre si scrolla la pagina */
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .topbar-titles { display: flex; flex-direction: column; }
.topbar .crumb {
  font-size: 11px; color: var(--ew-gray-500); font-weight: 500;
  letter-spacing: 0.04em; text-transform: uppercase;
  line-height: 1;
}
.topbar .topbar-title {
  font-size: 16px; font-weight: 600;
  color: var(--ew-violet);
  margin: 2px 0 0;
}
.topbar .meta { margin-left: auto; font-size: 13px; color: var(--ew-gray-500); }
.topbar .meta strong { color: var(--ew-violet); font-weight: 600; }

/* ============= MAIN AREA ============= */
.main {
  grid-area: main;
  background: var(--ew-off);
  width: 100%;
  max-width: 1800px;
  justify-self: center;
}
/* Per la tabella profili: full-width su monitor grandi (desktop dense view).
   Mantiene leggibilità nelle pagine semplici (upload, discoveries) che hanno
   .upload-page / .discoveries-page con padding proprio. */
body.profiles-fullwidth .main {
  max-width: none;
}
body.profiles-fullwidth .filter-bar,
body.profiles-fullwidth .profiles-main {
  max-width: none;
}

/* Layout scroll-in-table: solo la table-wrap scrolla, filter bar + chip
   + pagination restano sempre visibili. */
html, body.profiles-fullwidth {
  height: 100vh;
  overflow: hidden;
}
body.profiles-fullwidth .app {
  height: 100vh;
  overflow: hidden;
}
body.profiles-fullwidth .main.profiles-main {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
body.profiles-fullwidth .list-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
body.profiles-fullwidth .quick-filter-chips,
body.profiles-fullwidth .filter-bar {
  flex: 0 0 auto;
}
body.profiles-fullwidth #profiles-table {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
body.profiles-fullwidth #profiles-table .table-wrap {
  flex: 1;
  overflow: auto;
  min-height: 0;
}
body.profiles-fullwidth #profiles-table .pagination {
  flex: 0 0 auto;
  background: #fff;
  border-top: 1px solid var(--ew-gray-200, #e5e5e5);
}
/* Filter bar non più sticky: è già fuori dallo scroll */
body.profiles-fullwidth .filter-bar { position: static; top: auto; }
.profiles-table .cell-meta-mini {
  font-size: 13px;
  color: var(--ew-gray-600, #6b7280);
  display: block;
  line-height: 1.35;
}
.profiles-table .pill-mini {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  margin-right: 3px;
  background: #f0f0f0;
  color: #444;
  text-transform: uppercase;
}
.profiles-table .pill-mini.settore { background: #e3f2fd; color: #1565c0; }
.profiles-table .pill-mini.tier { background: #f3e5f5; color: #6a1b9a; }
.profiles-table .pill-mini.qualita { background: #e8f5e9; color: #2e7d32; }
.profiles-table .pill-mini.use_case { background: #fff3e0; color: #e65100; }
.profiles-table .pill-mini.cliente { background: #fce4ec; color: #ad1457; }
.profiles-table .pill-mini.cross_platform { background: #ede7f6; color: #4527a0; }
.profiles-table .brand-cell { font-size: 14px; line-height: 1.4; }

/* Popover hover per celle con contenuto troncato (Tag/Brand/Cita/Hashtag/Bio) */
.has-popover {
  position: relative;
  cursor: help;
}
.has-popover::after {
  content: "ⓘ";
  font-size: 10px;
  opacity: 0;
  color: var(--ew-magenta, #c2185b);
  margin-left: 4px;
  transition: opacity .12s;
  vertical-align: super;
}
.has-popover:hover::after { opacity: 0.6; }
.has-popover .popover-content {
  /* position: fixed per scappare dal clipping di .table-wrap overflow:auto.
     Le coordinate top/left sono settate da JS al mouseover (vedi index.html). */
  position: fixed;
  display: none;
  z-index: 9999;
  background: #fff;
  border: 1px solid var(--ew-gray-200, #e5e5e5);
  border-radius: 6px;
  padding: 10px 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  min-width: 240px;
  max-width: 400px;
  white-space: normal;
  font-size: 13px;
  color: #333;
  line-height: 1.45;
  cursor: default;
}
.has-popover:hover .popover-content { display: block; }
.popover-content h5 {
  margin: 0 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ew-gray-600, #6b7280);
  font-weight: 700;
}
.popover-content h5:not(:first-child) { margin-top: 10px; }
.popover-content .pop-item {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px dotted #eee;
  font-size: 13px;
}
.popover-content .pop-item:last-child { border-bottom: none; }
.popover-content .pop-count {
  color: var(--ew-magenta, #c2185b);
  font-weight: 700;
  font-size: 12px;
  margin-left: 8px;
}
.popover-content .pop-bio {
  font-size: 13px;
  color: #444;
  white-space: pre-wrap;
  word-break: break-word;
}
.profiles-table .brand-cell .brand-count {
  font-weight: 700;
  color: var(--ew-magenta, #c2185b);
}
.profiles-table .recency-fresh { color: #2e7d32; font-weight: 600; }
.profiles-table .recency-stale { color: #e65100; }
.profiles-table .recency-dead { color: #c62828; font-weight: 600; }
.profiles-table .agcom-risk { color: #c62828; font-weight: 700; }
.profiles-table .agcom-ok { color: #2e7d32; }
.profiles-table .has-email-yes { color: #2e7d32; font-size: 14px; }
.profiles-table .has-email-no { color: #bdbdbd; font-size: 14px; }
/* /profiles ora usa il drawer (come /shortlist), non più split-pane. */
.profiles-main {
  display: flex;
  flex-direction: column;
}
.list-pane { display: flex; flex-direction: column; background: var(--ew-off); }
.card-pane { background: #fff; border-left: 1px solid var(--ew-gray-200); }

/* La filter bar resta sticky in cima al main quando si scrolla */
.filter-bar {
  position: sticky;
  top: 56px;
  z-index: 10;
}

/* ============= FILTER BAR ============= */
.filter-bar {
  padding: 14px 20px;
  background: #fff;
  border-bottom: 1px solid var(--ew-gray-200);
  flex-shrink: 0;
}
.filter-bar .row {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
}
.filter-bar .search { flex: 1; min-width: 240px; }
.filter-bar input[type=text],
.filter-bar input[type=number],
.filter-bar select {
  padding: 8px 14px;
  border: 1px solid var(--ew-gray-200);
  border-radius: 999px;
  font-family: inherit; font-size: 12px;
  background: var(--ew-off);
  color: var(--ew-violet);
  outline: none;
  min-width: 110px;
}
.filter-bar input[type=text]:focus,
.filter-bar input[type=number]:focus,
.filter-bar select:focus { background: #fff; border-color: var(--ew-magenta); }
.filter-bar .chk {
  font-size: 12px; color: var(--ew-gray-700);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--ew-gray-200);
  border-radius: 999px;
  cursor: pointer;
}
.filter-bar .chk-warning {
  border-color: #f59e0b;
  color: #92400e;
  background: #fffbeb;
}

/* ============= TABLE ============= */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  position: relative;
}
/* Gradient hint per scroll orizzontale */
.table-wrap::after {
  content: "";
  position: sticky;
  top: 0;
  right: 0;
  width: 30px;
  height: 100%;
  background: linear-gradient(to right, rgba(255,255,255,0), rgba(255,255,255,0.9));
  pointer-events: none;
  display: block;
  margin-top: -100vh;
  z-index: 5;
}
table.profiles-table {
  width: 100%;
  min-width: 2200px;
  border-collapse: collapse;
  background: #fff;
  font-size: 14.5px;
}
.profiles-table thead th {
  background: var(--ew-violet-deep, #3a1d6e);
  color: #fff; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  font-size: 12.5px;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 2px solid var(--ew-violet, #4527a0);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 4;
}
.profiles-table thead th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background .15s;
}
.profiles-table thead th.sortable:hover { background: var(--ew-violet, #4527a0); }
/* Active sort: bordo inferiore magenta invece di sfondo magenta acceso */
.profiles-table thead th.sortable.active {
  background: var(--ew-violet, #4527a0);
  border-bottom: 3px solid var(--ew-magenta, #c2185b);
  color: #fff;
}
.profiles-table thead th .sort-arrow {
  display: inline-block;
  margin-left: 4px;
  font-weight: 700;
  opacity: 0.95;
}
.profiles-table tbody tr {
  border-bottom: 1px solid var(--ew-gray-100);
  cursor: pointer;
  transition: background .12s;
}
.profiles-table tbody tr:hover { background: var(--ew-violet-soft); }
.profiles-table tbody tr.selected {
  background: var(--ew-magenta-soft);
  box-shadow: inset 3px 0 0 var(--ew-magenta);
}
.profiles-table td { padding: 9px 12px; vertical-align: middle; font-size: 14px; }
/* Sticky first columns (check + avatar + profilo) durante scroll orizzontale */
.profiles-table tbody td:nth-child(1),
.profiles-table tbody td:nth-child(2),
.profiles-table tbody td:nth-child(3),
.profiles-table thead th:nth-child(1),
.profiles-table thead th:nth-child(2),
.profiles-table thead th:nth-child(3) {
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 3;
}
.profiles-table thead th:nth-child(1),
.profiles-table thead th:nth-child(2),
.profiles-table thead th:nth-child(3) {
  background: var(--ew-violet-deep, #3a1d6e);
  z-index: 5;
}
.profiles-table tbody td:nth-child(2) { left: 40px; }
.profiles-table tbody td:nth-child(3) { left: 80px; box-shadow: 2px 0 4px rgba(0,0,0,0.04); }
.profiles-table thead th:nth-child(2) { left: 40px; }
.profiles-table thead th:nth-child(3) { left: 80px; }
.profiles-table tbody tr:hover td:nth-child(1),
.profiles-table tbody tr:hover td:nth-child(2),
.profiles-table tbody tr:hover td:nth-child(3) {
  background: var(--ew-violet-soft, #f3e5f5);
}
.profiles-table tbody tr.selected td:nth-child(1),
.profiles-table tbody tr.selected td:nth-child(2),
.profiles-table tbody tr.selected td:nth-child(3) {
  background: var(--ew-magenta-soft, #fce4ec);
}

/* Compact view: nasconde colonne secondarie */
body.compact-view .profiles-table th.col-secondary,
body.compact-view .profiles-table td.col-secondary { display: none; }

/* Quick-filter chips */
.quick-filter-chips {
  display: flex;
  gap: 8px;
  padding: 12px 16px 4px;
  flex-wrap: wrap;
  background: var(--ew-off);
  border-bottom: 1px dashed #e5e5e5;
}
.quick-filter-chips .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .1s, box-shadow .15s;
  border: 1px solid transparent;
}
.quick-filter-chips .chip:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
.quick-filter-chips .chip.top-pick { background: #e8f5e9; color: #1b5e20; border-color: #66bb6a; }
.quick-filter-chips .chip.agcom { background: #ffebee; color: #b71c1c; border-color: #ef5350; }
.quick-filter-chips .chip.brand { background: #fce4ec; color: #ad1457; border-color: #ec407a; }
.quick-filter-chips .chip.active { box-shadow: inset 0 0 0 2px currentColor; }
.quick-filter-chips .chip-count { background: rgba(0,0,0,0.08); padding: 1px 7px; border-radius: 10px; font-size: 11px; }

/* View toggle */
.view-toggle {
  display: inline-flex;
  gap: 0;
  margin-left: auto;
  border: 1px solid var(--ew-gray-200, #e5e5e5);
  border-radius: 6px;
  overflow: hidden;
  align-self: center;
}
.view-toggle a {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  color: var(--ew-gray-700, #555);
  background: #fff;
}
.view-toggle a.active { background: var(--ew-violet-deep, #3a1d6e); color: #fff; }

/* Verdetto 2-righe (label sopra, descrizione sotto) */
.badge-livello.badge-2lines {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 4px 8px;
  line-height: 1.15;
  max-width: 130px;
  white-space: normal;
}
.badge-livello.badge-2lines .v-top {
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-livello.badge-2lines .v-bot {
  font-size: 10.5px;
  opacity: 0.85;
  font-weight: 500;
  margin-top: 1px;
}

/* ER anomalo badge */
.er-anomalo {
  display: inline-block;
  font-size: 10px;
  padding: 1px 5px;
  background: #fff3e0;
  color: #e65100;
  border-radius: 3px;
  font-weight: 700;
  margin-left: 4px;
  cursor: help;
}

/* Avatar foto reale */
.cell-avatar.with-photo {
  background-size: cover;
  background-position: center;
  background-color: var(--ew-magenta-soft, #fce4ec);
}
.cell-avatar.with-photo span { display: none; }
.empty-row { text-align: center; padding: 40px; color: var(--ew-gray-500); }
.cell-avatar {
  width: 38px; height: 38px; border-radius: 999px;
  background: linear-gradient(135deg, var(--ew-violet), var(--ew-magenta));
  color: #fff; font-weight: 600; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.cell-user { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.cell-user .meta { display: flex; flex-direction: column; line-height: 1.2; }
.cell-user .username { font-weight: 600; color: var(--ew-violet); }
.cell-user .fullname { color: var(--ew-gray-500); font-size: 11px; }
.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }

/* ============= TIER PILL ============= */
.tier-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
  background: var(--ew-gray-100); color: var(--ew-gray-700);
  white-space: nowrap;
}
.tier-pill .tier-name { text-transform: uppercase; letter-spacing: 0.04em; }
.tier-pill .tier-range { font-weight: 500; opacity: 0.78; font-size: 10px; }
.tier-pill.nano { background: #fff3e0; color: #e65100; }
.tier-pill.micro { background: #e8f5e9; color: #1b5e20; }
.tier-pill.mid { background: #e3f2fd; color: #0d47a1; }
.tier-pill.macro { background: #f3e5f5; color: #6a1b9a; }
.tier-pill.mega { background: var(--ew-magenta-soft); color: var(--ew-magenta-ink); }

/* ============= AQS GRADE ============= */
.grade {
  display: inline-block;
  width: 22px; height: 22px;
  border-radius: 4px;
  text-align: center; line-height: 22px;
  font-weight: 700; font-size: 12px;
  color: #fff;
}
.grade.A { background: var(--lv-eccellente); }
.grade.B { background: var(--lv-buono); }
.grade.C { background: var(--lv-medio); color: var(--ew-violet); }
.grade.D { background: var(--lv-scarso); }
.grade.E { background: var(--lv-critico); }

/* ============= BADGE LIVELLO ============= */
.badge-livello {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
  color: #fff;
  white-space: nowrap;
}
.badge-livello.eccellente { background: var(--lv-eccellente); }
.badge-livello.buono { background: var(--lv-buono); }
.badge-livello.medio { background: var(--lv-medio); color: #5d4500; }
.badge-livello.scarso { background: var(--lv-scarso); }
.badge-livello.critico { background: var(--lv-critico); }
.badge-livello.calc { background: var(--lv-calc); }
.badge-livello.neutro { background: var(--lv-neutro); }
.badge-livello.info { display: none; }

/* ID Utente (iscritto / non iscritto su Minfluencer) */
.cell-idutente { white-space: nowrap; text-align: center; }
.th-idutente { text-align: center; font-size: 11px; }
.badge-iscritto {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  background: #d1fae5; color: #065f46;
}
.badge-non-iscritto {
  font-size: 12px; color: var(--ew-gray-400);
}

/* ============= STAR / SHORTLIST ============= */
.star {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--ew-gray-300);
  line-height: 1; padding: 4px;
  transition: color .15s, transform .15s;
}
.star:hover { transform: scale(1.15); }
.star.active { color: var(--ew-magenta); }

.crm-cell { position: relative; }
.crm-state {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 3px 9px 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid transparent;
}
.crm-state.none { background: var(--ew-gray-100); color: var(--ew-gray-500); }
.crm-state.da-contattare { background: #fff3e0; color: #e65100; }
.crm-state.contattato { background: #e3f2fd; color: #0d47a1; }
.crm-state.risposto { background: #f3e5f5; color: #6a1b9a; }
.crm-state.iscritto { background: var(--lv-eccellente); color: #fff; }
.crm-state.rifiutato { background: var(--ew-gray-300); color: var(--ew-gray-700); }
.crm-state::after { content: " ▾"; font-size: 9px; opacity: 0.65; }

/* CRM popover quick-change */
.crm-popover {
  position: absolute;
  top: calc(100% + 4px);
  left: 8px;
  background: #fff;
  border: 1px solid var(--ew-gray-200);
  border-radius: 8px;
  box-shadow: 0 12px 32px -8px rgba(35, 1, 89, 0.25);
  padding: 4px;
  z-index: 50;
  min-width: 200px;
}
.crm-popover .opt {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 12px; font-weight: 500;
  color: var(--ew-violet);
  cursor: pointer;
  transition: background .12s;
  text-transform: none; letter-spacing: 0;
}
.crm-popover .opt:hover { background: var(--ew-violet-soft); }
.crm-popover .opt.current { background: var(--ew-magenta-soft); color: var(--ew-magenta-ink); }
.crm-popover .opt.current::after { content: "✓"; margin-left: auto; font-weight: 700; color: var(--ew-magenta); }
.crm-popover .opt .dot {
  width: 9px; height: 9px;
  border-radius: 999px;
  flex-shrink: 0;
}
.crm-popover .opt .dot.none { background: var(--ew-gray-300); }
.crm-popover .opt .dot.da-contattare { background: #ff9a3c; }
.crm-popover .opt .dot.contattato { background: #2196f3; }
.crm-popover .opt .dot.risposto { background: #9c27b0; }
.crm-popover .opt .dot.iscritto { background: var(--lv-eccellente); }
.crm-popover .opt .dot.rifiutato { background: var(--ew-gray-500); }
.crm-popover hr { border: 0; border-top: 1px solid var(--ew-gray-100); margin: 4px 0; }

/* Close popover when clicking outside (HTMX-friendly: remove on next htmx swap on body) */
.crm-cell { position: relative; }

/* ============= PAGINATION ============= */
.pagination {
  background: #fff;
  border-top: 1px solid var(--ew-gray-200);
  padding: 12px 20px;
  display: flex; align-items: center; gap: 12px;
  font-size: 12px;
  color: var(--ew-gray-500);
  flex-shrink: 0;
}
.pagination strong { color: var(--ew-violet); font-weight: 600; }
.pagination .pages { margin-left: auto; display: flex; gap: 4px; }
.pagination .pages button {
  border: 1px solid var(--ew-gray-200);
  background: #fff;
  width: 28px; height: 28px;
  border-radius: 6px;
  font-family: inherit; font-size: 12px;
  cursor: pointer;
  color: var(--ew-violet);
}
.pagination .pages button.curr { background: var(--ew-violet); color: #fff; border-color: var(--ew-violet); }

/* ============= CARD PANE ============= */
.card-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--ew-gray-500);
}
.card-empty .ew-label { display: block; margin-bottom: 8px; }
.card-header {
  background: linear-gradient(135deg, var(--ew-violet) 0%, var(--ew-violet-deep) 100%);
  color: #fff;
  padding: 32px 36px;
  display: flex; align-items: center; gap: 24px;
  position: relative;
}
.card-header .pic {
  width: 120px; height: 120px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fff, var(--ew-magenta-soft));
  color: var(--ew-violet);
  font-weight: 700; font-size: 40px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  border: 4px solid var(--ew-magenta);
  overflow: hidden;
}
.card-header .pic img { width: 100%; height: 100%; object-fit: cover; }
.card-header .info { flex: 1; min-width: 0; }
.card-header .label {
  font-size: 11px; font-weight: 600;
  color: var(--ew-magenta-hot);
  text-transform: uppercase; letter-spacing: 0.18em;
  margin-bottom: 6px;
}
.card-header .name { font-size: 26px; font-weight: 600; margin-bottom: 4px; line-height: 1.2; }
.card-header .handle { font-size: 14px; color: rgba(255,255,255,0.75); }
.badge-limitato {
  display: inline-block;
  margin-top: 8px;
  font-size: 11px;
  font-weight: 600;
  background: var(--lv-medio);
  color: #5d4500;
  padding: 4px 10px;
  border-radius: 6px;
}

/* Bio + link nel header card */
.card-bio {
  margin-top: 12px;
  font-size: 14px;
  color: rgba(255,255,255,0.9);
  line-height: 1.5;
  max-height: 100px;
  overflow-y: auto;
  white-space: pre-line;
  padding-right: 4px;
  max-width: 700px;
}
.card-bio::-webkit-scrollbar { width: 4px; }
.card-bio::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); border-radius: 2px; }
.card-link {
  margin-top: 10px;
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 700px;
}
.card-link a { color: var(--ew-magenta-hot); text-decoration: none; }
.card-link a:hover { text-decoration: underline; }

/* Help text dentro metric */
.metric .help {
  font-size: 10px;
  color: var(--ew-gray-500);
  line-height: 1.3;
  margin-top: 2px;
}

/* Note diagnostiche */
.diag-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.diag-list li {
  background: #fff8e1;
  border-left: 3px solid var(--lv-medio);
  padding: 8px 12px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--ew-gray-700);
  border-radius: 4px;
}

/* Posts grid (Ultimi N post) — 4 colonne nel drawer 960px */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.post-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--ew-gray-200);
  border-radius: 8px;
  background: #fff;
  text-decoration: none;
  color: var(--ew-violet);
  overflow: hidden;
  transition: box-shadow .15s, transform .12s;
}
.post-card:hover {
  box-shadow: 0 8px 20px -6px rgba(35,1,89,0.25);
  transform: translateY(-2px);
  text-decoration: none;
}
.post-card .post-head {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--ew-off);
  border-bottom: 1px solid var(--ew-gray-100);
  font-size: 12px;
}
.post-card .post-date { color: var(--ew-gray-500); }
.post-card .post-type { font-weight: 600; color: var(--ew-violet); }
.post-card .post-stats {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ew-violet);
}
.post-card .post-caption {
  padding: 8px 12px 12px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--ew-gray-700);
  flex: 1;
  max-height: 68px;
  overflow: hidden;
}

@media (max-width: 1200px) {
  .posts-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .posts-grid { grid-template-columns: repeat(2, 1fr); }
}
.verdict {
  position: absolute; top: 20px; right: 20px;
  background: var(--lv-neutro); color: #fff;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  box-shadow: 0 4px 12px -2px rgba(0,0,0,0.25);
}
.verdict.eccellente { background: var(--lv-eccellente); }
.verdict.buono { background: var(--lv-buono); }
.verdict.medio { background: var(--lv-medio); color: #5d4500; }
.verdict.scarso { background: var(--lv-scarso); }
.verdict.critico { background: var(--lv-critico); }

.card-section { padding: 24px 36px; border-bottom: 1px solid var(--ew-gray-100); }
.card-section h4 {
  font-size: 12px; font-weight: 700;
  color: var(--ew-magenta);
  text-transform: uppercase; letter-spacing: 0.18em;
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--ew-gray-200);
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px 24px;
}
.metric {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--ew-off);
  border-radius: 8px;
  padding: 14px 16px;
  border-left: 4px solid var(--ew-gray-200);
}
.metric .lbl {
  font-size: 12px; color: var(--ew-gray-500); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.metric .val {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  font-size: 24px; font-weight: 700;
  color: var(--ew-violet);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.metric .val small { font-size: 12px; color: var(--ew-gray-500); font-weight: 500; }
.metric .badge-livello { font-size: 11px; padding: 3px 9px; }
.metric .help { font-size: 11px; color: var(--ew-gray-500); line-height: 1.4; margin-top: 2px; }

/* Border-left dei metric coordinato col livello */
.metric:has(.badge-livello.eccellente) { border-left-color: var(--lv-eccellente); }
.metric:has(.badge-livello.buono) { border-left-color: var(--lv-buono); }
.metric:has(.badge-livello.medio) { border-left-color: var(--lv-medio); }
.metric:has(.badge-livello.scarso) { border-left-color: var(--lv-scarso); }
.metric:has(.badge-livello.critico) { border-left-color: var(--lv-critico); }
.metric:has(.badge-livello.calc) { border-left-color: var(--lv-calc); }
.metric:has(.badge-livello.neutro) { border-left-color: var(--lv-neutro); }

/* ============= CRM SECTION ============= */
.crm-section { background: var(--ew-violet-soft); }
.crm-section h4 { color: var(--ew-violet); border-bottom-color: var(--ew-gray-200); }
.crm-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.crm-form .field:nth-child(3) { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 12px; font-weight: 600;
  color: var(--ew-gray-700);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.field input, .field select, .field textarea {
  font-family: inherit; font-size: 14px;
  padding: 10px 14px;
  border: 1px solid var(--ew-gray-200);
  border-radius: 8px;
  background: #fff;
  color: var(--ew-violet);
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--ew-magenta); }
.field textarea { min-height: 100px; resize: vertical; }
.crm-actions { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.autosave-hint { font-size: 12px; color: var(--ew-gray-500); }
.muted { color: var(--ew-gray-500); font-size: 14px; }

/* ============= UPLOAD ============= */
.upload-page { padding: 48px; max-width: 720px; margin: auto; }
.upload-card {
  background: #fff;
  padding: 32px;
  border-radius: 14px;
  border: 1px solid var(--ew-gray-200);
}
.upload-card .field { margin: 16px 0; }
.error-banner {
  background: #ffeaea;
  color: var(--lv-critico);
  padding: 12px 16px;
  border-radius: 8px;
  border-left: 3px solid var(--lv-critico);
  font-size: 14px;
  margin: 16px 0;
}
.upload-card label {
  font-size: 11px; font-weight: 500;
  color: var(--ew-gray-700);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.upload-card select, .upload-card input[type=file] {
  padding: 10px 12px;
  border: 1px solid var(--ew-gray-200);
  border-radius: 8px;
  font-family: inherit; font-size: 14px;
}
.stat-row { display: flex; gap: 24px; margin: 24px 0; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; }
.stat .num { font-size: 32px; font-weight: 700; color: var(--ew-magenta); line-height: 1; }
.stat .lbl {
  font-size: 12px; color: var(--ew-gray-500);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-top: 4px;
}

/* ============= DISCOVERIES ============= */
.discoveries-page { padding: 32px; max-width: 1100px; margin: auto; }
.discoveries-table { width: 100%; border-collapse: collapse; margin-top: 16px; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.discoveries-table th {
  background: var(--ew-violet); color: #fff;
  text-align: left; padding: 12px 14px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.discoveries-table td { padding: 12px 14px; border-bottom: 1px solid var(--ew-gray-100); }
.discoveries-table th.num, .discoveries-table td.num { text-align: right; }

/* ============= SHORTLIST (gruppi tabella) ============= */
.shortlist-page { padding: 24px 32px 32px; }
.shortlist-page .page-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px;
}
.shortlist-page .page-header .ew-label { display: block; margin-bottom: 4px; }
.shortlist-page h1 { margin: 0; }
.shortlist-page h1 .muted { font-weight: 400; font-size: 16px; color: var(--ew-gray-500); }

.sl-group { margin-bottom: 32px; }
.sl-group-title {
  display: flex; align-items: center; gap: 12px;
  margin: 0 0 12px;
  font-size: 16px;
}
.sl-group-title .crm-state {
  font-size: 12px;
  padding: 5px 14px;
  cursor: default;
}
.sl-group-title .crm-state::after { content: ""; }
.sl-group-title .count {
  background: var(--ew-violet-soft);
  color: var(--ew-violet);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.sl-table thead th {
  /* Header meno alti dei profili */
  font-size: 10px;
  padding: 8px 12px;
}
.sl-table { box-shadow: 0 1px 2px rgba(0,0,0,0.04); border-radius: 8px; overflow: hidden; }
.sl-table tbody tr:hover { background: var(--ew-magenta-soft); }
.sl-table .email-cell {
  font-size: 12px;
  color: var(--ew-gray-700);
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sl-table .ig-link {
  font-size: 12px;
  padding: 4px 10px;
  background: var(--ew-violet);
  color: #fff;
  border-radius: 6px;
  text-decoration: none;
}
.sl-table .ig-link:hover { background: var(--ew-violet-deep); text-decoration: none; }

/* Drawer card fluttuante per /shortlist e /profiles.
   Selettore: body con classe "drawer-pane" → matcha il card-pane fisso. */
body.drawer-pane #card-pane {
  position: fixed;
  top: 56px;
  right: 0;
  width: 960px;
  max-width: 95vw;
  height: calc(100vh - 56px);
  background: #fff;
  border-left: 1px solid var(--ew-gray-200);
  box-shadow: -16px 0 40px -12px rgba(35,1,89,0.3);
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform .25s ease;
  z-index: 30;
}
body.drawer-pane #card-pane:not(:empty) { transform: translateX(0); }

/* Backdrop semi-trasparente bianco dietro il drawer */
body.drawer-pane #card-pane:not(:empty)::before {
  content: "";
  position: fixed;
  top: 56px; left: 0;
  width: calc(100vw - 960px);
  height: calc(100vh - 56px);
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(1px);
  z-index: -1;
}

/* Bottone chiudi drawer (X in top-right) */
.drawer-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  border-radius: 10px;
  cursor: pointer;
  font-size: 24px;
  font-weight: 300;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
  transition: background .15s, transform .15s;
}
.drawer-close:hover { background: rgba(255,255,255,0.3); transform: scale(1.05); }

.empty-state {
  background: #fff;
  border: 1px dashed var(--ew-gray-200);
  border-radius: 12px;
  padding: 48px;
  text-align: center;
  color: var(--ew-gray-500);
}
.empty-state .ew-label { display: block; margin-bottom: 8px; }

/* ============= BIO + SECTOR COLUMNS ============= */
.profiles-table .cell-bio {
  max-width: 260px;
  min-width: 180px;
  font-size: 12px;
  color: var(--ew-gray-700);
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  cursor: help;
}
.profiles-table .cell-sector {
  max-width: 130px;
  font-size: 12px;
  color: var(--ew-gray-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profiles-table th.th-bio { min-width: 180px; }

/* ============= ID UTENTE COLUMN ============= */
.profiles-table .cell-idutente { text-align: center; }
.badge-iscritto {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--lv-eccellente);
  color: #fff;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.badge-non-iscritto {
  color: var(--ew-gray-300);
  font-weight: 600;
  font-size: 12px;
}

/* ============= FILTER CHECKBOX WARNING ============= */
.filter-bar .chk-warning {
  background: #fff3e0;
  color: #e65100;
  border: 1px solid #ffd180;
  padding: 7px 12px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.filter-bar .chk-warning input { accent-color: #e65100; }

/* ============= BULK SELECTION ============= */
.profiles-table th.th-check,
.profiles-table td.cell-check {
  width: 36px;
  text-align: center;
  padding-left: 14px;
  padding-right: 0;
}
.profiles-table input[type=checkbox] {
  cursor: pointer;
  width: 16px;
  height: 16px;
  accent-color: var(--ew-magenta);
}

.bulk-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: var(--ew-violet);
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  box-shadow: 0 18px 48px -12px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
}
.bulk-bar[hidden] { display: none; }
.bulk-count strong {
  color: var(--ew-magenta-hot);
  font-weight: 700;
  font-size: 16px;
  margin-right: 4px;
}
.ew-btn--danger {
  background: var(--lv-critico);
  color: #fff;
}
.ew-btn--danger:hover { background: #a01e1e; }
.bulk-bar .ew-btn--ghost {
  background: transparent;
  color: #fff;
  border-color: rgba(255,255,255,0.4);
}
.bulk-bar .ew-btn--ghost:hover {
  background: rgba(255,255,255,0.1);
  border-color: #fff;
}

@media (max-width: 1100px) {
  .kanban { grid-template-columns: repeat(2, 1fr); }
  .profiles-main { grid-template-columns: 1fr 360px; }
}

@media (max-width: 800px) {
  .profiles-main { grid-template-columns: 1fr; }
  .card-pane { display: none; }
}
