:root {
  --ink: #24384a;
  --muted: #6e7c8a;
  --line: #dce4eb;
  --bg: #f4f7fa;
  --blue: #29465b;
  --orange: #f47d33;
  --green: #26865d;
  --red: #bd3d3d;
  --soft-blue: #e9f1f7;
  --soft-orange: #fff0e7;
}

* {
  letter-spacing: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-navbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 3px 10px rgba(36, 56, 74, .05);
  padding-top: 6px;
  padding-bottom: 6px;
}

.app-navbar-two-rows {
  align-items: stretch;
  flex-direction: column;
  position: sticky;
  top: 0;
  z-index: 1030;
}

.app-navbar-top {
  align-items: center;
  background: #fff;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 6px;
}

.app-navbar-bottom {
  background: #26865d;
  border-top: 1px solid #1d6a49;
  justify-content: center;
  padding-bottom: 8px;
  padding-top: 8px;
  position: relative;
  z-index: 1;
}

.app-navbar-bottom .navbar-collapse {
  display: flex !important;
  justify-content: center;
  width: 100%;
}

.app-navbar-bottom .navbar-nav {
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

.app-navbar-user {
  margin-left: auto;
}

.brand-logo {
  width: 42px;
  height: 34px;
  object-fit: contain;
}

.navbar-brand {
  font-weight: 800;
  color: #111;
  font-size: 1.05rem;
}

.navbar-brand:hover {
  color: #111;
}

.navbar-nav {
  gap: 6px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 12px !important;
  border: 1px solid rgba(0,0,0,.35);
  border-radius: 7px;
  background: #fff;
  color: #111 !important;
  font-size: .84rem;
  font-weight: 800;
  line-height: 1;
  transition: .15s ease;
}

.nav-link:hover {
  background: #f3f3f3;
  color: #111 !important;
  border-color: #111;
}

.nav-link.active {
  background: #fff;
  border-color: #111;
  color: #111 !important;
}

.nav-link.active:hover {
  background: #f3f3f3;
  color: #111 !important;
}

.clock-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--blue);
  font-size: .84rem;
  font-weight: 800;
  padding: 6px 10px;
  white-space: nowrap;
}

.app-shell {
  padding: 28px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(41, 70, 91, .12), rgba(244, 125, 51, .10)),
    #f7fafc;
}

.login-card {
  width: min(460px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(36, 56, 74, .16);
  padding: 34px;
}

.login-logo {
  width: 118px;
  display: block;
  margin-bottom: 18px;
}

h1 {
  font-size: clamp(1.55rem, 2.6vw, 2.25rem);
  font-weight: 800;
  margin: 0;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.page-head .btn-success {
  min-width: 160px;
}

.page-head p {
  color: var(--muted);
  margin: 6px 0 0;
}

.workbench-head {
  align-items: center;
}

.workbench-search-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 520px;
}

.workbench-search-inline .form-control {
  min-width: 320px;
  height: 42px;
}

.workbench-search-inline .btn {
  height: 42px;
  white-space: nowrap;
}

.advanced-toggle-btn,
.advanced-search-row .btn-warning {
  background: var(--orange);
  border-color: var(--orange);
  color: #111;
}

.advanced-toggle-btn:hover,
.advanced-search-row .btn-warning:hover {
  background: #df6824;
  border-color: #df6824;
  color: #111;
}

.advanced-search-row {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(5, minmax(130px, 1fr)) auto auto;
  margin-bottom: 10px;
  padding: 10px 12px;
}

.advanced-search-row .form-select,
.advanced-search-row .btn {
  height: 38px;
  font-size: .82rem;
}

.advanced-search-row .btn {
  white-space: nowrap;
}

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(36, 56, 74, .06);
  padding: 20px;
}

.panel.narrow {
  max-width: 760px;
}

.panel-title {
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 16px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.metric-grid.small {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.metric-card {
  border-radius: 8px;
  padding: 18px;
  border: 1px solid var(--line);
  background: #fff;
}

.metric-card span {
  color: var(--muted);
  display: block;
  font-weight: 700;
  font-size: .86rem;
}

.metric-card strong {
  display: block;
  font-size: 2rem;
  line-height: 1.1;
  margin-top: 8px;
}

.metric-blue {
  border-left: 5px solid var(--blue);
}

.metric-green {
  border-left: 5px solid var(--green);
}

.metric-orange {
  border-left: 5px solid var(--orange);
}

.metric-red {
  border-left: 5px solid var(--red);
}

.metric-gray {
  border-left: 5px solid #8796a5;
}

.campaign-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.campaign-tile {
  display: block;
  text-decoration: none;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(36, 56, 74, .06);
}

.campaign-tile:hover {
  border-color: var(--orange);
  transform: translateY(-1px);
}

.campaign-tile span,
.campaign-tile .tile-stats {
  display: block;
  color: var(--muted);
  font-size: .9rem;
}

.campaign-tile strong {
  display: block;
  font-size: 1.25rem;
  margin: 6px 0 16px;
}

.tile-alert {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  color: #9a4a0f;
  font-size: .86rem;
  font-weight: 800;
}

.operator-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.operator-tabs a {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  display: inline-flex;
  font-weight: 800;
  gap: 8px;
  padding: 8px 12px;
  text-decoration: none;
}

.operator-tabs a.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.operator-tabs b {
  background: rgba(244, 125, 51, .14);
  border-radius: 999px;
  color: var(--orange);
  min-width: 24px;
  padding: 1px 7px;
  text-align: center;
}

.operator-tabs a.active b {
  background: rgba(255, 255, 255, .2);
  color: #fff;
}

.urgent-panel {
  border-color: #ffc68d;
  box-shadow: 0 16px 44px rgba(244, 125, 51, .12);
}

.blink-dot {
  animation: pulseDot 1s infinite;
  background: #ef4444;
  border-radius: 50%;
  display: inline-block;
  height: 9px;
  width: 9px;
}

.blink-dot.big {
  height: 12px;
  margin-right: 8px;
  width: 12px;
}

.reminder-blink {
  animation: reminderPulse 1.1s infinite;
  font-weight: 900;
}

@keyframes reminderPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(244, 125, 51, .45); }
  50% { box-shadow: 0 0 0 8px rgba(244, 125, 51, 0); }
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .35; transform: scale(.78); }
}

.table > :not(caption) > * > * {
  padding: .85rem;
}

.lead-table small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.lead-table {
  font-size: .84rem;
}

.lead-table > :not(caption) > * > * {
  padding: .58rem .62rem;
}

.lead-row-new > td,
.mobile-lead-card.lead-row-new {
  --bs-table-bg: #fff8d6;
  background: #fff8d6;
  border-color: #f4d35e;
}

.lead-row-working > td,
.mobile-lead-card.lead-row-working {
  --bs-table-bg: #fff0df;
  background: #fff0df;
  border-color: #fb923c;
}

.lead-row-positive > td,
.mobile-lead-card.lead-row-positive {
  --bs-table-bg: #e8f9ef;
  background: #e8f9ef;
  border-color: #22c55e;
}

.lead-row-negative > td,
.mobile-lead-card.lead-row-negative {
  --bs-table-bg: #fee8e8;
  background: #fee8e8;
  border-color: #ef4444;
}

.tel-link {
  align-items: center;
  color: var(--blue);
  display: inline-flex;
  font-weight: 850;
  gap: 6px;
  line-height: 1.35;
  margin: 1px 0;
  min-width: 0;
  text-decoration: none;
}

.tel-link:hover {
  color: var(--orange);
  text-decoration: underline;
}

.tel-link.muted {
  color: var(--muted);
  font-weight: 700;
}

.crm-phone-item {
  border-radius: 8px;
  display: block;
  margin: 0 0 5px;
  max-width: 100%;
}

.crm-phone-item:last-child {
  margin-bottom: 0;
}

.crm-phone-main {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  min-width: 0;
}

.crm-phone-icon {
  align-items: center;
  background: #eef3f7;
  border-radius: 5px;
  color: #607386;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: .82rem;
  height: 25px;
  justify-content: center;
  margin: 0;
  min-width: 28px;
  padding: 2px 5px;
}

.crm-phone-number {
  background: transparent;
  color: inherit;
  display: inline;
  font-size: inherit;
  font-weight: inherit;
  margin: 0;
  min-width: 0;
  padding: 0;
  text-align: left;
  text-transform: none;
}

.crm-phone-item-invalid {
  background: #fff7f7;
  border: 1px solid #f1caca;
  border-left: 4px solid #dc2626;
  padding: 6px 8px;
}

.tel-link.crm-phone-invalid {
  color: #9f2d2d;
}

.tel-link.crm-phone-invalid .crm-phone-number {
  opacity: .78;
  text-decoration: line-through;
  text-decoration-color: #c62828;
  text-decoration-thickness: 2px;
}

.tel-link.crm-phone-invalid:hover {
  color: #7f1d1d;
}

.crm-phone-item-invalid .crm-phone-icon {
  background: #fee2e2;
  color: #991b1b;
}

