:root {
  --bg: #06100f;
  --bg-2: #0a1716;
  --surface: #0d1817;
  --surface-2: #122321;
  --surface-3: #182e2b;
  --border: #1c2c2a;
  --border-2: #243936;
  --border-strong: #2f4a46;
  --text: #e8f4f1;
  --text-muted: #7a8d8a;
  --text-dim: #4f5f5d;
  --primary: oklch(0.82 0.18 160);
  --primary-dim: oklch(0.62 0.16 160);
  --primary-soft: oklch(0.82 0.18 160 / 0.12);
  --primary-glow: oklch(0.82 0.18 160 / 0.35);
  --cyan: oklch(0.78 0.14 195);
  --cyan-soft: oklch(0.78 0.14 195 / 0.12);
  --amber: oklch(0.82 0.16 75);
  --rose: oklch(0.72 0.18 25);
  --violet: oklch(0.7 0.16 290);
  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-md: 0 4px 16px -4px rgb(0 0 0 / 0.5);
  --shadow-lg: 0 24px 64px -16px rgb(0 0 0 / 0.6), 0 8px 24px -8px rgb(0 0 0 / 0.4);
  --shadow-glow: 0 0 0 1px oklch(0.82 0.18 160 / 0.4), 0 12px 40px -8px oklch(0.82 0.18 160 / 0.25);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}
#root { height: 100%; }

/* Subtle radial accent on body */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 0% 0%, oklch(0.82 0.18 160 / 0.05), transparent 60%),
    radial-gradient(ellipse 60% 50% at 100% 100%, oklch(0.78 0.14 195 / 0.04), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; color: inherit; }

::selection { background: var(--primary-glow); color: var(--text); }

/* Scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--border-strong); background-clip: padding-box; border: 2px solid transparent; }

/* ============ BOOT SPLASH ============ */
.boot-splash {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 24px; background: var(--bg); z-index: 1000;
}
.boot-logo {
  display: flex; align-items: center; gap: 12px;
  color: var(--primary); font-weight: 600; font-size: 20px; letter-spacing: -0.02em;
  animation: bootPulse 1.5s ease-in-out infinite;
}
.boot-bar { width: 160px; height: 2px; background: var(--border); border-radius: 2px; overflow: hidden; }
.boot-fill { width: 30%; height: 100%; background: var(--primary); border-radius: 2px; animation: bootSlide 1.2s ease-in-out infinite; }
@keyframes bootPulse { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }
@keyframes bootSlide { 0% { transform: translateX(-100%); } 100% { transform: translateX(450%); } }

/* ============ APP SHELL ============ */
.app-shell {
  display: flex;
  height: 100vh;
  position: relative;
  z-index: 1;
  animation: fadeIn 0.4s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.main-area {
  flex: 1;
  min-width: 0;
  position: relative;
  overflow: hidden;
  background: var(--bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  animation: screenEnter 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes screenEnter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ SIDEBAR ============ */
.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  gap: 4px;
  position: relative;
  transition: width 0.22s ease, min-width 0.22s ease, padding 0.22s ease;
}
.sidebar.collapsed {
  width: 56px;
  min-width: 56px;
}
/* Área central rolável: marca fica no topo, usuário no rodapé,
   e a lista de nav/workflows cresce com scroll próprio. */
.sidebar-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.sidebar-scroll::-webkit-scrollbar { width: 6px; }
.sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
.sidebar-scroll::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}
.sidebar-scroll::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.sidebar-brand-icon {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  display: flex; align-items: center; justify-content: center;
  color: var(--bg); font-weight: 800; flex-shrink: 0;
  box-shadow: 0 4px 12px -4px var(--primary-glow);
}
.sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.sidebar-brand-text strong { font-weight: 600; font-size: 14px; letter-spacing: -0.01em; }
.sidebar-brand-text span { font-size: 11px; color: var(--text-muted); font-weight: 400; }
.sidebar-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-dim); padding: 16px 10px 6px; font-weight: 600;
}
.sidebar-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 11px;
  border-radius: 9px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13.5px;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: all 0.18s ease;
  position: relative;
}
.sidebar-item:hover { background: var(--surface); color: var(--text); }
.sidebar-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: oklch(0.82 0.18 160 / 0.2);
}
.sidebar-item.active::before {
  content: ''; position: absolute; left: -16px; top: 8px; bottom: 8px;
  width: 2px; background: var(--primary); border-radius: 0 2px 2px 0;
}
.sidebar-item-icon { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-item-badge {
  margin-left: auto; font-size: 11px;
  background: var(--surface-2); padding: 1px 7px; border-radius: 10px;
  color: var(--text-muted); font-weight: 600;
}
.sidebar-item.active .sidebar-item-badge { background: var(--primary); color: var(--bg); }
.sidebar-kanban-sub { padding-left: 32px !important; font-size: 12.5px; opacity: 0.88; }
.sidebar-kanban-sub:hover { opacity: 1; }
.sidebar-kanban-sub.active { opacity: 1; }

.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.sidebar-user {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  border-radius: 9px;
}
.sidebar-user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--primary));
  display: flex; align-items: center; justify-content: center;
  color: var(--bg); font-weight: 700; font-size: 12px;
}
.sidebar-user-info { line-height: 1.2; }
.sidebar-user-info strong { font-size: 13px; display: block; }
.sidebar-user-info span { font-size: 11px; color: var(--text-muted); }

