/* ══════════════════════════════════════════════════════════
   Automations – Shared styles for list & editor pages
   ══════════════════════════════════════════════════════════ */

/* ════════════════════════════════════════════════════════════════
   List page (/automazioni) — clean, restrained layout
   ════════════════════════════════════════════════════════════════ */

.ae-list-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem clamp(1rem, 3vw, 1.75rem) 3rem;
}

.ae-list-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.ae-section-nav--toolbar {
  margin-bottom: 0;
}

.ae-list-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  justify-content: flex-end;
  flex: 1 1 auto;
}

@media (max-width: 768px) {
  .ae-list-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .ae-list-toolbar-actions {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
  }

  .ae-list-toolbar-actions .ae-list-primary-btn {
    width: 100%;
    justify-content: center;
  }
}

.ae-list-title {
  font-weight: 600;
  font-size: clamp(1.375rem, 2.5vw, 1.75rem);
  letter-spacing: -0.02em;
  color: var(--color-ink-slate);
  margin: 0 0 0.35rem;
  line-height: 1.2;
}

.ae-list-lede {
  margin: 0;
  font-size: var(--font-size-md);
  line-height: 1.5;
  color: var(--color-text-muted);
  max-width: 36rem;
}

/* Switch between Automazioni list and Modelli WhatsApp */
.ae-section-nav {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
}

.ae-section-nav__link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.ae-section-nav__link:hover {
  color: var(--color-ink-slate);
  background: var(--color-surface);
}

.ae-section-nav__link.is-active {
  background: var(--color-surface);
  color: var(--brand-green-strong);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

.ae-list-mobile-status {
  width: 100%;
}

.ae-list-primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
  padding: 0.55rem 1.05rem;
  white-space: nowrap;
}

.ae-list-meta-line {
  margin: 1rem 0 0;
  font-size: var(--font-size-caption);
  color: var(--color-text-faint);
  line-height: 1.5;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.85rem;
}

.ae-list-meta-label {
  font-weight: 600;
  color: var(--color-text-muted);
}

.ae-list-flow {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 0;
}

.ae-list-flow-part {
  padding: 0.2rem 0.55rem;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border-faint);
  border-radius: var(--radius-xs);
  color: var(--color-text-secondary);
  font-size: var(--font-size-xs);
  font-weight: 500;
}

.ae-list-flow-sep {
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: var(--radius-round);
  background: var(--color-border-muted);
  margin: 0 0.25rem;
  vertical-align: middle;
}

.ae-list-section-head {
  margin-top: 2rem;
  margin-bottom: 0.875rem;
}

.ae-list-count {
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-faint);
}

.ae-list-cards {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

/* ── Workflow cards (list) ────────────────────────────────── */
.wf-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.125rem 1.25rem;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.wf-card:hover {
  border-color: var(--color-border-muted);
  box-shadow: var(--shadow-popover);
}

.wf-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.wf-card-main {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  min-width: 0;
  flex: 1;
}

.wf-status {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-round);
  margin-top: 0.42rem;
  background: var(--brand-green);
  box-shadow: 0 0 0 3px rgba(var(--brand-green-rgb), 0.2);
}

.wf-card-inactive .wf-status {
  background: var(--color-border-muted);
  box-shadow: var(--shadow-xs);
}

.wf-card-titles {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
}

.wf-card-inactive {
  opacity: 0.88;
}

.wf-card-inactive .wf-title {
  color: var(--color-text-muted);
}

.wf-title {
  font-weight: 600;
  font-size: var(--font-size-base);
  color: var(--color-ink-slate);
  margin: 0;
  line-height: 1.35;
}

/* Trigger badges — soft, typographic */
.wf-trigger-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-xs);
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.wf-trigger-badge--lead_created,
.wf-trigger-badge.lead_created {
  background: var(--color-surface-2);
  color: var(--color-text-emphasis);
  border: 1px solid var(--color-border);
}

.wf-trigger-badge--appointment_created,
.wf-trigger-badge.appointment_created {
  background: var(--color-ai-surface);
  color: var(--color-ai-ink-deep);
  border: 1px solid var(--color-ai-border);
}

.wf-trigger-badge--conversation_idle,
.wf-trigger-badge.conversation_idle {
  background: var(--color-warning-surface);
  color: var(--color-warning-ink-mid);
  border: 1px solid var(--color-warning-tint);
}

.wf-trigger-badge.manual,
.wf-trigger-badge--manual {
  background: var(--color-info-sky-surface);
  color: var(--color-info-sky-ink);
  border: 1px solid var(--color-info-sky-border);
}

.wf-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  margin-top: 0.9rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--color-border-divider);
  font-size: var(--font-size-caption);
  color: var(--color-text-faint);
}
.wf-meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.wf-meta i {
  font-size: var(--font-size-sm);
  color: var(--color-border-muted);
}

.wf-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.4rem;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
}

.wf-toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 0 0 0.25rem;
}

.wf-toggle-label {
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--color-text-faint);
}