.crm-phone-google {
  align-items: center;
  background: #fff;
  border: 1px solid #ccd7e1;
  border-radius: 7px;
  color: #334155;
  display: inline-flex;
  font-size: .69rem;
  font-weight: 850;
  gap: 5px;
  line-height: 1;
  padding: 5px 7px;
  text-decoration: none;
  white-space: nowrap;
}

.crm-phone-google:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
  text-decoration: none;
}

.crm-google-icon {
  align-items: center;
  background: #fff;
  border: 1px solid #e1e7ee;
  border-radius: 50%;
  color: #4285f4;
  display: inline-flex;
  flex: 0 0 19px;
  font-family: Arial, sans-serif;
  font-size: .72rem;
  font-weight: 900;
  height: 19px;
  justify-content: center;
  line-height: 1;
  margin: 0;
  padding: 0;
  text-transform: none;
  width: 19px;
}

.crm-phone-add-box {
  margin: 5px 0 0 34px;
}

.crm-phone-add-box > summary {
  color: #167345;
  cursor: pointer;
  display: inline-block;
  font-size: .69rem;
  font-weight: 850;
  list-style: none;
  padding: 2px 0;
  user-select: none;
}

.crm-phone-add-box > summary::-webkit-details-marker {
  display: none;
}

.crm-phone-add-box > summary:hover {
  color: #0f5132;
  text-decoration: underline;
}

.crm-phone-add-form {
  align-items: center;
  display: flex;
  gap: 6px;
  margin-top: 6px;
  max-width: 330px;
}

.crm-phone-add-form .form-control {
  flex: 1 1 auto;
  font-size: .78rem;
  min-width: 0;
}

.crm-phone-add-form .btn {
  flex: 0 0 auto;
  font-size: .72rem;
  font-weight: 850;
  white-space: nowrap;
}

.attempt-pill {
  background: #eef3f7;
  border: 1px solid #d8e2ea;
  border-radius: 999px;
  color: #45596c;
  display: inline-block;
  font-size: .78rem;
  font-weight: 800;
  margin: 2px 4px 2px 0;
  padding: 3px 8px;
}

@media (max-width: 575.98px) {
  .crm-phone-main {
    align-items: flex-start;
    flex-direction: column;
  }

  .crm-phone-google {
    margin-left: 34px;
  }

  .crm-phone-add-box {
    margin-left: 34px;
  }

  .crm-phone-add-form {
    align-items: stretch;
    flex-direction: column;
    max-width: 100%;
  }

  .crm-phone-add-form .btn {
    width: 100%;
  }
}

.recall-alert {
  background: #fff2d5;
  border: 1px solid #ffd28a;
  border-radius: 18px;
  color: #111;
  display: inline-block;
  width: 100%;
  box-sizing: border-box;
  font-size: .72rem;
  font-weight: 600;
  line-height: 1.15;
  padding: 5px 8px;
}

.recall-alert br{
  display:block;
}

.lead-date-reminder{
  margin-top:4px;
  color:#d97706;
  font-size:.72rem;
  font-weight:700;
  white-space:nowrap;
}

.btn-icon-edit{
  width:36px;
  min-width:36px;
  height:32px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:0 !important;
}

.company-link {
  color: var(--ink);
  display: inline-block;
  font-weight: 850;
  text-decoration: none;
}

.company-link:hover {
  color: var(--orange);
  text-decoration: underline;
}

.action-pill {
  background: #fff2d5;
  border: 1px solid #ffd28a;
  border-radius: 999px;
  color: #8a4d05;
  display: inline-block;
  font-size: .78rem;
  font-weight: 900;
  padding: 4px 8px;
}

.status-new {
  background: #facc15;
  color: #422006;
}

.status-working {
  background: #fb923c;
  color: #431407;
}

.status-positive {
  background: #22c55e;
  color: #052e16;
}

.status-negative {
  background: #ef4444;
  color: #fff;
}

.badge.status-new,
.badge.status-working,
.badge.status-positive,
.badge.status-negative {
  font-size: .72rem;
  font-weight: 900;
  padding: .32rem .46rem;
}

.lead-action-badges{
  display:flex;
  flex-direction:column;
  align-items:stretch;
  gap:5px;
  width:100%;
}

.lead-action-badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:100%;
  min-width:0;
  min-height:27px;
  padding:5px 8px;
  border-radius:8px;
  font-size:.70rem;
  font-weight:800;
  line-height:1;
  white-space:nowrap;
  box-sizing:border-box;
}

.lead-badge-email{
  background:#06b6d4;
  color:#fff;
}

.lead-badge-email-sent{
  background:#bdefff;
  color:#0b4963;
}

.lead-badge-reminder{
  background:#f59e0b;
  color:#111;
}

.lead-badge-confirmed{
  background:#9be37d;
  color:#0b3d0b;
}

.btn {
  border-radius: 6px;
  font-weight: 750;
}

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

.btn-primary:hover {
  background: #1f3546;
  border-color: #1f3546;
}

.btn-success {
  background: var(--green);
  border-color: var(--green);
}

.btn-row {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.panel > summary {
  border-radius: 8px;
  margin: -20px;
  padding: 16px 20px;
  transition: background .15s ease, border-color .15s ease;
}

.panel > summary:hover {
  background: #f8fafc;
}

.panel > summary::-webkit-details-marker {
  display: none;
}

.panel > summary .panel-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.panel > summary .panel-title::before {
  content: "▸";
  color: var(--blue);
  font-size: .9rem;
  transition: transform .15s ease;
}

.panel[open] > summary .panel-title::before {
  transform: rotate(90deg);
}

.panel[open] > summary {
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}

.panel > summary + form,
.panel > summary + .table-responsive {
  margin-top: 20px;
}

.panel .table td.text-end.btn-row {
  min-width: 180px;
}

.panel .table td .btn-row,
.panel .table td.text-end.btn-row {
  align-items: center;
  display: flex;
  justify-content: flex-end;
}

.panel .table td form.d-inline {
  display: inline-flex !important;
  margin: 0;
}

.panel .table td .btn {
  white-space: nowrap;
}

.panel .table th:last-child,
.panel .table td:last-child {
  text-align: right;
}

.panel details.panel {
  box-shadow: none;
}

.client-campaign-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.client-campaign-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.client-campaign-state-active,
.client-campaign-state-inactive {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 900;
  flex: 0 0 22px;
}

.client-campaign-state-active {
  background: #22c55e;
  color: #fff;
}

.client-campaign-state-inactive {
  background: #ef4444;
  color: #fff;
}

.client-campaign-name {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.client-campaign-name:hover {
  text-decoration: underline;
}

.client-campaign-item small {
  color: var(--muted);
  font-size: .75rem;
}

.user-row-details summary {
  cursor: pointer;
  font-weight: 800;
}

.user-campaign-list {
  margin-top: 8px;
}

.user-campaign-group {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.user-campaign-group summary {
  cursor: pointer;
  padding: 8px 12px;
  background: #f8fafc;
  font-weight: 800;
  list-style: none;
}

.user-campaign-group summary::-webkit-details-marker {
  display: none;
}

.user-campaign-group summary b {
  float: right;
  background: var(--blue);
  color: #fff;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: .72rem;
}

.user-campaign-group > div {
  padding: 10px 12px;
}

.user-campaign-group a {
  display: block;
  text-decoration: none;
  color: var(--blue);
  font-weight: 700;
  margin-bottom: 6px;
}

.user-campaign-group a:last-child {
  margin-bottom: 0;
}

.user-campaign-group small {
  display: block;
  color: var(--muted);
  font-size: .72rem;
}

.table small.text-muted {
  font-size: .72rem;
  line-height: 1.35;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 0;
}

.filter-pills .btn {
  font-size: .78rem;
  padding: 5px 9px;
}

.filter-pills b,
.filter-campaigns b {
  font-weight: 950;
  margin-left: 3px;
}

.filter-block {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 10px;
  padding: 10px 12px;
}

.filter-title {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 900;
  margin-bottom: 7px;
  text-transform: uppercase;
}

.filter-campaigns {
  margin-bottom: 0;
}

.filter-campaigns a {
  font-size: .8rem;
  padding: 6px 10px;
}

.compact-table {
  font-size: .84rem;
}

.desktop-leads{
    display:table;
    table-layout:fixed;
    width:100%;
}

/* Tentativi */
.desktop-leads th:nth-child(1),
.desktop-leads td:nth-child(1){
    width:50px;
    text-align:center;
}

/* Campagna */
.desktop-leads th:nth-child(2),
.desktop-leads td:nth-child(2){
    width:170px;
}

/* Azienda */
.desktop-leads th:nth-child(3),
.desktop-leads td:nth-child(3){
    width:auto;
}

/* Telefono */
.desktop-leads th:nth-child(4),
.desktop-leads td:nth-child(4){
    width:175px;
}

/* Comune */
.desktop-leads th:nth-child(5),
.desktop-leads td:nth-child(5){
    width:120px;
    font-size:.80rem;
}

/* Azione */
.desktop-leads th:nth-child(6),
.desktop-leads td:nth-child(6){
    width:185px;
}

/* Data azione */
.desktop-leads th:nth-child(7),
.desktop-leads td:nth-child(7){
    width:180px;
}

/* Ultima colonna vuota */
.desktop-leads th:nth-child(8),
.desktop-leads td:nth-child(8){
    width:4px;
    padding-left:0;
    padding-right:0;
}

.mobile-leads {
  display: none;
}

.mobile-lead-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 9px;
  overflow: hidden;
}

.mobile-lead-card summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  list-style: none;
  padding: 11px 12px;
}

.mobile-lead-card summary::-webkit-details-marker {
  display: none;
}

.mobile-lead-card summary strong,
.mobile-lead-card summary small {
  display: block;
}

.mobile-lead-card summary strong {
  font-size: .96rem;
}

.mobile-lead-card summary small {
  color: #56687a;
  font-size: .78rem;
  margin-top: 2px;
}

.mobile-lead-card summary b {
  background: var(--blue);
  border-radius: 6px;
  color: #fff;
  font-size: .75rem;
  padding: 6px 9px;
}

.mobile-lead-body {
  border-top: 1px solid rgba(36, 56, 74, .12);
  padding: 10px 12px 12px;
}

.mobile-lead-body dl {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 8px 10px;
  margin: 0;
}

.mobile-lead-body dt {
  color: var(--muted);
  font-size: .76rem;
  font-weight: 850;
}

.mobile-lead-body dd {
  font-size: .86rem;
  margin: 0;
  min-width: 0;
}

.mobile-lead-body dd small {
  color: var(--muted);
  display: block;
}

.mobile-actions {
  justify-content: flex-start;
  margin-top: 12px;
}

.detail-list {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px 16px;
}

.detail-list dt {
  color: var(--muted);
}

.detail-list dd {
  margin: 0;
}

.call-workspace {
  align-items: start;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, .8fr);
  gap: 12px;
}