/* Sidebar collapse button */
.sidebar-collapse-btn {
  margin-left: auto;
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
  padding: 0;
}
.sidebar-collapse-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}

/* Sidebar collapsed state */
.sidebar.collapsed { padding: 14px 8px; }
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .sidebar-label,
.sidebar.collapsed .sidebar-user-info { display: none; }
.sidebar.collapsed .sidebar-item span:not(.sidebar-item-badge) { display: none; }
.sidebar.collapsed .sidebar-item-badge { display: none; }
.sidebar.collapsed .sidebar-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .sidebar-brand { flex-direction: column; align-items: center; padding-bottom: 12px; gap: 6px; }
.sidebar.collapsed .sidebar-collapse-btn { margin-left: 0; }
.sidebar.collapsed .sidebar-wf-row { justify-content: center; }

/* Workflow row with delete button */
.sidebar-wf-row {
  display: flex;
  align-items: center;
  gap: 2px;
  position: relative;
}
.sidebar-wf-row .sidebar-item { flex: 1; min-width: 0; }
.sidebar-wf-delete {
  flex-shrink: 0;
  width: 24px; height: 24px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: all 0.15s;
  padding: 0;
}
.sidebar-wf-row:hover .sidebar-wf-delete { opacity: 1; }
.sidebar-wf-delete:hover { background: var(--surface-2); color: var(--text-muted); }
.sidebar-wf-delete.confirm {
  opacity: 1;
  background: oklch(0.55 0.22 25 / 0.15);
  color: oklch(0.65 0.2 25);
}
.sidebar-item.deleting {
  background: oklch(0.55 0.22 25 / 0.08) !important;
  color: oklch(0.65 0.2 25) !important;
  border-color: oklch(0.55 0.22 25 / 0.2) !important;
}

/* ============ COMMON ============ */
.screen-header {
  padding: 28px 32px 20px;
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px;
}
.screen-title {
  font-size: 24px; font-weight: 700; letter-spacing: -0.025em; margin: 0;
}
.screen-subtitle { color: var(--text-muted); font-size: 14px; margin-top: 2px; }