/* Toggle switch */
.wf-toggle .form-check-input {
  width: 2.35rem;
  height: 1.2rem;
  cursor: pointer;
  margin-top: 0;
}
/* A <label>, so taps on its pseudo-element flip the switch: 44px tap target, same visual. */
.wf-toggle {
  position: relative;
  cursor: pointer;
}
@media (pointer: coarse) {
  .wf-toggle::after {
    content: "";
    position: absolute;
    inset: 50% auto auto 50%;
    width: max(100%, 44px);
    height: 44px;
    transform: translate(-50%, -50%);
  }
}
.wf-toggle .form-check-input:focus {
  box-shadow: var(--focus-ring);
}
.wf-toggle .form-check-input:checked {
  background-color: var(--brand-green-hover);
  border-color: var(--brand-green-hover);
}

.wf-icon-actions {
  display: inline-flex;
  gap: 0.25rem;
  padding-left: 0.35rem;
  border-left: 1px solid var(--color-border-faint);
}

.wf-icon-btn {
  padding: 0.35rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: var(--color-text-muted);
  background: transparent;
  line-height: 1;
  transition: color .15s, background .15s, border-color .15s;
}
.wf-icon-btn:hover {
  color: var(--color-ink-slate);
  background: var(--color-surface-2);
  border-color: var(--color-border-hover);
}
.wf-icon-btn-danger:hover {
  color: var(--color-danger-bright);
  background: var(--color-danger-surface);
  border-color: var(--color-danger-border);
}

/* Stat pills — calmer palette */
.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .45rem;
  border-radius: var(--radius-xs);
  font-size: var(--font-size-xs);
  font-weight: 600;
  border: 1px solid transparent;
}
.stat-pill.pending {
  background: var(--color-warning-surface);
  color: var(--color-warning-ink-mid);
  border-color: var(--color-warning-tint);
}
.stat-pill.sent {
  background: var(--media-step-violet-soft);
  color: var(--color-success-deep);
  border-color: var(--color-success-border);
}
.stat-pill.error {
  background: var(--color-danger-surface);
  color: var(--color-danger-ink-deep);
  border-color: var(--color-danger-border);
  cursor: help;
  animation: none;
}

/* Empty — minimal centerpiece */
.ae-empty {
  margin-top: 3rem;
  padding: clamp(2.5rem, 6vw, 3.75rem) 1.75rem;
  text-align: center;
  border: 1px dashed var(--color-border-dashed);
  border-radius: var(--radius-lg);
  background: var(--color-surface-empty);
}

.ae-empty-icon {
  width: 3.25rem;
  height: 3.25rem;
  margin: 0 auto 1.125rem;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border-faint);
  color: var(--color-text-faint);
  font-size: var(--font-size-xl);
}

.ae-empty-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-text-emphasis);
  margin: 0 0 0.5rem;
}

.ae-empty-text {
  font-size: var(--font-size-md);
  color: var(--color-text-muted);
  margin: 0 auto 1.5rem;
  max-width: 28rem;
  line-height: 1.55;
}

.ae-empty-cta {
  font-weight: 600;
  border-radius: var(--radius-pill);
  padding: 0.55rem 1.35rem;
}

@media (max-width: 768px) {
  .wf-icon-btn {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

@media (max-width: 576px) {
  .wf-card-top {
    flex-direction: column;
    align-items: stretch;
  }
  .wf-actions {
    justify-content: space-between;
  }
  .wf-icon-actions {
    border-left: none;
    padding-left: 0;
    flex: 1;
    justify-content: flex-end;
  }
}

/* Legacy helpers (still referenced elsewhere / older markup) */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--color-text-faint);
}
.empty-state i {
  font-size: var(--font-size-6xl);
  margin-bottom: 1rem;
  display: block;
}

.wf-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.wf-card.inactive { opacity: .88; }

.ae-form-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-alt);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.ae-form-card h5 {
  font-weight: 700;
  font-size: var(--font-size-base);
  color: var(--color-text);
  margin-bottom: 1rem;
}
.ae-form-card h5 i {
  margin-right: .4rem;
  color: var(--brand-green);
}

/* ── Step timeline ────────────────────────────────────────── */
.step-list {
  position: relative;
  padding-left: 1.5rem;
}
.step-list::before {
  content: '';
  position: absolute;
  left: .85rem;
  top: 1.5rem;
  bottom: 1.5rem;
  width: 2px;
  background: var(--color-gray-300);
  border-radius: var(--radius-2xs);
}

.step-card {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border-alt);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 1rem;
  transition: all .2s ease;
  box-shadow: var(--shadow-xs);
}
.step-card:hover {
  box-shadow: var(--shadow-popover);
  border-color: var(--color-gray-300);
  transform: translateY(-1px);
}
.step-card::before {
  content: '';
  position: absolute;
  left: -1.15rem;
  top: 1.75rem;
  width: 14px;
  height: 14px;
  border-radius: var(--radius-round);
  background: var(--brand-green);
  border: 3px solid var(--color-surface);
  box-shadow: 0 0 0 2px var(--brand-green);
}

/* Step card enhancements */
.step-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-surface-3);
}

.step-card-header h6 {
  margin: 0;
  color: var(--color-text);
  font-weight: 700;
}

.step-number {
  position: absolute;
  left: -2.6rem;
  top: 1.2rem;
  width: 1.5rem;
  height: 1.5rem;
  background: var(--brand-green);
  color: var(--color-surface);
  border-radius: var(--radius-round);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xs);
  font-weight: 700;
}

.step-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .75rem;
}
.step-header-label {
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: var(--color-text-emphasis);
}

/* Delay row */
.delay-row {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
}
.delay-row label {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  white-space: nowrap;
}
.delay-row input,
.delay-row select { max-width: 110px; }
.delay-row .delay-ref-sel {
  max-width: 200px !important;
  font-size: var(--font-size-caption);
}