.outcome-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.outcome-grid label {
  position: relative;
}

.outcome-grid input[type="radio"] {
  position: absolute;
  opacity: 0;
}

.outcome-grid span {
  display: block;
  min-height: 50px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 750;
  cursor: pointer;
}

.outcome-grid strong,
.outcome-grid small {
  display: block;
}

.outcome-grid strong {
  font-size: .9rem;
  line-height: 1.15;
}

.outcome-grid small {
  display: none;
}

.outcome-grid input[type="radio"]:checked + span {
  border-color: var(--orange);
  background: var(--soft-orange);
  color: #a34710;
}

.call-workspace-single {
  display: block;
}

.outcome-grid-single {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.outcome-section {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.outcome-section + .outcome-section {
  border-top: 1px solid var(--line);
  margin-top: 6px;
  padding-top: 12px;
}

.outcome-grid-single label {
  margin: 0;
}

.outcome-grid-single label > span {
  align-items: center;
  display: flex;
  min-height: 42px;
}

.outcome-line-with-date {
  align-items: center;
  display: grid;
  grid-template-columns: minmax(190px, .6fr) minmax(280px, 1fr);
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.outcome-line-with-date > span {
  border: 0;
  min-height: auto;
  padding: 0 8px;
}

.outcome-line-with-date input[type="radio"]:checked + span {
  border: 0;
  background: transparent;
  color: var(--ink);
}

.outcome-date-row {
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 8px;
}

.outcome-line-with-date .form-select {
  grid-column: 1 / -1;
}

.outcome-email-row {
  align-items: center;
  display: grid;
  grid-template-columns: minmax(180px, .4fr) minmax(260px, 1fr);
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.outcome-email-row input[type="checkbox"] {
  position: static;
  opacity: 1;
}

.outcome-email-row .action-check {
  margin: 0;
}

.outcome-email-row > input.form-control {
  width: 100%;
}

.outcome-danger input:checked + span { background: #fee2e2; border-color: #ef4444; color: #991b1b; }
.outcome-warning input:checked + span { background: #fff7d6; border-color: #f59e0b; color: #8a4d05; }
.outcome-violet input:checked + span { background: #f1e8ff; border-color: #8b5cf6; color: #5b21b6; }
.outcome-dark input:checked + span { background: #e8edf2; border-color: #475569; color: #253344; }
.outcome-orange input:checked + span { background: #fff0e7; border-color: var(--orange); color: #a34710; }
.outcome-blue input:checked + span { background: #e6f0ff; border-color: #3b82f6; color: #1d4ed8; }
.outcome-green input:checked + span { background: #dcfce7; border-color: #22c55e; color: #166534; }
.outcome-teal input:checked + span { background: #dff8f4; border-color: #14b8a6; color: #0f766e; }

.crm-outcome-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.crm-outcome-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.crm-outcome-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.crm-outcome-pill > input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.crm-outcome-pill > span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 11px;
  border: 2px solid #cfd8e3;
  border-radius: 999px;
  background: #fff;
  color: #0b2138;
  font-weight: 850;
  font-size: .78rem;
  line-height: 1;
  box-shadow: 0 5px 14px rgba(15, 35, 50, .06);
}

.crm-outcome-pill > input[type="radio"]:checked + span {
  background: #0b2138;
  color: #fff;
  box-shadow: 0 8px 20px rgba(15, 35, 50, .18);
}

.crm-outcome-nr_inesistente > span {
  border-color: #6b7280;
}

.crm-outcome-occupato > span {
  border-color: #f59e0b;
}

.crm-outcome-non_risponde > span {
  border-color: #2563eb;
}

.crm-outcome-non_interessato > span,
.crm-outcome-chiudi_negativo_tentativi > span {
  border-color: #dc2626;
}

.crm-outcome-interessato_app > span {
  border-color: #16a34a;
}

.crm-action-row {
  display: grid;
  grid-template-columns: minmax(190px, .8fr) minmax(140px, 1fr) minmax(110px, .7fr);
  gap: 8px;
  align-items: center;
  padding: 9px;
  border: 1px solid #dbe4ee;
  border-radius: 12px;
  background: #f8fafc;
}

.crm-action-row.crm-action-app {
  grid-template-columns: minmax(190px, .8fr) minmax(140px, 1fr) minmax(110px, .7fr) minmax(150px, 1fr);
  border-left: 4px solid #22c55e;
  background: #f3fcf6;
}

/*
 * Etichette principali dei campi che l'operatore deve compilare.
 * Devono essere immediatamente distinguibili dal contenuto.
 */
.crm-operator-field-label {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-bottom: 6px;
  padding: 4px 8px;
  border: 1px solid #b9d4e7;
  border-radius: 6px;
  background: #eaf4fb;
  color: #173f55;
  font-size: .74rem;
  font-weight: 950;
  line-height: 1;
  letter-spacing: .02em;
  text-transform: uppercase;
}

/*
 * Campi Persona / Ruolo / Cellulare / Email.
 */
.crm-contact-fields .form-control {
  border-color: #cbd9e5;
  background: #fff;
}

.crm-contact-fields .form-control:focus {
  border-color: #4d8eaf;
  box-shadow: 0 0 0 .18rem rgba(77,142,175,.14);
}

/*
 * Campi Data / Ora / Tipo dentro il blocco appuntamento.
 */
.crm-app-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
}

.crm-app-field > span {
  color: #52697a;
  font-size: .70rem;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

/*
 * Quando Interessato/app fissato NON è attivo
 * il blocco mantiene l'aspetto secondario attuale.
 */
.crm-action-app.crm-disabled-field .crm-app-field > span {
  color: #71808d;
}

/*
 * Quando l'appuntamento è attivo, rendiamo chiaramente
 * riconoscibile tutta l'area Data / Ora / Tipo.
 */
.crm-action-app.crm-appointment-active {
  border-color: #72d697;
  border-left-color: #16a34a;
  background: #ecfbf2;
  box-shadow: 0 0 0 2px rgba(34,197,94,.08);
}

.crm-action-app.crm-appointment-active .crm-operator-field-label {
  border-color: #5bc984;
  background: #dff7e8;
  color: #0b5b2a;
}

.crm-action-app.crm-appointment-active .crm-app-field > span {
  color: #0b5b2a;
  font-weight: 950;
}

.crm-action-app.crm-appointment-active .form-control,
.crm-action-app.crm-appointment-active .form-select {
  border-color: #8fd9aa;
  background: #fff;
}

.crm-action-app.crm-appointment-active .form-control:focus,
.crm-action-app.crm-appointment-active .form-select:focus {
  border-color: #22a559;
  box-shadow: 0 0 0 .18rem rgba(34,165,89,.14);
}

/*
 * Contenitore Note appuntamento.
 * Quando non è attivo resta visivamente secondario.
 */
.crm-appointment-notes-wrap {
  padding: 10px;
  border: 1px solid #dbe4ee;
  border-left: 4px solid #22c55e;
  border-radius: 10px;
  background: #f8fafc;
  transition: .18s ease;
}

.crm-appointment-notes-wrap .crm-appointment-notes-label {
  margin-bottom: 7px;
}

.crm-appointment-notes-wrap textarea.form-control {
  width: 100%;
}

/*
 * Quando l'appuntamento è attivo, anche le Note appuntamento
 * diventano chiaramente parte della compilazione principale.
 */
.crm-appointment-notes-wrap.crm-appointment-notes-active {
  opacity: 1;
  filter: none;
  border-color: #72d697;
  border-left-color: #16a34a;
  background: #ecfbf2;
  box-shadow: 0 0 0 2px rgba(34,197,94,.08);
}

.crm-appointment-notes-wrap.crm-appointment-notes-active
.crm-appointment-notes-label {
  border-color: #5bc984;
  background: #dff7e8;
  color: #0b5b2a;
}

.crm-appointment-notes-wrap.crm-appointment-notes-active
textarea.form-control {
  border-color: #8fd9aa;
  background: #fff;
}

.crm-appointment-notes-wrap.crm-appointment-notes-active
textarea.form-control:focus {
  border-color: #22a559;
  box-shadow: 0 0 0 .18rem rgba(34,165,89,.14);
}

/*
 * Avviso indirizzo obbligatorio.
 */
.crm-appointment-address-help {
  display: block;
  margin-top: 6px;
  color: #9a4f00;
  font-size: .72rem;
  font-weight: 800;
  line-height: 1.25;
}

/*
 * Note chiamata volutamente più secondarie rispetto
 * ai campi operativi e alle Note appuntamento.
 */
.crm-call-notes-label {
  margin-bottom: -8px;
  color: #6e7c8a;
  font-size: .74rem;
  font-weight: 800;
}

/*
 * =========================================================
 * DETTATURA VOCALE NOTE
 * =========================================================
 *
 * Il contenitore viene creato automaticamente da leads.php
 * soltanto quando il browser supporta il riconoscimento vocale.
 */
.crm-voice-field {
  position: relative;
  width: 100%;
}

/*
 * Lasciamo spazio sulla destra al pulsante del microfono,
 * evitando che il testo venga scritto sotto al comando.
 */
.crm-voice-field > textarea.form-control {
  width: 100%;
  padding-right: 88px;
}

/*
 * Pulsante microfono integrato nel campo note.
 */
.crm-voice-button {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;

  min-width: 68px;
  height: 32px;
  padding: 5px 9px;

  border: 1px solid #b8c8d5;
  border-radius: 7px;

  background: #fff;
  color: #29465b;

  font-family: inherit;
  font-size: .70rem;
  font-weight: 850;
  line-height: 1;

  cursor: pointer;

  box-shadow: 0 2px 7px rgba(36,56,74,.10);

  transition:
    background .15s ease,
    border-color .15s ease,
    color .15s ease,
    box-shadow .15s ease,
    transform .15s ease;
}

.crm-voice-button svg {
  display: block;
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
}

.crm-voice-button:hover:not(:disabled) {
  border-color: #29465b;
  background: #eef4f8;
  color: #1f3546;
  box-shadow: 0 3px 10px rgba(36,56,74,.14);
}

.crm-voice-button:focus-visible {
  outline: 0;
  border-color: #29465b;
  box-shadow:
    0 0 0 .18rem rgba(41,70,91,.16),
    0 3px 10px rgba(36,56,74,.12);
}

/*
 * Campo disattivato:
 * anche il microfono viene reso chiaramente non utilizzabile.
 */
.crm-voice-button:disabled {
  opacity: .45;
  cursor: not-allowed;
  box-shadow: none;
}

/*
 * Registrazione in corso.
 *
 * Rosso evidente per evitare che l'operatore dimentichi
 * il microfono acceso.
 */
.crm-voice-button.is-recording {
  border-color: #dc2626;
  background: #dc2626;
  color: #fff;

  box-shadow:
    0 0 0 0 rgba(220,38,38,.38);

  animation:
    crmVoiceRecordingPulse 1.35s infinite;
}

.crm-voice-button.is-recording:hover {
  border-color: #b91c1c;
  background: #b91c1c;
  color: #fff;
}

/*
 * Piccolo impulso visivo durante l'ascolto.
 */
@keyframes crmVoiceRecordingPulse {
  0% {
    box-shadow:
      0 0 0 0 rgba(220,38,38,.38);
  }

  65% {
    box-shadow:
      0 0 0 7px rgba(220,38,38,0);
  }

  100% {
    box-shadow:
      0 0 0 0 rgba(220,38,38,0);
  }
}

.crm-action-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #0b2138;
  font-weight: 850;
  white-space: nowrap;
}

.crm-action-check input {
  width: 16px;
  height: 16px;
}

.crm-action-recall {
  border-left: 4px solid #7c3aed;
}

.crm-action-reminder {
  border-left: 4px solid #16a34a;
  background: #f3fcf6;
}

.crm-disabled-field{
  opacity:.45;
  filter:grayscale(.25);
  transition:.18s ease;
}

.crm-disabled-field input,
.crm-disabled-field select,
.crm-disabled-field textarea{
  cursor:not-allowed;
}

.crm-disabled-field textarea{
  display:none;
}

.crm-disabled-field .form-control,
.crm-disabled-field .form-select{
  background:#eef2f6;
}

.crm-action-row,
.crm-email-compact,
textarea.form-control{
  transition:.18s ease;
}
 	
.crm-email-compact {
  display: grid;
  grid-template-columns: minmax(190px, .8fr) minmax(220px, 1fr);
  gap: 8px;
  align-items: center;
  padding: 9px;
  border: 1px solid #dbe4ee;
  border-left: 4px solid var(--blue);
  border-radius: 12px;
  background: #fff;
}

.crm-edit-section-title {
  color: var(--muted);
  font-size: .76rem;
  font-weight: 950;
  margin: 2px 0 -3px;
  text-transform: uppercase;
}

.edit-call-compact {
  max-width: 980px;
}

.edit-call-compact .form-control,
.edit-call-compact .form-select {
  min-height: 36px;
  font-size: .86rem;
}

.edit-call-compact textarea.form-control {
  min-height: auto;
}

.quick-actions {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 10px;
}

.quick-box {
  background: #fff;
  border: 1px solid #e1e8ef;
  border-radius: 8px;
  padding: 9px;
}

.quick-box .form-label {
  font-size: .84rem;
  font-weight: 850;
  margin-bottom: 6px;
}

.quick-box .form-control,
.quick-box .form-select {
  font-size: .86rem;
}

.quick-box small {
  color: var(--muted);
  display: block;
  font-size: .76rem;
  margin-top: 5px;
}

.close-negative {
  align-items: flex-start;
  display: flex;
  gap: 8px;
  font-size: .86rem;
  font-weight: 800;
}

.action-check {
  align-items: center;
  display: flex;
  gap: 7px;
}

.timeline-item {
  border-left: 3px solid var(--orange);
  padding-left: 14px;
  margin-bottom: 18px;
}

.timeline-head {
  align-items: flex-start;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.timeline-actions {
  display: inline-flex;
  gap: 5px;
}

.timeline-actions form {
  display: inline;
}

.crm-timeline-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.crm-timeline-call-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.crm-timeline-call-head strong {
  font-size: .98rem;
  font-weight: 900;
  color: var(--ink);
}

.crm-timeline-call-head span {
  display: inline-flex;
  width: auto;
  margin: 0;
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
}

.crm-outcome-readonly {
  display: inline-flex;
  cursor: default;
  pointer-events: none;
}

.crm-outcome-readonly > span {
  min-height: 28px;
  padding: 5px 10px;
}

.crm-outcome-readonly input {
  display: none;
}

.btn-xs {
  border-radius: 5px;
  font-size: .7rem;
  line-height: 1.1;
  padding: 4px 7px;
}

.timeline-item span {
  display: block;
  color: var(--muted);
  font-size: .85rem;
  margin: 3px 0 6px;
}

.timeline-item em {
  background: #f8fafc;
  border-radius: 999px;
  color: var(--blue);
  display: inline-block;
  font-size: .78rem;
  font-style: normal;
  font-weight: 800;
  margin: 0 6px 6px 0;
  padding: 3px 8px;
}

.crm-note-details{
  margin-top:6px;
  border:1px solid #dce4eb;
  border-radius:8px;
  background:#fafcff;
  overflow:hidden;
}

.crm-note-details + .crm-note-details{
  margin-top:5px;
}

.crm-note-details summary{
  cursor:pointer;
  list-style:none;
  padding:6px 9px !important;
  font-size:.78rem;
  line-height:1.2;
  font-weight:850;
  color:var(--blue);
  user-select:none;
}

.crm-note-details summary::-webkit-details-marker{
  display:none;
}

.crm-note-details summary::before{
  content:"▸";
  display:inline-block;
  width:14px;
  color:var(--orange);
  font-weight:900;
}

.crm-note-details[open] summary::before{
  content:"▾";
}

.crm-note-details summary:hover{
  background:#f4f8fc;
}

/*
 * IMPORTANTE:
 * non applicare padding e white-space a tutti i DIV annidati.
 * Lo storico appuntamento contiene diversi div interni e la vecchia
 * regola generava spazi verticali enormi.
 */
.crm-note-details > div{
  padding:6px 8px 8px !important;
  font-size:.78rem;
  line-height:1.25;
  color:var(--ink);
  white-space:normal !important;
}

/*
 * Tutti i DIV interni allo storico devono restare compatti.
 */
.crm-note-details > div div{
  white-space:normal !important;
}

/*
 * Contenitore elenco eventi dello storico appuntamento.
 * Sovrascrive i gap/padding inline presenti in leads.php.
 */
.crm-note-details > div[style*="flex-direction:column"]{
  gap:5px !important;
  padding:6px !important;
}

/*
 * Singola scheda evento.
 */
.crm-note-details > div[style*="flex-direction:column"] > div{
  padding:6px 8px !important;
  border-radius:6px !important;
}

/*
 * Testata data/ora + operatore.
 * Deve stare tutta sulla stessa riga, senza spreco verticale.
 */
.crm-note-details > div[style*="flex-direction:column"] > div > div:first-child{
  display:flex !important;
  flex-direction:row !important;
  flex-wrap:wrap !important;
  align-items:center !important;
  gap:5px !important;
  margin:0 0 5px !important;
  padding:0 0 5px !important;
  line-height:1.15 !important;
}

/*
 * Data/ora e operatore compatti.
 */
.crm-note-details > div[style*="flex-direction:column"] > div > div:first-child strong,
.crm-note-details > div[style*="flex-direction:column"] > div > div:first-child span{
  display:inline !important;
  width:auto !important;
  margin:0 !important;
  padding:0 !important;
  font-size:.76rem !important;
  line-height:1.15 !important;
}

/*
 * Le righe Stato / Data / Tipo / Note generate dalla funzione PHP
 * diventano compatte e non occupano righe enormi.
 */
.crm-note-details
> div[style*="flex-direction:column"]
> div
> div:not(:first-child)
> div{
  min-height:0 !important;
}

/*
 * Etichetta + variazione sulla stessa riga.
 */
.crm-note-details
> div[style*="flex-direction:column"]
> div
> div:not(:first-child)
> div[style*="display:grid"]{
  grid-template-columns:60px minmax(0,1fr) !important;
  gap:6px !important;
  align-items:center !important;
  padding:4px 0 !important;
}

/*
 * Badge vecchio valore / nuovo valore.
 */
.crm-note-details
> div[style*="flex-direction:column"]
> div
span[style*="border-radius:8px"]{
  display:inline-flex !important;
  align-items:center !important;
  width:auto !important;
  margin:0 !important;
  padding:3px 6px !important;
  font-size:.73rem !important;
  line-height:1.1 !important;
}

/*
 * Freccia fra valore precedente e nuovo.
 */
.crm-note-details
> div[style*="flex-direction:column"]
> div
span[style*="color:#c96b00"]{
  display:inline !important;
  width:auto !important;
  margin:0 2px !important;
}

/*
 * I normali blocchi Note appuntamento / Note telefonata
 * mantengono invece gli a-capo digitati dall'operatore.
 */
.crm-note-details:not([style*="border:1px solid #f0b36c"]) > div{
  white-space:pre-wrap !important;
}

.duplicate-row,
.check-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.duplicate-row span,
.duplicate-row small {
  display: block;
  color: var(--muted);
}

.check-row {
  justify-content: flex-start;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.empty-state {
  background: #fff;
  border: 1px dashed #b8c4ce;
  border-radius: 8px;
  padding: 28px;
  color: var(--muted);
}

.hint {
  background: var(--soft-blue);
  border: 1px solid #ccdcea;
  border-radius: 8px;
  color: #35566f;
  padding: 12px;
  font-size: .92rem;
}

.nav-reminder-alert {
  position: relative;
  animation: crmReminderBlink 1s infinite;
  color: #111 !important;
}

.nav-reminder-alert:hover,
.nav-reminder-alert:focus,
.nav-reminder-alert:active {
  color: #111 !important;
}

.nav-reminder-alert .nav-reminder-badge {
  color: #fff !important;
}

.nav-reminder-badge {
  align-items: center;
  background: #ef4444;
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  font-size: .68rem;
  font-weight: 900;
  justify-content: center;
  line-height: 1;
  margin-left: 6px;
  min-width: 18px;
  padding: 3px 6px;
}

.reminder-campaign-tabs b {
  background: #ef4444;
  color: #fff;
}

.reminder-table {
  table-layout: fixed;
}

.reminder-table th:nth-child(1),
.reminder-table td:nth-child(1) {
  width: 130px;
}

.reminder-table th:nth-child(2),
.reminder-table td:nth-child(2) {
  width: 150px;
}

.reminder-table th:nth-child(3),
.reminder-table td:nth-child(3) {
  width: 140px;
}

.reminder-table th:nth-child(6),
.reminder-table td:nth-child(6) {
  width: 130px;
}

.reminder-table th:nth-child(7),
.reminder-table td:nth-child(7) {
  width: 150px;
}

.reminder-table th:nth-child(8),
.reminder-table td:nth-child(8) {
  width: 150px;
}

/* ============================================================
   EMAIL DA INVIARE / INVIATE / STATISTICHE
   ============================================================ */

.reminder-call-link {
  color: var(--blue);
  display: inline-flex;
  align-items: center;
  font-weight: 850;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}

.reminder-call-link:hover {
  color: var(--orange);
  text-decoration: underline;
}

.reminder-date-cell {
  white-space: nowrap;
}

.reminder-action-cell {
  align-items: center !important;
  display: table-cell !important;
  vertical-align: middle !important;
}

.reminder-action-cell form {
  display: inline-flex;
  margin: 0;
}

.reminder-action-cell .btn {
  min-width: 118px;
  padding: 8px 10px;
  white-space: nowrap;
}


/* TABELLA EMAIL */

.email-task-table {
  table-layout: fixed;
  width: 100%;
}

/* Stato */
.email-task-table th:nth-child(1),
.email-task-table td:nth-child(1) {
  width: 105px;
}

/* Campagna */
.email-task-table th:nth-child(2),
.email-task-table td:nth-child(2) {
  width: 135px;
}

/* Azienda */
.email-task-table th:nth-child(3),
.email-task-table td:nth-child(3) {
  width: 135px;
}

/* Persona */
.email-task-table th:nth-child(4),
.email-task-table td:nth-child(4) {
  width: 110px;
}

/* Telefono */
.email-task-table th:nth-child(5),
.email-task-table td:nth-child(5) {
  width: 125px;
}

/* Email */
.email-task-table th:nth-child(6),
.email-task-table td:nth-child(6) {
  width: 205px;
}

/* Invio */
.email-task-table th:nth-child(7),
.email-task-table td:nth-child(7) {
  width: 135px;
}

/* Azioni */
.email-task-table th:nth-child(8),
.email-task-table td:nth-child(8) {
  width: 215px;
}

.email-task-address {
  min-width: 0;
}

.email-task-address a {
  display: inline-block;
  max-width: 185px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

.email-task-table td:nth-child(7) {
  white-space: nowrap;
}

.email-task-table td:nth-child(7) small {
  display: block;
  margin-top: 3px;
}


/* BOTTONE / ICONA STATISTICHE */

.email-task-table .btn-outline-primary svg,
.panel .btn-outline-primary svg {
  display: inline-block;
  flex: 0 0 auto;
  vertical-align: -3px;
}

/* Statistiche generali */
.email-stats-main-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-left: 6px;
  padding: 9px 14px;
  background: var(--orange) !important;
  border-color: var(--orange) !important;
  color: #fff !important;
  font-weight: 850;
  white-space: nowrap;
  vertical-align: middle;
}

.email-stats-main-btn svg {
  width: 17px;
  height: 17px;
  stroke: #fff;
  stroke-width: 2.5;
}

.email-stats-main-btn:hover,
.email-stats-main-btn:focus {
  background: #e86f00 !important;
  border-color: #e86f00 !important;
  color: #fff !important;
}

/* Mantiene Statistiche, Cerca e Reset sulla stessa riga */
.filter-panel .col-md-3.text-md-end {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  flex-wrap: nowrap;
  width: auto;
  max-width: none;
  flex: 0 0 auto;
  margin-left: auto;
}

.filter-panel .col-md-3.text-md-end .btn {
  flex: 0 0 auto;
  margin: 0;
  white-space: nowrap;
}

/* Statistiche deve stare prima di Cerca e Reset */
.filter-panel .email-stats-main-btn {
  order: -1;
}

/* Statistiche singola email */
.email-task-table .email-tracking-btn {
  align-items: center;
  justify-content: center;
  min-width: 40px;
  width: 40px;
  height: 36px;
  padding: 0;
  background: #0d6efd;
  border: 2px solid #0759d5;
  color: #fff;
  box-shadow: 0 2px 7px rgba(13, 110, 253, .28);
}

.email-task-table .email-tracking-btn svg {
  width: 18px;
  height: 18px;
  stroke: #fff;
  stroke-width: 2.5;
}

.email-task-table .email-tracking-btn:hover,
.email-task-table .email-tracking-btn:focus {
  background: #0759d5;
  border-color: #064db8;
  color: #fff;
  box-shadow: 0 3px 9px rgba(13, 110, 253, .38);
}


/* RIEPILOGO STATISTICHE */

.email-stats-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.email-stats-card {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.email-stats-card small {
  color: var(--muted);
  display: block;
  font-size: .75rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.email-stats-card strong {
  color: var(--ink);
  display: block;
  font-size: 1.65rem;
  font-weight: 900;
  line-height: 1;
}


/* MODALE STATISTICHE EMAIL */

.modal[id^="emailStatsModal"] .modal-content,
.modal[id^="emailStatsMessageModal"] .modal-content {
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(36, 56, 74, .18);
}

.modal[id^="emailStatsModal"] .modal-header,
.modal[id^="emailStatsMessageModal"] .modal-header {
  background: #f8fafc;
  border-bottom-color: var(--line);
}

.modal[id^="emailStatsModal"] .modal-footer,
.modal[id^="emailStatsMessageModal"] .modal-footer {
  background: #f8fafc;
  border-top-color: var(--line);
}

.modal[id^="emailStatsModal"] .modal-body .vstack > .border,
.modal[id^="emailStatsMessageModal"] .modal-body .vstack > .border {
  background: #fff;
  border-color: var(--line) !important;
}

.modal[id^="emailStatsModal"] .modal-body .vstack > .border strong,
.modal[id^="emailStatsMessageModal"] .modal-body .vstack > .border strong {
  color: var(--blue);
}

.modal[id^="emailStatsModal"] .modal-body .vstack > .border a,
.modal[id^="emailStatsMessageModal"] .modal-body .vstack > .border a {
  overflow-wrap: anywhere;
  word-break: break-word;
}


/* RESPONSIVE EMAIL */

@media (max-width: 900px) {

  .email-stats-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mobile-lead-card .mobile-actions .btn-outline-primary {
    align-items: center;
    display: inline-flex;
    gap: 6px;
  }

  .modal[id^="emailStatsModal"] .modal-dialog,
  .modal[id^="emailStatsMessageModal"] .modal-dialog {
    margin: 12px;
  }

  .modal[id^="emailStatsModal"] .modal-body,
  .modal[id^="emailStatsMessageModal"] .modal-body {
    padding: 14px;
  }
}

@media (max-width: 560px) {

  .email-stats-summary {
    grid-template-columns: 1fr;
  }

  .modal[id^="emailStatsModal"] .modal-dialog,
  .modal[id^="emailStatsMessageModal"] .modal-dialog {
    margin: 8px;
  }

  .modal[id^="emailStatsModal"] .modal-header,
  .modal[id^="emailStatsModal"] .modal-body,
  .modal[id^="emailStatsModal"] .modal-footer,
  .modal[id^="emailStatsMessageModal"] .modal-header,
  .modal[id^="emailStatsMessageModal"] .modal-body,
  .modal[id^="emailStatsMessageModal"] .modal-footer {
    padding: 12px;
  }
}

@keyframes crmReminderBlink {
  0% {
    background: #fff;
    border-color: #111;
    transform: scale(1);
  }

  50% {
    background: #ffd9d9;
    border-color: #ef4444;
    transform: scale(1.04);
  }

  100% {
    background: #fff;
    border-color: #111;
    transform: scale(1);
  }
}

@media (max-width: 1200px) {
  .panel .table td.text-end.btn-row {
    min-width: 240px;
  }

  .panel .table td .btn,
  .panel .table td.text-end.btn-row .btn {
    font-size: .72rem;
    padding: 5px 7px;
  }
}

@media (max-width: 900px) {
  .app-shell {
    padding-top: 22px;
  }

  .app-navbar-top {
    align-items: center;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
  }

  .navbar-brand {
    justify-self: start;
  }

  .app-navbar-user {
    grid-column: 1 / -1;
    justify-content: center;
    margin-left: 0;
    order: 2;
    width: 100%;
  }

  .app-navbar-user .navbar-toggler {
    margin-left: 10px;
  }

  .app-navbar-bottom .navbar-collapse.show {
    justify-content: center;
    width: 100%;
  }

  .app-navbar-bottom .navbar-collapse:not(.show) {
    display: none !important;
  }

  .app-navbar-bottom .navbar-nav {
    align-items: center;
    justify-content: center;
    width: 100%;
  }

  .app-navbar-bottom .nav-item {
    display: flex;
    justify-content: center;
    width: 100%;
  }

  .app-navbar-bottom .nav-link {
    min-width: 220px;
  }

  .app-shell {
    padding: 22px 18px 18px;
  }

  .workbench-search-inline {
    width: 100%;
    min-width: 0;
    flex-wrap: wrap;
  }

  .workbench-search-inline .form-control {
    min-width: 0;
    width: 100%;
  }

  .advanced-search-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-grid,
  .metric-grid.small {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-list {
    grid-template-columns: 1fr;
  }

  .call-workspace {
    grid-template-columns: 1fr;
  }

  .crm-action-row,
  .crm-action-row.crm-action-app,
  .crm-email-compact {
    grid-template-columns: 1fr 1fr;
  }

  .crm-action-row .crm-action-check,
  .crm-email-compact .crm-action-check {
    grid-column: 1 / -1;
  }

  /*
   * Nuova struttura Appuntamento:
   * APPUNTAMENTO su tutta la riga,
   * Data e Ora affiancate,
   * Tipo su tutta la riga.
   */
  .crm-action-row.crm-action-app .crm-operator-field-label {
    grid-column: 1 / -1;
  }

  .crm-action-row.crm-action-app .crm-app-field {
    min-width: 0;
  }

  .crm-action-row.crm-action-app .crm-app-field:nth-of-type(3) {
    grid-column: 1 / -1;
  }

  .crm-action-row.crm-action-app .crm-app-field .form-control,
  .crm-action-row.crm-action-app .crm-app-field .form-select {
    width: 100%;
    min-width: 0;
  }

  .crm-contact-fields .col-md-6 {
    min-width: 0;
  }

  .crm-appointment-notes-wrap {
    width: 100%;
  }

  .desktop-leads {
    display: none;
  }

  .mobile-leads {
    display: block;
  }

  .table-responsive {
    overflow-x: visible;
  }
}

@media (max-width: 560px) {
  .login-card {
    padding: 24px;
  }

  .metric-grid,
  .metric-grid.small {
    grid-template-columns: 1fr;
  }

  .duplicate-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .outcome-grid {
    grid-template-columns: 1fr;
  }

  .advanced-search-row {
    grid-template-columns: 1fr;
  }
}

.crm-hours-warning {
    color: #f97316 !important;
    font-weight: 700;
}

.crm-hours-danger {
    color: #dc2626 !important;
    font-weight: 800;
}

.crm-alert-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    margin-left: 6px;
    border-radius: 999px;
    vertical-align: middle;
    animation: crmAlertBlink 0.9s infinite;
}

.crm-alert-dot-orange {
    background: #f97316;
    box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.65);
}

.crm-alert-dot-red {
    background: #dc2626;
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.75);
}

@keyframes crmAlertBlink {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.25;
        transform: scale(1.35);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================================
   SCRIPT CAMPAGNE
   ============================================================ */

.campaign-script-table {
    table-layout: fixed;
    width: 100%;
}

.campaign-script-table th:nth-child(1),
.campaign-script-table td:nth-child(1) {
    width: 18%;
}

.campaign-script-table th:nth-child(2),
.campaign-script-table td:nth-child(2) {
    width: 22%;
}

.campaign-script-table th:nth-child(3),
.campaign-script-table td:nth-child(3) {
    width: 110px;
}

.campaign-script-table th:nth-child(4),
.campaign-script-table td:nth-child(4) {
    width: auto;
}

.campaign-script-table th:nth-child(5),
.campaign-script-table td:nth-child(5) {
    width: 190px;
}

.campaign-script-association-row > td {
    background: #f8fafc;
    border-top: 0;
    padding: 14px 18px !important;
}

.campaign-script-association-form {
    align-items: end;
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(260px, 1fr) auto;
}

.campaign-script-association-form .form-label {
    color: var(--muted);
    font-size: .78rem;
    font-weight: 900;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.campaign-script-association-form .btn {
    min-height: 38px;
    white-space: nowrap;
}

@media (max-width: 900px) {
    .campaign-script-table {
        min-width: 850px;
    }

    .campaign-script-association-form {
        align-items: stretch;
        grid-template-columns: 1fr;
    }

    .campaign-script-association-form .btn {
        width: 100%;
    }
}

/* ============================================================
   MULTISELECT CRM
   ============================================================ */

.crm-multiselect-control {
    position: relative;
    width: 100%;
}

.crm-multiselect-native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.crm-multiselect-selection {
    align-items: center;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    cursor: text;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-height: 38px;
    padding: 5px 9px;
    transition:
        border-color .15s ease-in-out,
        box-shadow .15s ease-in-out;
    width: 100%;
}

.crm-multiselect-control.is-open .crm-multiselect-selection {
    border-color: #86b7fe;
    box-shadow: 0 0 0 .25rem rgba(13, 110, 253, .25);
}

.crm-multiselect-tags {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-width: 0;
}

.crm-multiselect-tag {
    align-items: center;
    background: var(--soft-blue);
    border: 1px solid #c8d9e6;
    border-radius: 999px;
    color: var(--blue);
    display: inline-flex;
    font-size: .72rem;
    font-weight: 800;
    gap: 4px;
    line-height: 1;
    max-width: 100%;
    min-height: 25px;
    padding: 4px 5px 4px 8px;
}

.crm-multiselect-tag-label {
    display: block;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-multiselect-tag-remove {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 999px;
    color: var(--blue);
    cursor: pointer;
    display: inline-flex;
    flex: 0 0 18px;
    font-size: 1rem;
    font-weight: 900;
    height: 18px;
    justify-content: center;
    line-height: 1;
    margin: 0;
    padding: 0;
    width: 18px;
}

.crm-multiselect-tag-remove:hover,
.crm-multiselect-tag-remove:focus {
    background: rgba(41, 70, 91, .13);
    color: #111;
    outline: none;
}

.crm-multiselect-search {
    background: transparent;
    border: 0;
    box-shadow: none;
    color: var(--ink);
    flex: 1 1 90px;
    font-size: .88rem;
    line-height: 1.35;
    min-width: 75px;
    outline: none;
    padding: 3px 1px;
}

.crm-multiselect-search::placeholder {
    color: #6c757d;
    opacity: 1;
}

.crm-multiselect-control.has-values .crm-multiselect-search {
    min-width: 70px;
}

.crm-multiselect-dropdown {
    background: #fff;
    border: 1px solid #cfd8e3;
    border-radius: 7px;
    box-shadow: 0 14px 34px rgba(36, 56, 74, .18);
    left: 0;
    margin-top: 4px;
    max-height: 260px;
    overflow-y: auto;
    padding: 5px;
    position: absolute;
    right: 0;
    top: 100%;
    z-index: 1060;
}

.crm-multiselect-dropdown[hidden] {
    display: none !important;
}

.crm-multiselect-options {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.crm-multiselect-option {
    background: #fff;
    border: 0;
    border-radius: 5px;
    color: var(--ink);
    cursor: pointer;
    display: block;
    font-size: .82rem;
    line-height: 1.25;
    padding: 8px 9px;
    text-align: left;
    width: 100%;
}

.crm-multiselect-option:hover,
.crm-multiselect-option:focus {
    background: var(--soft-blue);
    color: var(--blue);
    outline: none;
}

.crm-multiselect-empty {
    color: var(--muted);
    font-size: .8rem;
    padding: 10px;
    text-align: center;
}

.crm-multiselect-control select:disabled
    + .crm-multiselect-selection {
    background: #e9ecef;
    cursor: not-allowed;
    opacity: .7;
}

@media (max-width: 900px) {
    .crm-multiselect-dropdown {
        max-height: 220px;
    }

    .crm-multiselect-tag-label {
        max-width: 150px;
    }
}

@media (max-width: 560px) {
    .crm-multiselect-selection {
        min-height: 42px;
    }

    .crm-multiselect-tag-label {
        max-width: 115px;
    }

    .crm-multiselect-dropdown {
        max-height: 200px;
    }
}

/* ============================================================
   ARCHIVIO MEDIACOM
   ============================================================ */

.mediacom-table{
    table-layout:fixed;
    width:100%;
}

/* ID / selezione */
.mediacom-table th:nth-child(1),
.mediacom-table td:nth-child(1){
    width:70px;
}

/* Azienda */
.mediacom-table th:nth-child(2),
.mediacom-table td:nth-child(2){
    width:260px;
}

/* Categoria */
.mediacom-table th:nth-child(3),
.mediacom-table td:nth-child(3){
    width:210px;
}

/* CAP */
.mediacom-table th:nth-child(4),
.mediacom-table td:nth-child(4){
    width:70px;
}

/* Località */
.mediacom-table th:nth-child(5),
.mediacom-table td:nth-child(5){
    width:115px;
}

/* Provincia */
.mediacom-table th:nth-child(6),
.mediacom-table td:nth-child(6){
    width:70px;
}

/* Telefono */
.mediacom-table th:nth-child(7),
.mediacom-table td:nth-child(7){
    width:100px;
}

/* Email / sito */
.mediacom-table th:nth-child(8),
.mediacom-table td:nth-child(8){
    width:190px;
}

.mediacom-table td:nth-child(8) a{
    display:inline-block;
    max-width:180px;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}

/* Utilizzi */
.mediacom-table th:nth-child(9),
.mediacom-table td:nth-child(9){
    width:70px;
    text-align:center;
}

/* Azioni */
.mediacom-table th:nth-child(10),
.mediacom-table td:nth-child(10){
    width:135px;
    white-space:nowrap;
}

.mediacom-table td:nth-child(10){
    text-align:right;
}

.mediacom-table td:nth-child(10) .btn{
    margin-left:4px;
}

/* Ultima modifica */
.mediacom-table th:nth-child(11),
.mediacom-table td:nth-child(11){
    width:105px;
    white-space:nowrap;
}


/* ============================================================
   ASSEGNA AZIENDE MEDIACOM
   Override limitati esclusivamente alla pagina di assegnazione.
   L'Archivio Mediacom mantiene le misure originali sopra.
   ============================================================ */

/*
 * Il form #mediacom-assign-form esiste esclusivamente nella pagina
 * "Assegna aziende" ed è immediatamente precedente al pannello
 * contenente la tabella.
 *
 * In questo modo non servono modifiche HTML aggiuntive e le regole
 * sottostanti non alterano l'Archivio Mediacom generale.
 */

#mediacom-assign-form ~ .panel .table-responsive{
    width:100%;
    max-width:100%;
    overflow-x:hidden;
}

/*
 * La tabella deve sempre occupare esclusivamente lo spazio
 * disponibile nel pannello.
 */
#mediacom-assign-form ~ .panel .mediacom-table{
    table-layout:fixed;
    width:100%;
    min-width:0;
    margin-bottom:0;
    font-size:.78rem;
}

/*
 * Permette ai contenuti di andare a capo invece di creare
 * scroll orizzontale.
 */
#mediacom-assign-form ~ .panel .mediacom-table th,
#mediacom-assign-form ~ .panel .mediacom-table td{
    min-width:0 !important;
    max-width:none;
    padding:.55rem .45rem;
    vertical-align:middle;
    overflow-wrap:anywhere;
    word-break:normal;
}

/* ============================================================
   NUOVA STRUTTURA 9 COLONNE
   ============================================================ */

/* 1 - Checkbox */
#mediacom-assign-form ~ .panel .mediacom-table th:nth-child(1),
#mediacom-assign-form ~ .panel .mediacom-table td:nth-child(1){
    width:4% !important;
    text-align:center;
}

/* 2 - Azienda */
#mediacom-assign-form ~ .panel .mediacom-table th:nth-child(2),
#mediacom-assign-form ~ .panel .mediacom-table td:nth-child(2){
    width:20% !important;
}

/* 3 - Categoria */
#mediacom-assign-form ~ .panel .mediacom-table th:nth-child(3),
#mediacom-assign-form ~ .panel .mediacom-table td:nth-child(3){
    width:16% !important;
}

/* 4 - Sede */
#mediacom-assign-form ~ .panel .mediacom-table th:nth-child(4),
#mediacom-assign-form ~ .panel .mediacom-table td:nth-child(4){
    width:10% !important;
}

/* 5 - Telefono */
#mediacom-assign-form ~ .panel .mediacom-table th:nth-child(5),
#mediacom-assign-form ~ .panel .mediacom-table td:nth-child(5){
    width:9% !important;
}

/* 6 - Email / sito */
#mediacom-assign-form ~ .panel .mediacom-table th:nth-child(6),
#mediacom-assign-form ~ .panel .mediacom-table td:nth-child(6){
    width:11% !important;
}

/*
 * Email e sito possono andare a capo senza allargare la tabella.
 */
#mediacom-assign-form ~ .panel .mediacom-table td:nth-child(6) a{
    display:inline;
    max-width:none;
    overflow:visible;
    text-overflow:clip;
    white-space:normal;
    overflow-wrap:anywhere;
}

/* 7 - Utilizzi */
#mediacom-assign-form ~ .panel .mediacom-table th:nth-child(7),
#mediacom-assign-form ~ .panel .mediacom-table td:nth-child(7){
    width:18% !important;
    text-align:left;
}

/*
 * Utilizzi è volutamente la colonna più larga:
 * deve contenere badge, campagna e operatore senza comprimere
 * eccessivamente il testo.
 */
#mediacom-assign-form ~ .panel .mediacom-table td:nth-child(7) .badge{
    white-space:normal;
    line-height:1.2;
    text-align:left;
}

#mediacom-assign-form ~ .panel .mediacom-table td:nth-child(7) strong,
#mediacom-assign-form ~ .panel .mediacom-table td:nth-child(7) small,
#mediacom-assign-form ~ .panel .mediacom-table td:nth-child(7) a{
    overflow-wrap:anywhere;
}

/* 8 - Azioni */
#mediacom-assign-form ~ .panel .mediacom-table th:nth-child(8),
#mediacom-assign-form ~ .panel .mediacom-table td:nth-child(8){
    width:8% !important;
    white-space:normal;
}

/*
 * Bottoni più larghi e leggibili.
 */
#mediacom-assign-form ~ .panel .mediacom-table td:nth-child(8) .btn-row{
    align-items:stretch;
    display:flex;
    flex-direction:column;
    gap:6px;
    justify-content:center;
}

#mediacom-assign-form ~ .panel .mediacom-table td:nth-child(8) .btn{
    width:100%;
    margin-left:0;
    padding:.36rem .45rem;
    font-size:.72rem;
    white-space:normal;
}