/* ── Connections screen ─────────────────────────────────── */
.connections-loading {
  padding: 60px; text-align: center; color: var(--text-muted); font-size: 14px;
}
.connections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 16px;
  padding: 0 32px 32px;
}
.connections-empty {
  grid-column: 1 / -1;
  text-align: center; padding: 60px 20px;
  color: var(--text-muted); font-size: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.connection-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.connection-card-top {
  display: flex; align-items: center; gap: 8px;
}
.connection-status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.connection-instance-name {
  font-size: 13px; font-weight: 600; flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.connection-profile {
  display: flex; align-items: center; gap: 10px;
}
.connection-avatar {
  width: 38px; height: 38px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
}
.connection-avatar-placeholder {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--surface-2, oklch(0.22 0.02 240));
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); flex-shrink: 0;
}
.connection-profile-name { font-size: 13px; font-weight: 500; }
.connection-profile-phone { font-size: 12px; color: var(--text-muted); }
.connection-disconnected {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-muted);
  padding: 6px 0;
}
.connection-card-actions {
  display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px;
}
.connections-tabs {
  display: flex; align-items: center; gap: 8px;
  padding: 0 32px 18px;
}
.connections-tab {
  min-height: 38px;
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.connections-tab:hover { color: var(--text); border-color: var(--border-strong); }
.connections-tab.active {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: oklch(0.82 0.18 160 / 0.3);
}
.connections-tab span {
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-3);
  color: var(--text-dim);
  font-size: 10px;
}
.smtp-card-main {
  display: flex; align-items: center; gap: 10px;
}
.smtp-card-icon {
  width: 38px; height: 38px; border-radius: 50%;
  background: oklch(0.72 0.18 220 / 0.15);
  color: oklch(0.72 0.18 220);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.smtp-card-meta {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.smtp-card-meta span {
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  padding: 3px 7px;
  font-size: 10px;
}
.smtp-form {
  display: flex; flex-direction: column; gap: 12px;
}
.smtp-form-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(110px, 0.45fr);
  gap: 10px;
}
.smtp-form-row {
  display: flex; flex-direction: column; gap: 6px;
}
.smtp-form-row label {
  font-size: 12px; color: var(--text-dim); font-weight: 600;
}
.smtp-form .input {
  min-height: 42px;
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  outline: none;
  font-size: 14px;
}
.smtp-form .input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.smtp-active-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
}
.smtp-active-row span {
  display: flex; flex-direction: column; gap: 2px;
  font-size: 12px;
}
.smtp-active-row small { color: var(--text-muted); font-size: 11px; }
/* QR code modal */
.connections-qr-img {
  width: 224px; height: 224px;
  border-radius: 10px; background: #fff; padding: 8px;
  display: block;
}
.connections-qr-placeholder {
  width: 224px; height: 224px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  text-align: center; font-size: 13px; color: var(--text-muted); line-height: 1.5;
}
.connections-qr-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-dim);
}
.connections-qr-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: oklch(0.8 0.16 75);
  animation: qr-pulse 1.4s ease-in-out infinite;
}
@keyframes qr-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.35; transform: scale(0.8); }
}
@media (max-width: 640px) {
  .connections-tabs { padding: 0 20px 16px; overflow-x: auto; }
  .connections-grid { padding: 0 20px 24px; grid-template-columns: 1fr; }
  .smtp-form-grid { grid-template-columns: 1fr; }
}

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  border-radius: 9px;
  font-weight: 500;
  font-size: 13px;
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--text);
  transition: all 0.18s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: var(--primary);
  color: var(--bg);
  border-color: transparent;
  font-weight: 600;
  box-shadow: 0 4px 14px -4px var(--primary-glow);
}
.btn-primary:hover { background: oklch(0.86 0.18 160); box-shadow: 0 6px 20px -4px var(--primary-glow); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-danger { color: var(--rose); }
.btn-danger:hover { background: oklch(0.72 0.18 25 / 0.1); border-color: oklch(0.72 0.18 25 / 0.3); color: oklch(0.78 0.18 25); }

.btn-icon { padding: 8px; width: 34px; height: 34px; justify-content: center; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 500;
  background: var(--surface-2); color: var(--text-muted);
  border: 1px solid var(--border);
}
.chip-dot { width: 6px; height: 6px; border-radius: 50%; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s ease;
}

/* ============ DASHBOARD ============ */
.dash-grid {
  padding: 0 32px 32px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.dash-row-2 {
  padding: 16px 32px 32px;
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}

.metric-card {
  padding: 18px 18px 20px;
  position: relative;
  overflow: hidden;
}
.metric-card-label {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-muted); font-size: 12px; font-weight: 500;
}
.metric-card-icon {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
}
.metric-card-value {
  font-size: 30px; font-weight: 700; letter-spacing: -0.03em;
  margin: 14px 0 4px;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}
.metric-card-delta { font-size: 12px; color: var(--primary); font-weight: 500; display: flex; align-items: center; gap: 4px; }
.metric-card-delta.down { color: var(--rose); }
.metric-spark {
  position: absolute; right: 0; bottom: 0; left: 0; height: 36px;
  opacity: 0.4;
}

.funnel-card { padding: 22px; }
.funnel-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.funnel-card-title { font-size: 14px; font-weight: 600; }
.funnel-row {
  display: grid; grid-template-columns: 130px 1fr 90px; gap: 12px;
  align-items: center; padding: 6px 0;
}
.funnel-row-label { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.funnel-bar-track { height: 28px; background: var(--bg-2); border-radius: 7px; overflow: hidden; }
.funnel-bar-fill { height: 100%; border-radius: 7px; display: flex; align-items: center; justify-content: flex-end; padding-right: 10px; font-size: 11px; font-weight: 600; color: var(--bg); transition: width 0.7s cubic-bezier(0.16, 1, 0.3, 1); }
.funnel-row-value { font-size: 13px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }

.workflow-list-card { padding: 22px; }
.workflow-list-card .funnel-card-header { margin-bottom: 6px; }
.workflow-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 12px; border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s;
}
.workflow-item:hover { background: var(--bg-2); border-color: var(--border); }
.workflow-item-icon {
  width: 36px; height: 36px; border-radius: 9px;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}
.workflow-item-body { flex: 1; min-width: 0; }
.workflow-item-name { font-weight: 600; font-size: 14px; }
.workflow-item-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; display: flex; align-items: center; gap: 10px; }
.workflow-item-meta-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--text-dim); }

.workflow-item-stages { display: flex; gap: 3px; }
.workflow-item-stages span {
  width: 18px; height: 6px; border-radius: 3px;
}