/* Delay info (cumulative timing display) */
.delay-info {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.35rem;
  margin-bottom: 0.5rem;
  padding: 0.4rem 0.65rem;
  background: var(--color-surface-2);
  border-left: 3px solid var(--brand-green);
  border-radius: var(--radius-xs);
  font-size: var(--font-size-caption);
}

.delay-info:empty {
  display: none;
}

.delay-info small {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.delay-info i {
  font-size: var(--font-size-xs);
  color: var(--brand-green);
}

/* Message type sections */
.msg-section { margin-top: .75rem; }
.msg-section label {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  font-weight: 600;
}

/* Template picker - Improved card-based design */
.template-list {
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid var(--color-border-alt);
  border-radius: var(--radius-md);
  margin-top: .5rem;
  background: var(--color-surface);
  padding: 0.75rem;
}

.template-search-wrapper {
  position: sticky;
  top: 0;
  background: var(--color-surface);
  z-index: 10;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-surface-3);
}

.template-grid {
  display: grid;
  gap: 0.75rem;
}

.template-card {
  padding: 1rem;
  border: 1px solid var(--color-border-alt);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .15s ease;
  background: var(--color-surface);
}

.template-card:hover {
  background: var(--media-step-violet-soft);
  border-color: var(--brand-green);
  box-shadow: var(--shadow-brand);
  transform: translateY(-1px);
}

.template-card.selected {
  background: var(--color-success-surface);
  border-color: var(--brand-green);
  border-left: 4px solid var(--brand-green);
  box-shadow: var(--shadow-brand);
}

.template-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.template-card-name {
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: var(--color-text);
  word-break: break-word;
}

.template-card-lang {
  font-size: var(--font-size-2xs);
  padding: 0.15rem 0.4rem;
  background: var(--color-surface-3);
  border-radius: var(--radius-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.template-card-body {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  line-height: 1.5;
  margin-bottom: 0.75rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.template-card-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.template-card-status {
  font-size: var(--font-size-2xs);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-xl);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.template-card-status.approved,
.template-card-status.approved_v2 {
  background: var(--color-success-surface);
  color: var(--color-success-ink-deep);
}

.template-card-status.pending,
.template-card-status.pending_v2 {
  background: var(--color-warning-pending-surface);
  color: var(--color-warning-deep);
}

.template-card-status.rejected {
  background: var(--color-danger-tint);
  color: var(--color-danger-ink-bright);
}

/* Legacy styles for backward compatibility */
.template-item {
  padding: .6rem .8rem;
  border-bottom: 1px solid var(--color-surface-3);
  cursor: pointer;
  font-size: var(--font-size-sm);
  transition: background .15s;
}
.template-item:hover { background: var(--media-step-violet-soft); }
.template-item.selected {
  background: var(--color-success-surface);
  font-weight: 600;
}
.template-item .template-body {
  color: var(--color-text-muted);
  font-size: var(--font-size-caption);
  margin-top: .15rem;
}
.template-item .template-body-primary {
  color: var(--color-text-emphasis);
  font-size: var(--font-size-sm);
  line-height: 1.45;
  font-weight: 500;
}
.template-item .template-meta {
  font-size: var(--font-size-xs);
  margin-top: .25rem;
  color: var(--color-text-faint);
}
.template-loading {
  padding: 1.25rem;
  text-align: center;
  color: var(--color-text-faint);
  font-size: var(--font-size-sm);
}
.template-loading i {
  font-size: var(--font-size-2xl);
  display: block;
  margin-bottom: 0.5rem;
}

@keyframes templateSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.template-loading .spin {
  animation: templateSpin 1s linear infinite;
}

/* Template preview (after selection) */
.template-preview {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  padding: 0.75rem;
  margin-bottom: 1rem;
}
.template-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}
.template-preview-name {
  font-size: var(--font-size-sm);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
}
.template-preview-body {
  background: white;
  padding: 0.75rem;
  border-radius: var(--radius-xs);
  border: 1px solid var(--color-border);
  font-size: var(--font-size-sm);
  color: var(--color-text-emphasis);
  line-height: 1.5;
  max-height: 200px;
  overflow-y: auto;
}

/* Template parameters */
.template-params {
  margin-bottom: .5rem;
}
.template-params .param-row {
  margin-bottom: .4rem;
}
.template-params .param-row .input-group-text {
  min-width: 36px;
  justify-content: center;
  background: var(--color-surface-2);
  color: var(--color-text-secondary);
  font-size: var(--font-size-caption);
  font-weight: 600;
}
.template-params .param-input {
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: var(--font-size-sm);
}
.template-params .param-input::placeholder {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: var(--font-size-caption);
}

/* Placeholder helper */
.placeholder-helper {
  background: linear-gradient(135deg, var(--color-info-sky-surface) 0%, var(--color-info-sky-surface-2) 100%);
  border: 1px solid var(--color-info-sky-border);
  border-radius: var(--radius-sm);
  padding: .75rem;
}
.placeholder-helper-title {
  font-size: var(--font-size-caption);
  font-weight: 600;
  color: var(--color-info-sky-ink);
  margin-bottom: .5rem;
  display: flex;
  align-items: center;
  gap: .35rem;
}
.placeholder-helper-title i {
  font-size: var(--font-size-sm);
}
.placeholder-badges {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}
.placeholder-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .35rem .6rem;
  background: white;
  border: 1px solid var(--color-info-sky-accent);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all .15s;
  font-size: var(--font-size-xs);
}
.placeholder-badge:hover {
  background: var(--color-info-sky-accent);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(2, 132, 199, 0.2);
}
.placeholder-badge:hover code {
  color: white;
  background: transparent;
}
.placeholder-badge:active {
  transform: translateY(0);
}
.placeholder-badge code {
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: var(--font-size-xs);
  background: var(--color-info-sky-surface);
  color: var(--color-info-sky-ink);
  padding: .15rem .35rem;
  border-radius: var(--radius-xs);
  font-weight: 600;
  border: none;
}
.placeholder-badge .placeholder-desc {
  color: var(--color-text-secondary);
  font-size: var(--font-size-2xs);
  font-weight: 500;
}
.placeholder-badge:hover .placeholder-desc {
  color: white;
}

/* Toast notification */
.placeholder-toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--brand-green-hover);
  color: white;
  padding: .75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 500;
  box-shadow: var(--shadow-card);
  z-index: 9999;
  opacity: 0;
  transform: translateY(1rem);
  transition: all .3s ease;
}
.placeholder-toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Compact placeholder groups in template preview */
.template-placeholder-help {
  padding-top: 0.5rem;
  border-top: 1px dashed var(--color-border);
}