/* 9 - Ultima modifica */
#mediacom-assign-form ~ .panel .mediacom-table th:nth-child(9),
#mediacom-assign-form ~ .panel .mediacom-table td:nth-child(9){
    width:4% !important;
    white-space:normal;
    font-size:.68rem;
    text-align:center;
}

/*
 * Testi secondari.
 */
#mediacom-assign-form ~ .panel .mediacom-table small{
    font-size:.69rem;
    line-height:1.28;
}

/*
 * Tablet e notebook piccoli.
 */
@media (max-width:1100px){

    #mediacom-assign-form ~ .panel .mediacom-table{
        font-size:.73rem;
    }

    #mediacom-assign-form ~ .panel .mediacom-table th,
    #mediacom-assign-form ~ .panel .mediacom-table td{
        padding:.48rem .34rem;
    }

    #mediacom-assign-form ~ .panel .mediacom-table td:nth-child(8) .btn{
        font-size:.68rem;
        padding:.30rem .32rem;
    }

    #mediacom-assign-form ~ .panel .mediacom-table th:nth-child(9),
    #mediacom-assign-form ~ .panel .mediacom-table td:nth-child(9){
        font-size:.63rem;
    }
}


/* ============================================================
   MESSAGGI CLIENTE / OPERATORE
   ============================================================ */