.workflow-item-status {
  font-size: 11px; padding: 3px 8px; border-radius: 6px;
  font-weight: 500;
}
.workflow-item-status.active { background: var(--primary-soft); color: var(--primary); }
.workflow-item-status.draft { background: var(--surface-2); color: var(--text-muted); }

/* ============ WORKFLOW BUILDER ============ */
.builder-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
}

.node-palette {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  padding: 18px;
  overflow-y: auto;
}
.node-palette h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-dim); margin: 6px 4px 12px; font-weight: 600;
}
.palette-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: grab;
  transition: all 0.18s;
  user-select: none;
}
.palette-item:hover { border-color: var(--border-strong); background: var(--surface-2); transform: translateY(-1px); }
.palette-item:active { cursor: grabbing; }
.palette-item-icon {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--bg);
}
.palette-item-text { font-weight: 500; font-size: 13px; }
.palette-item-text small { display: block; color: var(--text-muted); font-size: 11px; font-weight: 400; margin-top: 1px; }

.palette-info {
  margin-top: 24px; padding: 14px; border-radius: 10px;
  background: var(--cyan-soft); border: 1px solid oklch(0.78 0.14 195 / 0.2);
  font-size: 12px; color: var(--text-muted); line-height: 1.55;
}
.palette-info strong { color: var(--cyan); display: block; margin-bottom: 4px; font-size: 12px; }

.canvas-area {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 0%, oklch(0.82 0.18 160 / 0.04), transparent 50%),
    radial-gradient(circle at 80% 100%, oklch(0.78 0.14 195 / 0.04), transparent 50%),
    var(--bg);
}

.canvas-toolbar {
  position: absolute; top: 18px; left: 18px; right: 18px;
  display: flex; align-items: center; justify-content: space-between;
  z-index: 5;
  pointer-events: none;
}
.canvas-toolbar > * { pointer-events: auto; }
.canvas-toolbar-left { display: flex; align-items: center; gap: 12px; }
.canvas-toolbar-title { font-size: 16px; font-weight: 600; }
.canvas-toolbar-title input {
  background: transparent; border: 1px solid transparent;
  border-radius: 7px; padding: 4px 8px; font-size: 16px; font-weight: 600;
  color: var(--text); width: 240px;
  transition: all 0.15s;
}
.canvas-toolbar-title input:hover { border-color: var(--border); }
.canvas-toolbar-title input:focus { background: var(--surface); border-color: var(--primary); outline: none; }

.canvas-toolbar-right { display: flex; align-items: center; gap: 8px; }

.canvas-svg-layer {
  position: absolute; inset: 0;
  pointer-events: none;
}
.canvas-svg-layer.events { pointer-events: auto; }

.canvas-grid {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle, var(--border-2) 1px, transparent 1px);
  background-size: 20px 20px;
  background-position: var(--bgx, 0) var(--bgy, 0);
  pointer-events: none;
}

.canvas-content {
  position: absolute; inset: 0;
  transform-origin: 0 0;
  pointer-events: none;
}
.canvas-content > * { pointer-events: auto; }

.flow-node {
  position: absolute;
  width: 220px;
  background: var(--surface);
  border: 1.5px solid var(--border-2);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  user-select: none;
  transition: box-shadow 0.18s, border-color 0.18s;
}
.flow-node:hover { box-shadow: var(--shadow-lg); }
.flow-node.selected { 
  border-color: var(--node-color, var(--primary));
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--node-color, var(--primary)) 25%, transparent), var(--shadow-lg);
}
.flow-node-header {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 12px 11px;
  border-bottom: 1px solid var(--border);
  cursor: move;
}
.flow-node-icon {
  width: 28px; height: 28px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  background: var(--node-color, var(--primary));
  color: var(--bg);
  flex-shrink: 0;
}
.flow-node-title {
  font-weight: 600; font-size: 13px; flex: 1;
  background: transparent; border: none;
  color: var(--text);
  padding: 2px 4px;
  border-radius: 5px;
  width: 100%;
  min-width: 0;
  transition: background 0.15s;
}
.flow-node-title:focus { background: var(--bg-2); outline: 1px solid var(--node-color, var(--primary)); }
.flow-node-body {
  padding: 9px 12px 12px;
  font-size: 11px;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap;
}
.flow-node-color-picker {
  display: flex; gap: 4px;
}
.flow-node-color {
  width: 14px; height: 14px; border-radius: 4px;
  border: 1.5px solid var(--border-2);
  cursor: pointer;
  transition: transform 0.15s;
}
.flow-node-color:hover { transform: scale(1.15); }
.flow-node-color.selected { border-color: var(--text); transform: scale(1.15); }