.tpl-ph-help-title {
  font-size: var(--font-size-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 0.35rem;
}

.tpl-ph-group {
  margin-bottom: 0.45rem;
}

.tpl-ph-group:last-child {
  margin-bottom: 0;
}

.tpl-ph-group-title {
  font-size: var(--font-size-2xs);
  color: var(--color-text-secondary);
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.tpl-ph-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.tpl-ph-chip {
  border: 1px solid var(--color-border-muted);
  background: var(--color-surface-2);
  color: var(--color-text);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-2xs);
  line-height: 1.1;
  padding: 0.2rem 0.45rem;
  font-family: 'Consolas', 'Monaco', monospace;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.tpl-ph-chip:hover {
  background: var(--color-info-sky-surface-2);
  border-color: var(--color-info-sky-border-mid);
  color: var(--color-info-sky-ink-deep);
}

/* Custom text & AI hint */
.custom-text-area { min-height: 80px; font-size: var(--font-size-sm); }
.ai-hint-input    { font-size: var(--font-size-sm); }

.ph-chip-editor {
  min-height: 2.25rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  cursor: text;
}

.ph-chip-editor--message {
  min-height: 80px;
}

.ph-chip-editor--param {
  min-height: 2rem;
  flex: 1 1 auto;
}

.ph-chip-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--color-text-form-muted);
  pointer-events: none;
}

.ph-chip-editor:focus {
  outline: none;
  border-color: var(--color-info-focus);
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

.ae-live-preview__label {
  margin-bottom: 0.35rem;
}

.ae-live-preview__note {
  margin-top: 0.35rem;
}

.ae-whatsapp-bubble {
  background: var(--color-surface-2);
  border-radius: var(--radius-md) var(--radius-md) var(--radius-md) var(--radius-xs);
  padding: 0.65rem 0.85rem;
  font-size: var(--font-size-sm);
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--color-border-muted);
}

.ae-whatsapp-bubble--inline {
  margin-top: 0.35rem;
}

.ae-template-raw summary {
  cursor: pointer;
}

.ae-message-hint p:last-child {
  margin-bottom: 0;
}

/* Add step button - Enhanced */
.add-step-area {
  text-align: center;
  padding: 1.25rem;
  background: linear-gradient(135deg, var(--color-surface-2) 0%, var(--color-surface-3) 100%);
  border: 2px dashed var(--color-border-muted);
  border-radius: var(--radius-md);
  margin-top: .75rem;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: all .2s ease;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.add-step-area:hover {
  border-color: var(--brand-green);
  background: linear-gradient(135deg, var(--media-step-violet-soft) 0%, var(--brand-green-50) 100%);
  color: var(--brand-green-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-brand);
}
.add-step-area:active {
  transform: translateY(0);
}
.add-step-area i {
  font-size: var(--font-size-lg);
}

/* Empty state for step list */
.step-list-empty {
  text-align: center;
  padding: 2.5rem 1.5rem;
  color: var(--color-text-faint);
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  border: 1px dashed var(--color-border-alt);
  margin-bottom: 1rem;
}
.step-list-empty i {
  font-size: var(--font-size-5xl);
  margin-bottom: 0.75rem;
  display: block;
  color: var(--color-border-muted);
}
.step-list-empty p {
  margin-bottom: 0.25rem;
  font-weight: 500;
}
.step-list-empty small {
  font-size: var(--font-size-caption);
}

/* ── Parameter preview badges ────────────────────────────── */
.param-row-wrapper {
  margin-bottom: 0.5rem;
}

.param-preview {
  margin-top: 0.25rem;
  margin-left: 2.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-size: var(--font-size-xs);
}

.preview-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-xs);
  font-weight: 500;
  white-space: nowrap;
}

.preview-badge i {
  font-size: var(--font-size-2xs);
}

/* Resolved user placeholder */
.preview-resolved {
  background: var(--brand-green-50);
  color: var(--brand-green-strong);
  border: 1px solid var(--brand-green-200);
}

