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

body {
  background: #1a1714;
  color: #f3efe9;
  font-family: 'Inter', system-ui, sans-serif;
  min-height: 100dvh;
}

.wrap { max-width: 1000px; margin: 0 auto; padding: 24px 20px 80px; }
.center { text-align: center; margin-top: 60px; }
.dim { color: rgba(255,255,255,0.45); }

/* Topbar */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.brand { font-size: 22px; font-weight: 900; letter-spacing: -0.5px; }
.logout, .back {
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.8); border-radius: 999px; padding: 8px 16px;
  font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.logout:hover, .back:hover { background: rgba(255,255,255,0.12); }
.back { margin-bottom: 18px; }

/* Griglia lista */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card {
  background: #242019; border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px; padding: 16px; cursor: pointer; transition: border-color 0.12s, transform 0.08s;
}
.card:hover { border-color: rgba(244,192,137,0.4); transform: translateY(-1px); }
/* Risposta: verde a sinistra = persona ha risposto (da ascoltare); grigio+sbiadito = saltare */
.card.ans-yes { border-left: 4px solid #4caf6e; }
.card.ans-no  { border-left: 4px solid rgba(255,255,255,0.18); opacity: 0.5; }
.card.ans-no:hover { opacity: 0.85; }
.ans-strip { font-size: 11px; font-weight: 800; letter-spacing: 0.4px; margin-bottom: 8px; }
.ans-strip-yes { color: #6fd698; }
.ans-strip-no  { color: rgba(255,255,255,0.5); }
.ans-pill { border-radius: 6px; padding: 2px 8px; font-size: 11px; font-weight: 800; border: 1px solid; }
.ans-pill.ans-strip-yes { background: rgba(79,175,110,0.14); border-color: rgba(79,175,110,0.45); }
.ans-pill.ans-strip-no  { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.18); }
/* Barra filtro */
.filterbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.filter-toggle {
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.8); border-radius: 999px; padding: 8px 16px;
  font-size: 13px; font-weight: 700; cursor: pointer; min-height: 40px;
}
.filter-toggle.on { background: rgba(79,175,110,0.16); border-color: rgba(79,175,110,0.5); color: #8fe0ad; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.lead-name { font-weight: 700; font-size: 15px; }
.stars-badge { color: #f4c089; font-size: 13px; letter-spacing: 1px; }
.card-meta { margin: 8px 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-bottom { display: flex; align-items: center; gap: 10px; font-size: 12px; flex-wrap: wrap; }
.badge {
  background: rgba(244,192,137,0.12); border: 1px solid rgba(244,192,137,0.3);
  color: #f4c089; border-radius: 6px; padding: 2px 8px; font-size: 11px; font-weight: 600;
}
.comment-pill { color: rgba(255,255,255,0.6); font-size: 12px; }
.no-audio { color: rgba(255,120,120,0.7); font-size: 11px; }

/* Dettaglio */
.detail-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.detail-head h2 { font-size: 20px; font-weight: 800; }

.player-box {
  background: #242019; border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px; padding: 16px; margin-bottom: 16px;
}
.mark-btn {
  margin-top: 12px; width: 100%; background: #f4c089; color: #1a1714; border: none;
  border-radius: 999px; padding: 12px; font-size: 14px; font-weight: 800; cursor: pointer; font-family: inherit;
}
.mark-btn:hover { background: #e8a662; }

/* Form commento */
.comment-form {
  background: #242019; border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px; padding: 16px; margin-bottom: 16px;
}
.comment-form-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.ts-chip {
  background: rgba(244,192,137,0.15); color: #f4c089; border-radius: 6px;
  padding: 4px 10px; font-size: 13px; font-weight: 700; min-width: 90px; text-align: center;
}
select, textarea {
  background: #1a1714; border: 1.5px solid rgba(255,255,255,0.12); color: #f3efe9;
  border-radius: 10px; padding: 9px 12px; font-size: 14px; font-family: inherit; outline: none; width: 100%;
}
select:focus, textarea:focus { border-color: #f4c089; }
textarea { resize: vertical; }
.primary {
  margin-top: 10px; background: #f4c089; color: #1a1714; border: none;
  border-radius: 999px; padding: 10px 18px; font-size: 14px; font-weight: 800; cursor: pointer; font-family: inherit;
}
.primary:hover { background: #e8a662; }
.primary:disabled { opacity: 0.4; cursor: not-allowed; }

/* Commenti */
.comments, .feedback-box { margin-bottom: 16px; }
.comments h3, .feedback-box h3, .info-col h3 {
  font-size: 14px; font-weight: 700; margin-bottom: 10px; color: rgba(255,255,255,0.7);
}
.comment {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.ts-link {
  background: rgba(244,192,137,0.15); color: #f4c089; border: none; border-radius: 6px;
  padding: 3px 9px; font-size: 12px; font-weight: 700; cursor: pointer; font-family: inherit; flex-shrink: 0;
}
.ts-link:hover { background: rgba(244,192,137,0.3); }
.comment-body { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.cat { font-size: 11px; color: #f4c089; text-transform: uppercase; letter-spacing: 0.5px; }
.ctext { font-size: 14px; line-height: 1.4; }
.del {
  background: none; border: none; color: rgba(255,100,100,0.6); font-size: 18px;
  cursor: pointer; flex-shrink: 0; line-height: 1;
}
.del:hover { color: rgba(255,100,100,1); }

.feedback-box {
  background: #242019; border: 1px solid rgba(255,255,255,0.08); border-radius: 14px; padding: 16px;
}

/* Info grid */
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 720px) { .info-grid { grid-template-columns: 1fr; } }
.info-col {
  background: #242019; border: 1px solid rgba(255,255,255,0.08); border-radius: 14px; padding: 16px;
}
.pre {
  white-space: pre-wrap; word-break: break-word; font-family: inherit; font-size: 13px;
  line-height: 1.5; color: rgba(255,255,255,0.85); max-height: 360px; overflow-y: auto;
}

/* ─── Barra navigazione condivisa (pannello unico Regia) ─── */
.nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(20px, calc((100% - 1000px) / 2 + 20px));
  background: rgba(26,23,20,0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.nav-links { display: flex; gap: 8px; }
.nav-link {
  text-decoration: none; color: rgba(255,255,255,0.6);
  border: 1px solid transparent; border-radius: 999px;
  padding: 9px 16px; font-size: 14px; font-weight: 700; line-height: 1;
  display: inline-flex; align-items: center; min-height: 40px;
}
.nav-link:hover { color: #f3efe9; background: rgba(255,255,255,0.06); }
.nav-link.active { color: #f4c089; background: rgba(244,192,137,0.12); border-color: rgba(244,192,137,0.3); }
.nav-logout {
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.8); border-radius: 999px; padding: 9px 16px;
  font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; min-height: 40px;
}
.nav-logout:hover { background: rgba(255,255,255,0.12); }

/* Telefono lead nelle card */
.card-phone { font-size: 13px; color: rgba(255,255,255,0.72); margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ─── Mobile ─── */
@media (max-width: 720px) {
  .wrap { padding: 16px 14px 80px; }
  .nav { padding: 8px 14px; }
  .nav-link { padding: 9px 12px; font-size: 13px; }
  .grid { grid-template-columns: 1fr; }
  .detail-head h2 { font-size: 18px; }
}

/* ─── Ricerca e filtri archivio ─── */
.searchbar {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px; padding: 4px 14px; margin-bottom: 10px;
}
.searchbar:focus-within { border-color: rgba(79,175,110,0.55); background: rgba(79,175,110,0.06); }
.search-ico { font-size: 16px; opacity: 0.6; }
.search-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: #eee; font-size: 16px; padding: 12px 0; font-family: inherit;
}
.search-input::placeholder { color: rgba(255,255,255,0.35); }
.search-clear {
  background: transparent; border: none; color: rgba(255,255,255,0.5);
  font-size: 16px; cursor: pointer; padding: 4px 6px; line-height: 1;
}
.search-clear:hover { color: #eee; }
.search-hint { font-size: 13px; color: rgba(255,255,255,0.5); margin: -4px 0 12px 4px; }
.sel {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.14);
  color: #ddd; border-radius: 999px; padding: 8px 12px;
  font-size: 13px; font-family: inherit; cursor: pointer;
}
.sel:hover { border-color: rgba(255,255,255,0.3); }
.sel.reset { color: #f4c089; border-color: rgba(244,192,137,0.4); }

@media (max-width: 720px) {
  .search-input { font-size: 16px; }
  .filterbar { gap: 8px; }
  .sel { padding: 7px 10px; font-size: 12px; }
}

/* ───────────── Telefono (schermata "componi e parla") ───────────── */
.tel-wrap { max-width: 560px; }
.tel-titolo { font-size: 26px; font-weight: 800; margin: 18px 0 4px; }
.tel-sub { color: #999; font-size: 14px; line-height: 1.5; margin: 0 0 18px; }
.tel-avviso {
  background: rgba(230,170,60,0.12); border: 1px solid rgba(230,170,60,0.45);
  color: #e0aa4a; border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px;
}
.tel-errore {
  background: rgba(220,80,80,0.12); border: 1px solid rgba(220,80,80,0.45);
  color: #e07070; border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-top: 14px;
}

/* chiavette */
.tel-sim-riga { display: flex; gap: 10px; flex-wrap: wrap; }
.tel-sim {
  flex: 1 1 150px; display: flex; flex-direction: column; gap: 2px; align-items: flex-start;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px; padding: 10px 12px; cursor: pointer; color: #ddd; font-size: 12px;
  min-height: 44px; text-align: left;
}
.tel-sim b { font-size: 14px; }
.tel-sim span { color: #8e8e8e; }
.tel-sim.sel { border-color: rgba(120,200,140,0.7); background: rgba(120,200,140,0.12); }
.tel-sim:disabled { opacity: 0.55; cursor: default; }
.tel-sim .tel-pallino { font-weight: 700; }
.tel-ok .tel-pallino { color: #7ec88c; }
.tel-busy .tel-pallino { color: #e0aa4a; }
.tel-fail .tel-pallino { color: #e07070; }
.tel-nota { color: #8e8e8e; font-size: 12px; margin: 8px 0 16px; }

/* numero + tastierino */
.tel-numero {
  width: 100%; box-sizing: border-box; background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.15); border-radius: 12px; color: #fff;
  font-size: 26px; font-weight: 600; letter-spacing: 1px; padding: 14px 16px; text-align: center;
}
.tel-numero:disabled { opacity: 0.6; }
.tel-tastierino {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0;
}
.tel-tasto {
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px; color: #eee; font-size: 20px; font-weight: 600;
  padding: 14px 0; cursor: pointer; min-height: 48px;
}
.tel-tasto:hover:not(:disabled) { background: rgba(255,255,255,0.11); }
.tel-tasto:disabled { opacity: 0.4; cursor: default; }

/* chiamare / in linea */
.tel-chiama {
  width: 100%; background: rgba(120,200,140,0.2); border: 1px solid rgba(120,200,140,0.6);
  color: #7ec88c; border-radius: 14px; font-size: 18px; font-weight: 800;
  padding: 16px 0; cursor: pointer; min-height: 52px;
}
.tel-chiama:disabled { opacity: 0.45; cursor: default; }
.tel-incorso {
  background: rgba(120,200,140,0.10); border: 1px solid rgba(120,200,140,0.35);
  border-radius: 14px; padding: 16px;
}
.tel-incorso-testa { display: flex; justify-content: space-between; align-items: baseline; font-size: 20px; }
.tel-durata { font-variant-numeric: tabular-nums; color: #7ec88c; font-weight: 700; }
.tel-incorso-sotto { color: #8e8e8e; font-size: 12px; margin-top: 4px; }
.tel-bottoni { display: flex; gap: 10px; margin-top: 14px; }
.tel-muto {
  flex: 1; background: transparent; border: 1px solid rgba(255,255,255,0.18);
  color: #ccc; border-radius: 12px; padding: 12px 0; font-size: 14px; font-weight: 600; cursor: pointer;
}
.tel-muto.on { background: rgba(230,170,60,0.16); border-color: rgba(230,170,60,0.55); color: #e0aa4a; }
.tel-riaggancia {
  flex: 1; background: rgba(220,80,80,0.18); border: 1px solid rgba(220,80,80,0.55);
  color: #e07070; border-radius: 12px; padding: 12px 0; font-size: 14px; font-weight: 700; cursor: pointer;
}
.tel-piede { color: #777; font-size: 12px; line-height: 1.55; margin-top: 20px; }

@media (max-width: 520px) {
  .tel-sim { flex: 1 1 100%; }
  .tel-numero { font-size: 22px; }
}

/* scelta della linea: internet (Telnyx) o SIM del gateway */
.tel-linee { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.tel-linea {
  flex: 1 1 200px; display: flex; flex-direction: column; gap: 3px; align-items: flex-start;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px; padding: 12px 14px; cursor: pointer; color: #ddd; text-align: left;
}
.tel-linea b { font-size: 14px; }
.tel-linea span { color: #8e8e8e; font-size: 11px; line-height: 1.4; }
.tel-linea.sel { border-color: rgba(120,200,140,0.7); background: rgba(120,200,140,0.12); }
.tel-linea:disabled { opacity: 0.55; cursor: default; }

/* misura del microfono durante la chiamata */
.tel-mic { margin-top: 14px; }
.tel-mic-testa { display: flex; justify-content: space-between; font-size: 12px; color: #8e8e8e; margin-bottom: 6px; }
.tel-mic-ok { color: #7ec88c; font-weight: 700; }
.tel-mic-attesa { color: #e0aa4a; }
.tel-mic-barra {
  position: relative; height: 10px; border-radius: 6px; overflow: hidden;
  background: rgba(255,255,255,0.08);
}
.tel-mic-riempi {
  height: 100%; background: linear-gradient(90deg, #7ec88c, #e0aa4a);
  transition: width 60ms linear;
}
.tel-mic-picco {
  position: absolute; top: 0; width: 2px; height: 100%; background: #fff; opacity: 0.75;
}
.tel-mic-guaio { color: #e07070; font-size: 11px; margin-top: 6px; }

/* invito di una seconda persona nella telefonata */
.tel-invito { margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,0.10); }
.tel-invita {
  width: 100%; background: rgba(120,160,220,0.14); border: 1px solid rgba(120,160,220,0.45);
  color: #8fb6e8; border-radius: 12px; padding: 12px 0; font-size: 14px; font-weight: 700; cursor: pointer;
}
.tel-invito-testa { font-size: 12px; color: #7ec88c; font-weight: 700; margin-bottom: 6px; }
.tel-invito-link {
  width: 100%; box-sizing: border-box; background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.15); border-radius: 10px; color: #ddd;
  font-size: 11px; padding: 9px 10px; font-family: ui-monospace, Menlo, monospace;
}
.tel-invito-azioni { display: flex; gap: 8px; margin-top: 8px; }