/* Pause / Dia Vazio node */
.flow-node.pause-node {
  border-style: dashed;
  border-color: oklch(0.52 0.03 220 / 0.6);
  background: oklch(0.52 0.03 220 / 0.06);
  opacity: 0.88;
}
.flow-node.pause-node:hover { opacity: 1; }
.flow-node.pause-node .flow-node-icon {
  background: oklch(0.52 0.03 220 / 0.2);
  color: oklch(0.65 0.05 220);
}
.flow-node.pause-node .flow-node-title { color: var(--text-muted); }

/* Route / Encaminhar Fluxo node */
.flow-node.route-node {
  border-style: dashed;
  border-color: oklch(0.68 0.18 290 / 0.6);
  background: oklch(0.68 0.18 290 / 0.06);
}
.flow-node.route-node .flow-node-icon {
  background: oklch(0.68 0.18 290 / 0.18);
  color: oklch(0.72 0.2 290);
}

/* A/B Split node */
.flow-node.ab-split-node {
  border-color: oklch(0.70 0.20 300 / 0.7);
  background: oklch(0.70 0.20 300 / 0.06);
}
.flow-node.ab-split-node .flow-node-icon {
  background: oklch(0.70 0.20 300 / 0.2);
  color: oklch(0.78 0.22 300);
}

/* E-mail action node */
.flow-node.email-node {
  border-color: oklch(0.72 0.18 220 / 0.7);
  background: oklch(0.72 0.18 220 / 0.06);
}
.flow-node.email-node .flow-node-icon {
  background: oklch(0.72 0.18 220 / 0.2);
  color: oklch(0.72 0.18 220);
}

/* WhatsApp action node */
.flow-node.whatsapp-node {
  border-color: oklch(0.72 0.20 145 / 0.7);
  background: oklch(0.72 0.20 145 / 0.06);
}
.flow-node.whatsapp-node .flow-node-icon {
  background: oklch(0.72 0.20 145 / 0.2);
  color: oklch(0.72 0.20 145);
}

/* Route config popup */
.route-config-popup {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 300px;
  background: var(--surface-elevated, var(--surface));
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 12px;
  z-index: 200;
  box-shadow: 0 8px 28px oklch(0 0 0 / 0.32);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.route-config-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.route-config-section > label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.route-select,
.route-cond-field,
.route-cond-op,
.route-cond-val {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 11.5px;
  padding: 4px 7px;
  cursor: pointer;
}
.route-select { width: 100%; }
.route-select:focus,
.route-cond-field:focus,
.route-cond-op:focus,
.route-cond-val:focus { outline: none; border-color: var(--primary); }
.route-always {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}
.route-condition-row {
  display: flex;
  gap: 4px;
  align-items: center;
}
.route-cond-field { flex: 1.4; min-width: 0; }
.route-cond-op    { width: 62px; flex-shrink: 0; }
.route-cond-val   { flex: 1; min-width: 0; }
.route-cond-val::placeholder { color: var(--text-muted); }

/* Node-level A/B test popup & metrics */
.node-ab-popup { width: 290px; }
.node-ab-header {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.node-ab-metrics {
  display: flex; flex-direction: column; gap: 7px;
  background: var(--surface-2); border-radius: 7px; padding: 8px 9px;
}
.node-ab-metric-row { display: flex; align-items: flex-start; gap: 7px; }
.node-ab-metric-row.winner .node-ab-badge {
  background: oklch(0.82 0.18 160 / 0.18);
  color: var(--primary);
  border-color: oklch(0.82 0.18 160 / 0.4);
}
.node-ab-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; flex-shrink: 0;
  background: var(--surface-3); border: 1px solid var(--border-strong);
  border-radius: 5px; font-size: 10px; font-weight: 800;
  color: var(--text-muted); letter-spacing: 0; margin-top: 1px;
}
.node-ab-bar-wrap { height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
.node-ab-bar { height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.4s ease; min-width: 2px; }
.node-ab-textarea {
  width: 100%; resize: none;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text);
  font-size: 11px; padding: 5px 7px;
  font-family: inherit; line-height: 1.45;
}
.node-ab-textarea:focus { outline: none; border-color: var(--primary); }
.node-ab-textarea::placeholder { color: var(--text-dim); }
/* "A|B ativo" badge inside the node footer */
.node-ab-active-badge {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 9px; font-weight: 800; letter-spacing: 0.05em;
  color: oklch(0.80 0.18 265);
  background: oklch(0.80 0.18 265 / 0.12);
  border: 1px solid oklch(0.80 0.18 265 / 0.3);
  border-radius: 4px; padding: 1px 5px;
  white-space: nowrap;
}

.flow-handle {
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--bg);
  border: 2.5px solid var(--node-color, var(--primary));
  top: 50%; transform: translateY(-50%);
  cursor: crosshair;
  transition: all 0.15s;
  z-index: 2;
}
.flow-handle:hover { transform: translateY(-50%) scale(1.3); box-shadow: 0 0 0 4px color-mix(in oklch, var(--node-color, var(--primary)) 20%, transparent); }
.flow-handle.source { right: -8px; }
.flow-handle.target { left: -8px; }
.flow-handle.connecting { background: var(--node-color, var(--primary)); }