/* Empty/missing value */
.preview-empty {
  background: var(--color-danger-surface);
  color: var(--color-danger-bright);
  border: 1px solid var(--color-danger-border);
}

.param-preview.has-warning {
  animation: subtle-pulse 2s ease-in-out infinite;
}

@keyframes subtle-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

/* ── Creation wizard (automation_edit, new only) ─────────── */
.ae-wizard--edit .ae-wizard-panel.d-none {
  display: block !important;
}
.ae-wizard--edit .ae-wizard-hint-new {
  display: none !important;
}

/* Progress Bar */
.automation-edit-page {
  max-width: 880px;
}

.ae-progress-wrapper {
  margin-bottom: 1.5rem;
  padding: 0 0.5rem;
}

.ae-progress-bar {
  height: 6px;
  background: var(--color-border-alt);
  border-radius: var(--radius-xs);
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.ae-progress-fill {
  width: var(--pct, 33%);
  height: 100%;
  background: linear-gradient(90deg, var(--brand-green) 0%, var(--brand-green-400) 100%);
  transition: width 0.4s ease;
  border-radius: var(--radius-xs);
}

.ae-progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-xs);
  color: var(--color-text-faint);
  font-weight: 500;
}

.ae-progress-label.is-active {
  color: var(--brand-green-hover);
  font-weight: 700;
}

.ae-progress-label.is-done {
  color: var(--brand-green);
}

.ae-wizard-steps {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.ae-wizard-step-node {
  flex: 1 1 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.35rem;
  padding: 0.75rem 0.5rem;
  border-radius: var(--radius-md);
  border: 2px solid var(--color-border-alt);
  background: var(--color-surface);
  transition: border-color .2s, background .2s, color .2s;
}
.ae-wizard-step-node .ae-wizard-step-num {
  width: 1.65rem;
  height: 1.65rem;
  border-radius: var(--radius-round);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-caption);
  font-weight: 700;
  background: var(--color-surface-3);
  color: var(--color-text-muted);
}
.ae-wizard-step-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  line-height: 1.25;
}
.ae-wizard-step-node.is-active {
  border-color: var(--brand-green);
  background: var(--brand-green-50);
}
.ae-wizard-step-node.is-active .ae-wizard-step-num {
  background: var(--brand-green);
  color: var(--color-surface);
}
.ae-wizard-step-node.is-active .ae-wizard-step-label {
  color: var(--brand-green-ink);
}
.ae-wizard-step-node.is-done {
  border-color: var(--brand-green-200);
  background: var(--media-step-violet-soft);
}
.ae-wizard-step-node.is-done .ae-wizard-step-num {
  background: var(--brand-green-300);
  color: var(--brand-green-ink-deep);
}
.ae-wizard-step-connector {
  flex: 0 0 1.25rem;
  align-self: center;
  height: 2px;
  background: var(--color-border-alt);
  border-radius: var(--radius-2xs);
  margin-top: -1.5rem;
}
.ae-wizard-step-node.is-done + .ae-wizard-step-connector {
  background: var(--media-step-violet-border);
}

.ae-wizard:not(.ae-wizard--edit) .ae-wizard-panel:not(.is-active) {
  display: none !important;
}
.ae-wizard:not(.ae-wizard--edit) .ae-wizard-panel.is-active {
  display: block !important;
}

.ae-wizard-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border-alt);
  border-radius: var(--radius-md);
}
.ae-wizard-nav-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-left: auto;
}

.ae-wizard-summary-dl dt {
  font-size: var(--font-size-caption);
  color: var(--color-text-muted);
  font-weight: 600;
}
.ae-wizard-summary-dl dd {
  font-size: var(--font-size-sm);
  color: var(--color-text);
}
.ae-wizard-summary-steps li {
  padding: 0.5rem 0.65rem;
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

/* ── Visual Summary / Timeline ───────────────────────────── */
.ae-sum-container {
  padding: 0.5rem;
}

/* Trigger Card */
.ae-sum-trigger-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  background: linear-gradient(135deg, var(--brand-green-50) 0%, var(--media-step-violet-soft) 100%);
  border: 1px solid var(--color-success-border);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
}

.ae-sum-trigger-icon {
  width: 56px;
  height: 56px;
  background: var(--brand-green);
  border-radius: var(--radius-round);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: var(--font-size-2xl);
  flex-shrink: 0;
  box-shadow: var(--shadow-brand);
}

.ae-sum-trigger-info {
  flex: 1;
}

.ae-sum-trigger-label {
  font-size: var(--font-size-xs);
  color: var(--brand-green-hover);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.25rem;
}

.ae-sum-trigger-value {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--brand-green-ink-deep);
}

/* Timeline Arrow */
.ae-sum-timeline-arrow {
  text-align: center;
  color: var(--color-border-muted);
  font-size: var(--font-size-xl);
  margin: 0.5rem 0;
}

/* Timeline Container */
.ae-sum-timeline {
  position: relative;
  padding-left: 1.5rem;
}

.ae-sum-timeline::before {
  content: '';
  position: absolute;
  left: 0.5rem;
  top: 0.5rem;
  bottom: 1rem;
  width: 3px;
  background: linear-gradient(180deg, var(--brand-green) 0%, var(--brand-green-400) 100%);
  border-radius: var(--radius-xs);
}

/* Timeline Item */
.ae-sum-timeline-item {
  position: relative;
  margin-bottom: 1.25rem;
  padding-left: 1rem;
}