.messages-filters {
    display: grid;
    grid-template-columns: minmax(220px, 1.5fr) minmax(180px, 1fr) minmax(180px, 1fr) auto;
    gap: 10px;
    align-items: end;
}

.messages-filters .form-control,
.messages-filters .form-select,
.messages-filters .btn {
    min-height: 40px;
}

.messages-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message-thread {
    display: block;
    background: #fff;
    border: 1px solid var(--line);
    border-left: 4px solid #cbd5df;
    border-radius: 8px;
    color: var(--ink);
    padding: 14px 16px;
    text-decoration: none;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.message-thread:hover {
    border-color: #b8c8d5;
    border-left-color: var(--blue);
    box-shadow: 0 8px 22px rgba(36, 56, 74, .08);
    color: var(--ink);
    transform: translateY(-1px);
}

.message-thread.is-unread {
    background: #f4f9fd;
    border-left-color: var(--orange);
}

.message-thread-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.message-thread-title {
    min-width: 0;
}

.message-thread-title strong {
    display: block;
    color: var(--ink);
    font-size: .94rem;
    font-weight: 900;
    line-height: 1.3;
}

.message-thread.is-unread .message-thread-title strong {
    color: var(--blue);
}

.message-thread-meta {
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    font-size: .76rem;
    gap: 5px 12px;
    margin-top: 5px;
}

.message-thread-date {
    color: var(--muted);
    flex: 0 0 auto;
    font-size: .76rem;
    font-weight: 750;
    text-align: right;
    white-space: nowrap;
}

.message-thread-preview {
    color: #536575;
    font-size: .84rem;
    line-height: 1.45;
    margin-top: 9px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-thread.is-unread .message-thread-preview {
    color: var(--ink);
    font-weight: 700;
}

.message-unread-badge {
    align-items: center;
    background: #ef4444;
    border-radius: 999px;
    color: #fff;
    display: inline-flex;
    font-size: .68rem;
    font-weight: 900;
    justify-content: center;
    line-height: 1;
    margin-left: 6px;
    min-width: 19px;
    padding: 4px 6px;
}

.message-conversation {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message-bubble {
    background: #f7f9fb;
    border: 1px solid var(--line);
    border-radius: 9px;
    max-width: 82%;
    padding: 12px 14px;
}

.message-bubble.is-own {
    align-self: flex-end;
    background: var(--soft-blue);
    border-color: #cbdde9;
}

.message-bubble.is-other {
    align-self: flex-start;
}

.message-bubble-head {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    justify-content: space-between;
    margin-bottom: 7px;
}

.message-bubble-author {
    color: var(--blue);
    font-size: .82rem;
    font-weight: 900;
}

.message-bubble-date {
    color: var(--muted);
    font-size: .72rem;
    font-weight: 700;
    white-space: nowrap;
}

.message-bubble-body {
    color: var(--ink);
    font-size: .88rem;
    line-height: 1.55;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.message-contact-box {
    background: #fff8ed;
    border: 1px solid #ffd4a8;
    border-radius: 7px;
    color: #744114;
    font-size: .78rem;
    margin-top: 10px;
    padding: 7px 9px;
}

.message-contact-box strong {
    font-weight: 900;
}

.message-compose {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.message-compose-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.message-compose-grid .message-field-full {
    grid-column: 1 / -1;
}

.message-compose textarea.form-control {
    min-height: 130px;
    resize: vertical;
}

.message-email-preference {
    align-items: center;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    gap: 9px;
    margin-top: 12px;
    padding: 10px 12px;
}

.message-email-preference input {
    flex: 0 0 auto;
    height: 17px;
    width: 17px;
}

.message-email-preference label {
    cursor: pointer;
    font-size: .82rem;
    font-weight: 750;
    margin: 0;
}

.nav-message-alert {
    position: relative;
}

.nav-message-badge {
    align-items: center;
    background: #ef4444;
    border-radius: 999px;
    color: #fff;
    display: inline-flex;
    font-size: .68rem;
    font-weight: 900;
    justify-content: center;
    line-height: 1;
    margin-left: 6px;
    min-width: 18px;
    padding: 3px 6px;
}

@media (max-width: 900px) {
    .messages-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .message-bubble {
        max-width: 90%;
    }
}

@media (max-width: 560px) {
    .messages-filters {
        grid-template-columns: 1fr;
    }

    .message-compose-grid {
        grid-template-columns: 1fr;
    }

    .message-compose-grid .message-field-full {
        grid-column: auto;
    }

    .message-thread-head {
        flex-direction: column;
        gap: 5px;
    }

    .message-thread-date {
        text-align: left;
    }

    .message-thread-preview {
        white-space: normal;
    }

    .message-bubble {
        max-width: 96%;
    }

    .message-bubble-head {
        align-items: flex-start;
        flex-direction: column;
        gap: 2px;
    }
}

/* ============================================================
   FORM ADMIN - CLIENTI / UTENTI
   Solo i form marcati esplicitamente in admin.php
   ============================================================ */

.admin-readable-form .form-label {
    color: var(--ink);
    font-size: .82rem;
    font-weight: 850;
    line-height: 1.2;
    margin-bottom: 6px;
}

.admin-readable-form .form-control,
.admin-readable-form .form-select {
    background: #fff;
    border: 1px solid #bfcbd6;
    color: var(--ink);
    min-height: 40px;
}

.admin-readable-form textarea.form-control {
    min-height: 80px;
}

.admin-readable-form .form-control::placeholder {
    color: #8795a3;
    opacity: 1;
}

.admin-readable-form .form-control:focus,
.admin-readable-form .form-select:focus {
    background: #fff;
    border-color: var(--blue);
    box-shadow: 0 0 0 .18rem rgba(41, 70, 91, .12);
}

.admin-readable-form .input-group .form-control {
    border-right: 0;
}

.admin-readable-form .input-group .btn {
    min-width: 90px;
    border-color: #bfcbd6;
    background: #f6f8fa;
    color: var(--blue);
    font-weight: 850;
}

.admin-readable-form .input-group .btn:hover {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
}

.admin-readable-form small.text-muted {
    display: block;
    font-size: .76rem;
    line-height: 1.35;
    margin-top: 5px;
}


/* ============================================================
   SCHEDA AZIENDA - PULSANTI SALVATAGGIO TELEFONATA
   ============================================================ */

.crm-call-save-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
}

.crm-call-save-actions .btn {
    min-height: 48px;
    color: #fff;
    font-weight: 850;
    white-space: normal;
}

.crm-call-save-dashboard {
    background: #1f6f4a;
    border-color: #1f6f4a;
}

.crm-call-save-dashboard:hover,
.crm-call-save-dashboard:focus {
    background: #185a3c;
    border-color: #185a3c;
    color: #fff;
}

.crm-call-save-stay {
    background: #38a9e0;
    border-color: #38a9e0;
}

.crm-call-save-stay:hover,
.crm-call-save-stay:focus {
    background: #2694ca;
    border-color: #2694ca;
    color: #fff;
}

@media (max-width: 560px) {
    .crm-call-save-actions {
        grid-template-columns: 1fr;
    }
}