.flow-edge { stroke: #5a9e94; stroke-width: 2.5; fill: none; transition: stroke 0.15s, stroke-width 0.15s; }
.flow-edge:hover { stroke: var(--primary); stroke-width: 3; cursor: pointer; }
.flow-edge.selected { stroke: var(--primary); stroke-width: 3; }
.flow-edge-hit { stroke: transparent; stroke-width: 16; fill: none; cursor: pointer; }
.flow-edge-temp { stroke: var(--primary); stroke-width: 2; stroke-dasharray: 5 4; fill: none; opacity: 0.7; }
.flow-edge-animated { stroke: var(--primary); stroke-dasharray: 10 6; stroke-dashoffset: 0; animation: flow-march 0.85s linear infinite; }
@keyframes flow-march { from { stroke-dashoffset: 0; } to { stroke-dashoffset: -16; } }

.canvas-controls {
  position: absolute; bottom: 18px; left: 18px;
  display: flex; gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  box-shadow: var(--shadow-md);
}
.canvas-controls button {
  width: 30px; height: 30px;
  border: none; background: transparent;
  color: var(--text-muted); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.canvas-controls button:hover { background: var(--surface-2); color: var(--text); }
.canvas-zoom-level { font-size: 11px; color: var(--text-muted); padding: 0 8px; display: flex; align-items: center; min-width: 48px; justify-content: center; font-variant-numeric: tabular-nums; }

.canvas-minimap {
  position: absolute; bottom: 18px; right: 18px;
  width: 200px; height: 130px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.canvas-status {
  position: absolute; top: 70px; right: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 11px;
  color: var(--text-muted);
  display: flex; gap: 14px;
  box-shadow: var(--shadow-sm);
}
.canvas-status strong { color: var(--text); margin-right: 4px; font-variant-numeric: tabular-nums; }

/* ============ KANBAN ============ */
.kanban-shell { padding: 0 0 0 0; height: 100%; display: flex; flex-direction: column; }
.kanban-header {
  padding: 24px 32px 16px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}
.kanban-header-info { display: flex; align-items: center; gap: 14px; }
.kanban-header-chip {
  padding: 4px 10px; border-radius: 8px;
  background: var(--primary-soft); color: var(--primary);
  font-size: 12px; font-weight: 500;
  border: 1px solid oklch(0.82 0.18 160 / 0.2);
  display: flex; align-items: center; gap: 6px;
}

.kanban-board {
  flex: 1;
  display: flex;
  gap: 14px;
  padding: 8px 32px 32px;
  overflow-x: auto;
  overflow-y: hidden;
  align-items: flex-start;
  min-height: 0;
}
.kanban-column {
  width: 280px;
  flex-shrink: 0;
  background: var(--bg-2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex; flex-direction: column;
  max-height: 100%;
}
.kanban-column.drop-target { 
  border-color: var(--col-color, var(--primary));
  box-shadow: 0 0 0 2px color-mix(in oklch, var(--col-color, var(--primary)) 30%, transparent);
}
.kanban-column-header {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
}
.kanban-column-title {
  display: flex; align-items: center; gap: 9px;
  margin-bottom: 8px;
}
.kanban-column-title-icon {
  width: 26px; height: 26px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  background: var(--col-color, var(--primary));
  color: var(--bg);
  flex-shrink: 0;
}
.kanban-column-title-text { font-weight: 600; font-size: 13.5px; flex: 1; }
.kanban-column-title-count {
  font-size: 11px; color: var(--text-muted);
  background: var(--surface);
  padding: 2px 7px; border-radius: 10px;
  font-weight: 600;
}
.kanban-column-meta {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; color: var(--text-muted);
}
.kanban-column-meta strong { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }
.kanban-column-add {
  background: transparent; border: none; color: var(--text-muted);
  width: 22px; height: 22px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.kanban-column-add:hover { background: var(--col-color, var(--primary)); color: var(--bg); }

.kanban-column-body {
  flex: 1;
  padding: 10px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
  min-height: 60px;
}

.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  cursor: grab;
  transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s;
  position: relative;
}
.kanban-card:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.kanban-card.dragging { opacity: 0.4; cursor: grabbing; }
.kanban-card-header {
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 10px;
}
.kanban-card-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
  color: var(--bg);
  flex-shrink: 0;
}
.kanban-card-name { font-weight: 600; font-size: 13px; line-height: 1.3; }
.kanban-card-company { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }
.kanban-card-value {
  font-size: 14px; font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}
.kanban-card-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.kanban-card-tag {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 5px;
  font-weight: 500;
}

.kanban-empty {
  height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 60px 32px;
  text-align: center;
}
.kanban-empty-illustration {
  width: 120px; height: 120px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  color: var(--primary);
  position: relative;
}
.kanban-empty-illustration::before, .kanban-empty-illustration::after {
  content: ''; position: absolute; border-radius: 24px;
  inset: -8px; border: 1px dashed oklch(0.82 0.18 160 / 0.15);
  animation: pulseRing 3s ease-in-out infinite;
}
.kanban-empty-illustration::after { inset: -18px; animation-delay: 0.6s; }
@keyframes pulseRing { 0%, 100% { opacity: 0.3; } 50% { opacity: 0.8; } }
.kanban-empty h2 { font-size: 20px; font-weight: 700; margin: 8px 0 0; letter-spacing: -0.02em; }
.kanban-empty p { color: var(--text-muted); margin: 0 0 8px; max-width: 380px; }

/* ============ MODAL ============ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgb(0 0 0 / 0.55);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: backdropIn 0.2s ease-out;
}
@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 16px;
  width: 440px;
  max-width: 100%;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-weight: 600; font-size: 15px; }
.modal-body { padding: 18px 20px 4px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}
.form-group { margin-bottom: 14px; }
.form-label {
  display: block; font-size: 11.5px; font-weight: 500;
  color: var(--text-muted); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.form-input, .form-textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 13.5px;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.form-tag-option {
  padding: 5px 10px; border-radius: 7px;
  font-size: 11.5px; font-weight: 500;
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer; transition: all 0.15s;
}
.form-tag-option.selected { background: var(--primary-soft); color: var(--primary); border-color: oklch(0.82 0.18 160 / 0.3); }

/* ============ TOAST ============ */
.toast-stack {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-left: 3px solid var(--primary);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  font-size: 13px;
}
.toast-icon {
  width: 24px; height: 24px; border-radius: 6px;
  background: var(--primary-soft);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ============ WORKFLOW EXECUTE OVERLAY ============ */
.exec-overlay {
  position: fixed; inset: 0;
  background: rgb(0 0 0 / 0.7);
  backdrop-filter: blur(8px);
  z-index: 300;
  display: flex; align-items: center; justify-content: center;
  animation: backdropIn 0.25s ease-out;
}
.exec-card {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 18px;
  padding: 32px 40px;
  display: flex; flex-direction: column; align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
}

/* ── Clientes Screen ──────────────────────────────────────────────────── */
.clientes-table {
  width: 100%;
  border-collapse: collapse;
}
.clientes-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.clientes-row td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.clientes-row:last-child td { border-bottom: none; }
.clientes-row:hover td { background: var(--surface-2); }

/* Form validation feedback */
.form-input-error { border-color: var(--rose) !important; }
.form-error {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--rose);
}
.exec-check {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--primary-soft);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
  animation: checkPop 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.1s backwards;
}
@keyframes checkPop {
  0% { transform: scale(0); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}
.exec-check svg { animation: checkDraw 0.4s ease-out 0.3s backwards; }
@keyframes checkDraw { from { stroke-dashoffset: 30; } to { stroke-dashoffset: 0; } }
.exec-card h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.exec-card p { margin: 0; color: var(--text-muted); }
.exec-card-stages {
  display: flex; gap: 6px; margin-top: 4px;
}
.exec-card-stage {
  padding: 4px 9px; border-radius: 6px;
  font-size: 11px; font-weight: 500;
  color: var(--bg);
}

/* ============ WHATSAPP CONFIG ============ */
.whatsapp-config-popup { width: 310px; }
.email-config-popup { width: 340px; }
.whatsapp-toggle {
  width: 34px; height: 18px;
  background: var(--border-strong);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
  position: relative;
  flex-shrink: 0;
}
.whatsapp-toggle.active { background: oklch(0.72 0.20 145); }
.whatsapp-toggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--bg);
  transition: transform 0.2s;
  box-shadow: 0 1px 3px oklch(0 0 0 / 0.2);
}
.whatsapp-toggle.active .whatsapp-toggle-thumb { transform: translateX(16px); }

/* ============ AUTOMATION SCREEN ============ */
.automation-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 0 32px 20px;
}
.automation-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.automation-stat-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.automation-stat-value {
  font-size: 24px; font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.automation-stat-label {
  font-size: 11px; color: var(--text-muted);
  font-weight: 500; margin-top: 1px;
}

/* Tabs */
.automation-tabs {
  display: flex; gap: 4px;
  padding: 0 32px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.automation-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px;
  border-radius: 8px 8px 0 0;
  font-size: 13px; font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.automation-tab:hover { color: var(--text); background: var(--surface); }
.automation-tab.active {
  color: var(--primary);
  background: var(--surface);
  border-color: var(--border);
}
.automation-tab.active::after {
  content: ''; position: absolute; bottom: -1px; left: 0; right: 0;
  height: 2px; background: var(--primary);
}
.automation-tab-badge {
  background: var(--primary);
  color: var(--bg);
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 10px;
  min-width: 18px; text-align: center;
}

/* Config panel */
.automation-config-panel {
  padding: 24px 32px 32px;
  display: flex; flex-direction: column; gap: 0;
}
.automation-config-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}
.automation-config-row:last-child { border-bottom: none; }
.automation-config-info { flex: 1; min-width: 0; }
.automation-config-title { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.automation-config-desc { font-size: 12px; color: var(--text-muted); }
.automation-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 13px;
  padding: 7px 10px;
  cursor: pointer;
  min-width: 90px;
}
.automation-select:focus { outline: none; border-color: var(--primary); }
.automation-config-section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.06em;
  padding-top: 20px; margin-bottom: 10px;
}
.automation-compliance-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.automation-compliance-item {
  font-size: 12px; color: var(--text-muted);
  display: flex; align-items: center; gap: 8px;
}
.automation-compliance-check {
  color: oklch(0.78 0.16 160);
  font-weight: 700;
  flex-shrink: 0;
}