.ae-sum-timeline-connector {
  position: absolute;
  left: -1.25rem;
  top: 1.25rem;
  width: 1rem;
  height: 3px;
  background: var(--brand-green);
  border-radius: var(--radius-2xs);
}

.ae-sum-timeline-node {
  position: absolute;
  left: -1.75rem;
  top: 0.5rem;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-round);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: var(--font-size-sm);
  border: 3px solid white;
  box-shadow: var(--shadow-card);
  z-index: 5;
}

.ae-sum-timeline-content {
  background: white;
  border: 1px solid var(--color-border-alt);
  border-radius: var(--radius-md);
  padding: 1rem;
  box-shadow: var(--shadow-xs);
}

.ae-sum-timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ae-sum-timeline-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-xl);
  font-size: var(--font-size-caption);
  font-weight: 600;
}

.ae-sum-timeline-timing {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-weight: 500;
}

.ae-sum-timeline-timing i {
  color: var(--brand-green);
}

.ae-sum-timeline-from {
  font-size: var(--font-size-xs);
  color: var(--color-text-faint);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--color-border-alt);
}

/* Message Preview in Timeline */
.ae-sum-msg-preview {
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  margin-top: 0.5rem;
}

.ae-sum-msg-label {
  font-size: var(--font-size-caption);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.ae-sum-msg-label--template {
  color: var(--color-info-sky-accent);
}

.ae-sum-msg-label--ai {
  color: var(--color-ai);
}

.ae-sum-timeline-node--template {
  background: var(--color-info-sky-accent);
}

.ae-sum-timeline-node--ai {
  background: var(--color-ai);
}

.ae-sum-timeline-node--custom {
  background: var(--color-orange-600);
}

.ae-sum-timeline-badge--template {
  background: var(--color-info-sky-surface);
  color: var(--color-info-sky-accent);
}

.ae-sum-timeline-badge--ai {
  background: var(--color-ai-surface);
  color: var(--color-ai);
}

.ae-sum-timeline-badge--custom {
  background: var(--color-warning-surface-alt);
  color: var(--color-orange-600);
}

.ae-step-switch-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-weight: 600;
}

.ae-step-check-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.ae-form-hint {
  font-size: var(--font-size-caption);
  color: var(--color-text-muted);
}

.ae-template-clear-btn {
  padding: 0;
  font-size: var(--font-size-sm);
}

.ae-meta-vars-warning {
  color: var(--color-warning-deep);
}

.ae-delay-info-total {
  margin-left: 0.5rem;
}

.ae-sum-msg-meta {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.ae-sum-msg-body {
  font-size: var(--font-size-sm);
  color: var(--color-text-emphasis);
  line-height: 1.5;
}

/* Empty State */
.ae-sum-empty-steps {
  text-align: center;
  padding: 2rem;
  color: var(--color-text-faint);
  font-style: italic;
}

/* Summary Footer Stats */
.ae-sum-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border-alt);
}

.ae-sum-stat {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  padding: 0.4rem 0.75rem;
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
}

.ae-sum-stat i {
  font-size: var(--font-size-base);
}

.ae-sum-stat .text-success {
  color: var(--brand-green) !important;
}

.ae-sum-stat .text-warning {
  color: var(--color-warning) !important;
}

@media (max-width: 576px) {
  .ae-wizard-step-connector {
    display: none;
  }
  .ae-wizard-steps {
    flex-direction: column;
  }
  .ae-wizard-step-node {
    flex-direction: row;
    justify-content: flex-start;
    text-align: left;
    gap: 0.75rem;
  }
  .ae-wizard-step-node .ae-wizard-step-label {
    flex: 1;
  }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 576px) {
  .wf-header  { flex-direction: column; }
  .wf-actions { width: 100%; justify-content: flex-end; }
  .step-list  { padding-left: 1rem; }
  .step-number { display: none; }
  .delay-row  { flex-direction: column; align-items: stretch; }
  .delay-row input,
  .delay-row select { max-width: 100%; }
}


.template-empty-state {
  border: 1px dashed var(--color-border-muted);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
}

/* ── Email channel ────────────────────────────────────────── */
.step-header-title {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.step-channel-icon {
  font-size: var(--font-size-sm);
}
.step-channel-icon--whatsapp { color: var(--color-whatsapp); }
.step-channel-icon--email { color: var(--color-info-sky-accent); }

.ae-channel-switch {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
}
.ae-channel-opt {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.9rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
}
.ae-channel-opt:hover:not(:disabled) { color: var(--color-text-emphasis); }
.ae-channel-opt.is-active {
  background: var(--color-surface);
  color: var(--color-text-emphasis);
  box-shadow: var(--shadow-xs);
}
.ae-channel-opt--whatsapp.is-active i { color: var(--color-whatsapp); }
.ae-channel-opt--email.is-active i { color: var(--color-info-sky-accent); }
.ae-channel-opt:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
.ae-channel-opt:focus-visible {
  outline: 2px solid var(--brand-green);
  outline-offset: 1px;
}
.ae-channel-hint a { font-weight: 600; }

.ph-chip-editor--subject {
  min-height: 0;
  white-space: nowrap;
  overflow-x: auto;
}

.ae-email-envelope {
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--color-border-muted);
  border-bottom: 0;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: var(--color-surface-2);
  font-size: var(--font-size-sm);
}
.ae-email-preview__row {
  display: flex;
  gap: 0.6rem;
  min-width: 0;
  line-height: 1.6;
}
.ae-email-preview__row > :last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ae-email-preview__key {
  flex: 0 0 4.5rem;
  color: var(--color-text-muted);
}
/* Live HTML preview (email-compose.js) */
.ec-preview {
  border: 1px solid var(--color-border-muted);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  overflow: hidden;
}
.ec-preview__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem 0.35rem 0.85rem;
  border-bottom: 1px solid var(--color-border-muted);
  background: var(--color-surface);
}
.ec-preview__bar .ae-live-preview__label { margin: 0; }
.ec-device {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
}
.ec-device__btn {
  padding: 0.2rem 0.55rem;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--color-text-muted);
}
.ec-device__btn.is-active {
  background: var(--color-surface);
  color: var(--color-text-emphasis);
  box-shadow: var(--shadow-xs);
}
.ec-preview__stage {
  display: flex;
  justify-content: center;
  padding: 0;
  background: var(--color-surface-3);
}
.ec-preview__frame {
  display: block;
  width: 100%;
  height: 520px;
  border: 0;
  background: var(--color-surface);
}
.ec-preview__stage.is-phone { padding: 1rem 0; }
.ec-preview__stage.is-phone .ec-preview__frame {
  width: 375px;
  max-width: 100%;
  height: 620px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

/* Formatting toolbar */
.ec-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--color-border);
  border-bottom: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--color-surface-2);
}
.ec-tool {
  padding: 0.2rem 0.55rem;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--color-text-secondary);
}
.ec-tool:hover { background: var(--color-surface); color: var(--color-text-emphasis); }
.ec-tool:focus-visible { outline: 2px solid var(--brand-green); outline-offset: 1px; }
.ec-link-form {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.35rem;
}
.ec-link-form.d-none { display: none; }
.ec-link-input { width: 14rem; }
.ec-toolbar + .ec-body {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

/* Call-to-action button fields */
.ec-cta {
  margin-top: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}
.ec-cta__summary {
  padding: 0.5rem 0.75rem;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  cursor: pointer;
}
.ec-cta__body { padding: 0 0.75rem 0.75rem; }
.ec-cta-warning {
  margin-bottom: 0.6rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--color-warning-tint);
  border-radius: var(--radius-sm);
  background: var(--color-warning-surface);
  color: var(--color-warning-deep);
  font-size: var(--font-size-caption);
  line-height: 1.45;
}
.et-card__cta {
  display: inline-flex;
  align-items: center;
  margin-top: 0.4rem;
  font-size: var(--font-size-caption);
  color: var(--color-text-muted);
}
@media (max-width: 576px) {
  .ec-link-form { flex-wrap: wrap; margin-left: 0; }
  .ec-link-input { width: 100%; }
}

.ae-email-template-list {
  display: grid;
  gap: 0.5rem;
  max-height: 260px;
  overflow-y: auto;
}
.ae-email-template-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  text-align: left;
  cursor: pointer;
}
.ae-email-template-option:hover { border-color: var(--color-border-alt); }
.ae-email-template-option.is-selected {
  border-color: var(--brand-green);
  box-shadow: 0 0 0 1px var(--brand-green);
}
.ae-email-template-option__name {
  font-weight: 600;
  color: var(--color-text-emphasis);
}
.ae-email-template-option__subject {
  color: var(--color-text-muted);
  font-size: var(--font-size-caption);
}

.ae-sum-msg-label--email { color: var(--color-info-sky-accent); }
.ae-sum-timeline-node--email { background: var(--color-info-sky-accent); }
.ae-sum-timeline-badge--email {
  background: var(--color-info-sky-surface);
  color: var(--color-info-sky-accent);
}

.wf-channels i { color: var(--color-text-faint); }