/* Queue panel */
.automation-queue-panel { padding: 20px 32px 32px; }
.automation-queue-actions {
  display: flex; gap: 8px; margin-bottom: 14px;
}
.automation-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 60px 20px;
  color: var(--text-muted); font-size: 14px;
}
.automation-queue-table-wrap {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.automation-queue-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.automation-queue-table th {
  text-align: left; font-size: 11px; font-weight: 600;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em;
  padding: 10px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.automation-queue-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.automation-queue-table tr:last-child td { border-bottom: none; }
.automation-queue-table tr:hover td { background: var(--surface); }
.automation-queue-lead { font-weight: 500; white-space: nowrap; }
.automation-queue-msg {
  max-width: 200px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-size: 12px; color: var(--text-muted);
}
.automation-channel-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 5px;
  font-size: 10px; font-weight: 600;
}
.automation-channel-chip[data-channel="whatsapp"] {
  background: oklch(0.72 0.20 145 / 0.12); color: oklch(0.72 0.20 145);
}
.automation-channel-chip[data-channel="email"] {
  background: oklch(0.72 0.18 220 / 0.12); color: oklch(0.72 0.18 220);
}

/* History panel */
.automation-history-panel { padding: 20px 32px 32px; }
.automation-history-list { display: flex; flex-direction: column; gap: 0; }
.automation-history-item {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.automation-history-item:last-child { border-bottom: none; }
.automation-history-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.automation-history-content { flex: 1; min-width: 0; }
.automation-history-title {
  font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.automation-history-workflow {
  font-size: 11px; font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 2px 7px; border-radius: 5px;
}
.automation-history-meta {
  font-size: 12px; color: var(--text-muted); margin-top: 4px;
  display: flex; gap: 6px; align-items: center;
}
.automation-history-time {
  font-size: 11px; color: var(--text-dim);
  white-space: nowrap; flex-shrink: 0;
  margin-top: 2px;
}

/* WhatsApp toggle reuse */
.whatsapp-toggle {
  width: 40px; height: 22px;
  border-radius: 11px;
  background: var(--border-2);
  cursor: pointer;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.whatsapp-toggle.active { background: var(--primary); }
.whatsapp-toggle-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--text);
  position: absolute;
  top: 2px; left: 2px;
  transition: transform 0.2s;
}
.whatsapp-toggle.active .whatsapp-toggle-thumb {
  transform: translateX(18px);
  background: var(--bg);
}

/* Responsive */
@media (max-width: 900px) {
  .automation-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-row-2 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { width: 56px; min-width: 56px; padding: 14px 8px; }
  .sidebar-brand-text, .sidebar-item span:not(.sidebar-item-badge), .sidebar-label, .sidebar-user-info { display: none; }
  .sidebar-item { justify-content: center; padding: 10px; }
  .sidebar-brand { justify-content: center; }
  .builder-shell { grid-template-columns: 64px 1fr; }
  .node-palette { padding: 12px 8px; }
  .palette-item-text { display: none; }
  .palette-item { justify-content: center; padding: 10px; }
  .palette-info { display: none; }
  .canvas-minimap { width: 130px; height: 90px; }
  .dash-grid, .dash-row-2 { padding-left: 16px; padding-right: 16px; }
  .screen-header, .kanban-header { padding-left: 16px; padding-right: 16px; }
  .kanban-board { padding: 8px 16px 16px; }
}