/* Modelli email page */
.et-list {
  display: grid;
  gap: 0.75rem;
}
.et-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg, var(--radius-md));
  background: var(--color-surface);
}
.et-card__main { min-width: 0; }
.et-card__name {
  margin: 0 0 0.15rem;
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text-emphasis);
}
.et-card__subject {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.et-card__excerpt {
  margin-top: 0.35rem;
  color: var(--color-text-muted);
  font-size: var(--font-size-caption);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.et-card__actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}
@media (max-width: 576px) {
  .et-card { flex-direction: column; }
  .et-card__actions { align-self: flex-end; }
}

/* Link popover (opens inside the formatting toolbar) and link chips */
.ec-link-pop {
  flex: 1 0 100%;
  margin: 3px 0 2px;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}
.ec-link-pop.d-none { display: none; }
.ec-link-error {
  min-height: 0;
  margin-top: 0.35rem;
  font-size: var(--font-size-caption);
  color: var(--color-danger);
}
.ec-link-error:empty { display: none; }
.ec-link-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.6rem;
}
.ph-chip--link {
  gap: 0.2rem;
  padding-left: 0.35em;
  background: var(--color-success-tint);
  color: var(--brand-green-ink);
  border-color: var(--brand-green);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.ph-chip--link .wt-chip-remove { color: inherit; }
.ph-chip--link:hover { background: var(--color-success-surface); }

/* Modelli email: sender card, default (Carla) templates, content mode (V3 phase 5) */
.et-sender {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  margin-bottom: 1rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg, var(--radius-md));
  background: var(--color-surface);
  font-size: var(--font-size-sm);
}
.et-sender--posta, .et-sender--platform { border-color: var(--brand-green-100); background: var(--brand-green-pill-bg); }
.et-sender--none { border-color: var(--color-warning-tint); background: var(--color-warning-surface); }
.et-sender__icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-round);
  background: var(--color-surface);
  color: var(--brand-green-strong);
  font-size: var(--font-size-lg);
}
.et-sender--none .et-sender__icon { color: var(--color-warning-deep); }
.et-sender__title { font-weight: 600; color: var(--color-text-emphasis); margin-bottom: 0.15rem; }
.et-sender__text { min-width: 0; overflow-wrap: anywhere; }
.et-section-title {
  margin: 0.5rem 0 0.35rem;
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text-emphasis);
}
.et-list--defaults { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.et-card--default { border-top: 3px solid var(--brand-green); }
.et-card__icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-sm);
  background: var(--brand-green-100);
  color: var(--brand-green-strong);
}
.et-card__main { flex: 1 1 auto; }
.et-card__badges { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.15rem 0 0.35rem; }
.et-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.05rem 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--color-surface-3);
  color: var(--color-text-muted);
  font-size: var(--font-size-caption);
  font-weight: 600;
}
.et-badge--carla { background: var(--brand-green-100); color: var(--brand-green-strong); }
.et-card__headline {
  margin-top: 0.3rem;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-emphasis);
}
.et-card__wf {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
  margin-top: 0.65rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--color-border);
}
.et-mode { display: inline-flex; flex-wrap: wrap; gap: 0.4rem; }
.et-mode__opt { position: relative; margin: 0; cursor: pointer; }
.et-mode__opt input { position: absolute; opacity: 0; pointer-events: none; }
.et-mode__opt span {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  background: var(--color-surface);
}
.et-mode__opt input:checked + span {
  border-color: var(--brand-green);
  background: var(--brand-green-100);
  color: var(--brand-green-strong);
  font-weight: 600;
}
.et-mode__opt input:focus-visible + span { outline: 2px solid var(--brand-green); outline-offset: 2px; }
.et-html { font-size: var(--font-size-caption); min-height: 14rem; }

.et-optout-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); }
.et-optout { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.6rem 0.9rem; }
.et-optout + .et-optout { border-top: 1px solid var(--color-border); }
.et-optout__main { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.6rem; min-width: 0; }
.et-optout__email { font-weight: 600; color: var(--color-text-emphasis); overflow-wrap: anywhere; }
.et-badge--warn { background: var(--color-warning-tint); color: var(--color-warning-ink-strong); }


/* ── Automazioni → Catalogo (ready automations, automation_catalog.html) ─────────────────────── */
.recipe-group { margin-bottom: 1.75rem; }
.recipe-group-title { font-size: var(--font-size-sm); margin: 0 0 0.75rem; }
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 1rem;
}
.recipe-card { height: 100%; border-color: var(--color-border-muted); }
.recipe-title { color: var(--color-text-emphasis); }
.recipe-steps { display: flex; flex-direction: column; gap: 0.75rem; }
.recipe-step { border-left: 2px solid var(--color-border-muted); padding-left: 0.75rem; }
.recipe-step-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.5rem;
  color: var(--color-text-secondary); margin-bottom: 0.4rem;
}
.recipe-sender-own { background: var(--brand-green-50); color: var(--brand-green-ink); border: 1px solid var(--brand-green-200); }
/* A small phone surface so the bubble reads as "what the contact sees". */
.recipe-phone {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border-muted);
  border-radius: var(--radius-md);
  padding: 0.6rem;
}
/* The shared bubble keeps line breaks (pre-wrap); only the message text should. */
.recipe-bubble { background: var(--color-surface); max-width: 92%; white-space: normal; }
.recipe-bubble-text { white-space: pre-wrap; }
.recipe-bubble-buttons {
  display: flex; flex-direction: column; gap: 0.25rem; margin-top: 0.5rem;
  border-top: 1px solid var(--color-border-muted); padding-top: 0.4rem;
}
.recipe-bubble-buttons span { text-align: center; color: var(--color-info-sky-ink); font-weight: 500; }
.recipe-email summary { cursor: pointer; overflow-wrap: anywhere; }
.recipe-email-frame {
  display: block; width: 100%; height: 360px; margin-top: 0.5rem;
  border: 1px solid var(--color-border-muted); border-radius: var(--radius-md);
  background: var(--white); /* the e-mail itself is always light, as in the mail client */
}

/* Automazioni → Attività: on phones each row becomes a stacked card, labels from data-label. */
@media (max-width: 576px) {
  .automation-activity-table thead {
    display: none;
  }
  .automation-activity-table,
  .automation-activity-table tbody,
  .automation-activity-table tr,
  .automation-activity-table td {
    display: block;
    width: 100%;
  }
  .automation-activity-table tr {
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--color-border-divider);
  }
  .automation-activity-table tr:last-child {
    border-bottom: 0;
  }
  .automation-activity-table td {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.75rem;
    padding: 0.2rem 0;
    border: 0;
    white-space: normal;
  }
  .automation-activity-table td::before {
    content: attr(data-label);
    flex: 0 0 6.5rem;
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-text-faint);
  }
  .automation-activity-table td > div {
    flex-basis: 100%;
    padding-left: 7.25rem;
  }
}
