@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,300&display=swap');

/* ─── DESIGN TOKENS ──────────────────────────────────────── */
:root {
  --bg:            #0a0f1e;
  --bg-2:          #0d1428;
  --bg-card:       rgba(255,255,255,0.03);
  --bg-card-hover: rgba(255,255,255,0.055);
  --border:        rgba(59,130,246,0.14);
  --border-hover:  rgba(59,130,246,0.38);
  --blue:          #3b82f6;
  --blue-light:    #60a5fa;
  --blue-dim:      rgba(59,130,246,0.12);
  --blue-glow:     rgba(59,130,246,0.22);
  --text:          #f0f4ff;
  --text-2:        rgba(240,244,255,0.55);
  --text-3:        rgba(240,244,255,0.28);
  --green:         #10b981;
  --green-dim:     rgba(16,185,129,0.15);
  --red:           #ef4444;
  --red-dim:       rgba(239,68,68,0.15);
  --yellow:        #f59e0b;
  --yellow-dim:    rgba(245,158,11,0.15);
  --gray-dim:      rgba(255,255,255,0.07);
  --sidebar-w:     228px;
  --header-h:      60px;
  --radius:        12px;
  --radius-sm:     8px;
  --ease:          cubic-bezier(0.4,0,0.2,1);
}

/* ─── RESET ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }
ul { list-style: none; }

/* ─── SPACE BACKGROUND ──────────────────────────────────── */
body::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 70% 55% at 15% -10%, rgba(59,130,246,0.07) 0%, transparent 55%),
    radial-gradient(ellipse 45% 40% at 88% 105%, rgba(99,102,241,0.05) 0%, transparent 50%),
    radial-gradient(ellipse 30% 25% at 60% 50%, rgba(59,130,246,0.025) 0%, transparent 60%);
}

/* ─── LAYOUT ─────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; position: relative; z-index: 1; }

/* ─── SIDEBAR ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: rgba(13,20,40,0.85);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  backdrop-filter: blur(20px);
  z-index: 100;
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 22px 20px 20px;
  border-bottom: 1px solid var(--border);
}
.logo-mark {
  width: 30px; height: 30px;
  background: var(--blue-dim);
  border: 1px solid var(--border-hover);
  border-radius: 8px;
  display: grid; place-items: center;
  box-shadow: 0 0 14px var(--blue-glow);
  flex-shrink: 0;
}
.logo-mark svg { width: 15px; height: 15px; }
.logo-text {
  font-family: 'Syne', sans-serif;
  font-size: 1rem; font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
}
.logo-text span { color: var(--blue-light); }

.sidebar-nav {
  flex: 1;
  padding: 14px 12px;
  display: flex; flex-direction: column; gap: 2px;
}
.nav-section-label {
  font-size: 0.65rem; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-3);
  padding: 10px 10px 6px;
}
.nav-item a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 500;
  color: var(--text-2);
  transition: all 0.18s var(--ease);
  position: relative;
}
.nav-item a svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7; transition: opacity 0.18s; }
.nav-item a:hover { background: var(--bg-card-hover); color: var(--text); }
.nav-item a:hover svg { opacity: 1; }
.nav-item.active a {
  background: var(--blue-dim);
  color: var(--blue-light);
  border: 1px solid var(--border-hover);
}
.nav-item.active a svg { opacity: 1; color: var(--blue-light); }
.nav-item.active a::before {
  content: '';
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 16px;
  background: var(--blue);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 8px var(--blue);
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}
.status-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: rgba(16,185,129,0.08);
  border: 1px solid rgba(16,185,129,0.2);
  border-radius: 20px;
  font-size: 0.75rem; color: var(--green);
}
.status-dot {
  width: 6px; height: 6px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16,185,129,0.4); }
  50% { box-shadow: 0 0 0 4px rgba(16,185,129,0); }
}

/* ─── MAIN CONTENT ───────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 100vh;
}

/* ─── HEADER ─────────────────────────────────────────────── */
.header {
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(10,15,30,0.7);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 50;
}
.header-title { font-family: 'Syne', sans-serif; font-size: 1.05rem; font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 12px; }
.header-badge {
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.05em;
  padding: 3px 9px;
  background: var(--blue-dim);
  border: 1px solid var(--border-hover);
  border-radius: 20px;
  color: var(--blue-light);
}
.avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--blue) 0%, #6366f1 100%);
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: 'Syne', sans-serif;
  font-size: 0.75rem; font-weight: 700;
  color: white;
  border: 1px solid rgba(255,255,255,0.15);
}

/* ─── PAGE CONTENT ───────────────────────────────────────── */
.content { padding: 28px; flex: 1; }
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px;
}
.page-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.5rem; font-weight: 700;
  line-height: 1.2;
}
.page-subtitle { font-size: 0.825rem; color: var(--text-2); margin-top: 4px; }

/* ─── STAT CARDS ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all 0.22s var(--ease);
  position: relative;
  overflow: visible; /* tooltip del info-tip se asoma encima del card */
}
.stat-card::before {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--blue), transparent);
  opacity: 0;
  transition: opacity 0.22s;
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}
.stat-card:hover { border-color: var(--border-hover); background: var(--bg-card-hover); box-shadow: 0 4px 24px var(--blue-glow); }
.stat-card:hover::before { opacity: 1; }
.stat-label { font-size: 0.72rem; font-weight: 500; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3); margin-bottom: 10px; }
.stat-value {
  font-family: 'Syne', sans-serif;
  font-size: 2rem; font-weight: 700;
  line-height: 1;
}
.stat-icon {
  position: absolute; right: 16px; top: 16px;
  width: 32px; height: 32px;
  border-radius: 8px;
  display: grid; place-items: center;
}
.stat-icon svg { width: 16px; height: 16px; }
.stat-card.blue .stat-icon  { background: var(--blue-dim); color: var(--blue-light); }
.stat-card.red .stat-icon   { background: var(--red-dim); color: var(--red); }
.stat-card.yellow .stat-icon{ background: var(--yellow-dim); color: var(--yellow); }
.stat-card.gray .stat-icon  { background: var(--gray-dim); color: var(--text-2); }
.stat-card.blue  .stat-value { color: var(--blue-light); }
.stat-card.red   .stat-value { color: var(--red); }
.stat-card.yellow .stat-value { color: var(--yellow); }
.stat-card.green .stat-icon { background: rgba(22,163,74,0.14); color: #22c55e; }
.stat-card.green .stat-value { color: #22c55e; }
.stat-sub {
  margin-top: 4px;
  font-size: 0.74rem;
  color: var(--text-3);
}

/* ─── DATE PICKER ────────────────────────────────────────── */
.input-date {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 6px 10px;
  font-size: 0.78rem;
  font-family: inherit;
  color-scheme: dark;
}
.input-date:focus { outline: none; border-color: var(--blue-light); }
.preset-btn.active,
.filter-pill.active {
  background: var(--blue-dim);
  color: var(--blue-light);
  border-color: rgba(59,130,246,0.4);
}

/* ─── INFO TOOLTIP ──────────────────────────────────────── */
.info-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px; height: 14px;
  margin-left: 4px;
  border-radius: 50%;
  font-size: 0.7rem;
  color: var(--text-3);
  cursor: help;
  position: relative;
  font-style: normal;
  vertical-align: middle;
}
.info-tip:hover { color: var(--blue-light); }
.info-tip:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15,23,42,0.98);
  color: #e2e8f0;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.74rem;
  font-weight: 400;
  line-height: 1.45;
  width: max-content;
  max-width: 280px;
  white-space: pre-wrap;
  text-transform: none;
  letter-spacing: normal;
  z-index: 1000;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  border: 1px solid rgba(59,130,246,0.2);
  pointer-events: none;
}
.info-tip:hover::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(15,23,42,0.98);
  z-index: 1000;
  pointer-events: none;
}

/* ─── ACTION BUTTONS (CRM) ──────────────────────────────── */
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  margin-left: 4px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}
.action-btn:hover { background: var(--bg-card-hover); color: var(--text); border-color: var(--border-hover); }
.action-btn.whatsapp { color: #25d366; border-color: rgba(37,211,102,0.3); }
.action-btn.whatsapp:hover { background: rgba(37,211,102,0.12); border-color: #25d366; }
.action-btn.email:hover { color: var(--blue-light); border-color: rgba(59,130,246,0.4); }

/* ─── PRODUCT TAG ───────────────────────────────────────── */
.product-tag {
  display: inline-block;
  padding: 3px 9px;
  font-size: 0.72rem;
  font-weight: 500;
  background: var(--blue-dim);
  color: var(--blue-light);
  border-radius: 999px;
  border: 1px solid rgba(59,130,246,0.25);
}

/* ─── CARDS ──────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s;
}
.card:hover { border-color: rgba(59,130,246,0.22); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-family: 'Syne', sans-serif;
  font-size: 0.875rem; font-weight: 600;
}
.card-body { padding: 20px; }

/* ─── TABLE ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 11px 16px;
  font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text-3);
  text-align: left;
  border-bottom: 1px solid var(--border);
}
tbody tr {
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.15s;
}
tbody tr:hover { background: rgba(255,255,255,0.025); }
tbody tr:last-child { border-bottom: none; }
td { padding: 13px 16px; font-size: 0.825rem; vertical-align: middle; }
.td-email { color: var(--text-2); font-size: 0.775rem; margin-top: 2px; }
.td-name { font-weight: 500; }

/* ─── BADGES ─────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  white-space: nowrap;
}
.badge-dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.badge-green  { background: var(--green-dim);  color: var(--green);  border: 1px solid rgba(16,185,129,0.25);  }
.badge-green .badge-dot  { background: var(--green); }
.badge-red    { background: var(--red-dim);    color: var(--red);    border: 1px solid rgba(239,68,68,0.25);   }
.badge-red .badge-dot    { background: var(--red); }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(245,158,11,0.25); }
.badge-yellow .badge-dot { background: var(--yellow); }
.badge-blue   { background: var(--blue-dim);   color: var(--blue-light); border: 1px solid var(--border-hover); }
.badge-blue .badge-dot   { background: var(--blue-light); }
.badge-gray   { background: var(--gray-dim);   color: var(--text-2); border: 1px solid rgba(255,255,255,0.1);  }
.badge-gray .badge-dot   { background: var(--text-3); }

/* ─── BUTTONS ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.825rem; font-weight: 600;
  transition: all 0.18s var(--ease);
  letter-spacing: 0.01em;
}
.btn svg { width: 14px; height: 14px; }
.btn-primary {
  background: var(--blue); color: white;
  border: 1px solid transparent;
  box-shadow: 0 0 20px rgba(59,130,246,0.25);
}
.btn-primary:hover { background: var(--blue-light); box-shadow: 0 0 28px rgba(59,130,246,0.4); }
.btn-outline {
  background: transparent; color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--border-hover); color: var(--text); background: var(--bg-card-hover); }
.btn-ghost {
  background: transparent; color: var(--text-3);
  border: 1px solid transparent;
  padding: 6px 10px;
}
.btn-ghost:hover { color: var(--text-2); background: var(--bg-card-hover); }
.btn-danger {
  background: var(--red-dim); color: var(--red);
  border: 1px solid rgba(239,68,68,0.25);
}
.btn-danger:hover { background: rgba(239,68,68,0.22); border-color: rgba(239,68,68,0.4); }
.btn-success {
  background: var(--green-dim); color: var(--green);
  border: 1px solid rgba(16,185,129,0.25);
}
.btn-success:hover { background: rgba(16,185,129,0.22); }
.btn-sm { padding: 6px 12px; font-size: 0.75rem; }

/* ─── FORMS ──────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.75rem; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 7px;
}
.form-input {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.85rem; color: var(--text);
  transition: all 0.18s var(--ease);
  outline: none;
}
.form-input:focus {
  border-color: var(--blue);
  background: rgba(59,130,246,0.06);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.form-input::placeholder { color: var(--text-3); }
.form-input[readonly] { cursor: default; color: var(--text-2); }
.form-input-wrap { position: relative; }
.form-input-action {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; cursor: pointer;
  color: var(--text-3); padding: 4px;
  transition: color 0.15s;
}
.form-input-action:hover { color: var(--blue-light); }
select.form-input { appearance: none; cursor: pointer; }

/* ─── PROGRESS BAR ───────────────────────────────────────── */
.progress-wrap { margin-bottom: 22px; }
.progress-label {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.72rem; color: var(--text-3);
  margin-bottom: 7px;
}
.progress-track {
  height: 4px; background: var(--border);
  border-radius: 4px; overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--blue-light));
  border-radius: 4px;
  box-shadow: 0 0 8px var(--blue);
  transition: width 0.5s var(--ease);
}

/* ─── SEARCH & FILTERS ───────────────────────────────────── */
.filters-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px;
}
.search-wrap { position: relative; flex: 1; max-width: 340px; }
.search-wrap svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--text-3); pointer-events: none;
}
.search-wrap input { padding-left: 35px; }
.filter-select { width: auto; padding: 10px 14px; }

/* ─── SIMULATOR ──────────────────────────────────────────── */
.flow-nodes {
  display: flex; align-items: center; justify-content: center;
  gap: 0; margin-bottom: 32px;
}
.flow-node {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 20px 28px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 150px; text-align: center;
  transition: all 0.3s var(--ease);
}
.flow-node.active  { border-color: var(--blue);  box-shadow: 0 0 24px var(--blue-glow); }
.flow-node.success { border-color: var(--green); box-shadow: 0 0 20px rgba(16,185,129,0.2); }
.flow-connector {
  width: 50px; height: 1px;
  background: linear-gradient(90deg, var(--border), var(--border));
  position: relative;
  flex-shrink: 0;
}
.flow-connector::after {
  content: '';
  position: absolute; right: -4px; top: -3px;
  border: 3px solid transparent;
  border-left: 5px solid var(--border);
}
.flow-node-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 1.3rem;
  background: var(--bg-card-hover);
  border: 1px solid var(--border);
}
.flow-node-name { font-family: 'Syne', sans-serif; font-size: 0.85rem; font-weight: 600; }
.flow-node-status { font-size: 0.7rem; color: var(--text-3); }

.sim-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 20px; }
.btn-sim {
  padding: 16px; border-radius: var(--radius);
  font-size: 0.9rem; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: all 0.2s var(--ease);
  border: 1px solid transparent;
}
.btn-sim svg { width: 22px; height: 22px; }
.btn-sim span { font-size: 0.7rem; font-weight: 400; opacity: 0.7; }
.btn-sim-purchase {
  background: var(--green-dim); color: var(--green);
  border-color: rgba(16,185,129,0.25);
}
.btn-sim-purchase:hover { background: rgba(16,185,129,0.2); transform: translateY(-1px); box-shadow: 0 8px 20px rgba(16,185,129,0.15); }
.btn-sim-cancel {
  background: var(--red-dim); color: var(--red);
  border-color: rgba(239,68,68,0.25);
}
.btn-sim-cancel:hover { background: rgba(239,68,68,0.2); transform: translateY(-1px); box-shadow: 0 8px 20px rgba(239,68,68,0.15); }

.log-panel {
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-family: 'Courier New', monospace;
  font-size: 0.775rem;
  min-height: 180px; max-height: 280px;
  overflow-y: auto;
  margin-top: 20px;
}
.log-line { padding: 3px 0; line-height: 1.6; }
.log-line.info  { color: var(--blue-light); }
.log-line.ok    { color: var(--green); }
.log-line.error { color: var(--red); }
.log-line.dim   { color: var(--text-3); }
.log-cursor { display: inline-block; animation: blink 1.2s step-end infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* ─── TOAST ──────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.825rem; font-weight: 500;
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  transform: translateY(80px); opacity: 0;
  transition: all 0.3s var(--ease);
  z-index: 999;
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast.toast-ok    { background: rgba(16,185,129,0.15);  border-color: rgba(16,185,129,0.3);  color: var(--green); }
#toast.toast-error { background: rgba(239,68,68,0.15);   border-color: rgba(239,68,68,0.3);   color: var(--red); }
#toast.toast-info  { background: rgba(59,130,246,0.15);  border-color: var(--border-hover);   color: var(--blue-light); }

/* ─── EMPTY STATE ────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 48px 24px;
  color: var(--text-3);
}
.empty-state svg { width: 36px; height: 36px; margin: 0 auto 14px; opacity: 0.35; display: block; }
.empty-state p { font-size: 0.85rem; }

/* ─── SKELETON ───────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, rgba(255,255,255,0.06) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }
.skeleton-row { height: 42px; margin-bottom: 8px; }

/* ─── GRID HELPERS ───────────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ─── COPY FIELD ─────────────────────────────────────────── */
.copy-field {
  display: flex; align-items: center;
  background: rgba(59,130,246,0.06);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.copy-field input {
  flex: 1; border: none; background: transparent;
  padding: 10px 14px; font-size: 0.775rem;
  color: var(--blue-light); font-family: 'Courier New', monospace;
}
.copy-field input:focus { outline: none; }
.copy-btn {
  padding: 10px 14px;
  background: var(--blue-dim);
  border-left: 1px solid var(--border-hover);
  color: var(--blue-light);
  font-size: 0.75rem; font-weight: 600;
  transition: background 0.15s;
  flex-shrink: 0;
}
.copy-btn:hover { background: rgba(59,130,246,0.2); }

/* ─── MISC ───────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.font-syne { font-family: 'Syne', sans-serif; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.whatsapp-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px;
  background: rgba(37,211,102,0.1);
  border: 1px solid rgba(37,211,102,0.25);
  border-radius: 20px;
  font-size: 0.7rem; font-weight: 600;
  color: #25d366;
  transition: all 0.15s;
}
.whatsapp-btn:hover { background: rgba(37,211,102,0.18); }

/* ─── EXPANDABLE ROW ─────────────────────────────────────── */
.row-detail {
  background: rgba(0,0,0,0.25);
  border-bottom: 1px solid var(--border);
  display: none;
}
.row-detail.open { display: table-row; }
.row-detail td { padding: 12px 16px; }
.json-block {
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: 'Courier New', monospace;
  font-size: 0.72rem;
  color: var(--text-2);
  overflow-x: auto;
  white-space: pre;
  max-height: 200px;
  overflow-y: auto;
}

/* ─── INLINE FORM ────────────────────────────────────────── */
.inline-form-row {
  display: none;
  background: rgba(59,130,246,0.04);
  border-bottom: 1px solid var(--border-hover);
}
.inline-form-row.open { display: table-row; }
.inline-form-row td { padding: 12px 16px; }
.inline-form-fields { display: flex; gap: 10px; align-items: center; }
.inline-form-fields .form-input { margin-bottom: 0; }

/* ─── AUTOMATION RULES ──────────────────────────────────── */
.rule-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 14px;
  transition: border-color 0.18s, transform 0.18s;
}
.rule-card:hover { border-color: var(--border-hover); }
.rule-card.rule-inactive { opacity: 0.55; }
.rule-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.rule-icon {
  width: 36px; height: 36px;
  background: var(--blue-dim);
  color: var(--blue-light);
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 1rem;
}
.rule-name { font-size: 0.95rem; font-weight: 600; color: var(--text-1); }
.rule-meta { font-size: 0.74rem; color: var(--text-3); margin-top: 2px; }
.rule-meta code { background: var(--bg-card-hover); padding: 1px 6px; border-radius: 4px; font-size: 0.7rem; }
.rule-flow {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 12px;
  background: var(--bg-card-hover);
  border-radius: 8px;
  margin-bottom: 12px;
}
.flow-step { display: flex; align-items: center; gap: 8px; }
.flow-step-icon {
  width: 26px; height: 26px;
  border-radius: 6px;
  display: grid; place-items: center;
  font-size: 0.85rem;
  border: 1px solid var(--border);
}
.flow-step-name { font-size: 0.78rem; font-weight: 500; color: var(--text-1); }
.flow-step-detail { font-size: 0.7rem; color: var(--text-3); }
.flow-arrow { color: var(--text-3); font-size: 1rem; }
.rule-courses {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.course-chip {
  background: var(--blue-dim);
  border: 1px solid var(--border-hover);
  color: var(--blue-light);
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
}

/* ─── MODAL ─────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%; max-width: 640px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 80px rgba(0,0,0,0.5), 0 0 0 1px rgba(59,130,246,0.05);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1.05rem; font-weight: 600; color: var(--text-1); }
.modal-sub { font-size: 0.78rem; color: var(--text-3); margin-top: 4px; }
.modal-body { padding: 20px 22px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
}
.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  color: var(--text-3);
  cursor: pointer;
  transition: all 0.18s;
}
.icon-btn:hover { color: var(--text-1); border-color: var(--border-hover); }

/* ─── STEP CARDS (Trigger / Action) ────────────────────── */
.step-card {
  background: var(--bg-card-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-bottom: 4px;
}
.step-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.step-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 0.95rem;
  border: 1px solid var(--border);
}
.step-title { font-size: 0.85rem; font-weight: 600; color: var(--text-1); }
.step-sub { font-size: 0.72rem; color: var(--text-3); }
.step-arrow {
  text-align: center;
  color: var(--text-3);
  font-size: 1.2rem;
  margin: 6px 0;
}

/* ─── CHECKBOXES ────────────────────────────────────────── */
.checkbox-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 0.82rem;
  color: var(--text-2);
  cursor: pointer;
}
.checkbox-row input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--blue);
  cursor: pointer;
}

.course-list {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 280px;
  overflow-y: auto;
}
.course-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.12s;
}
.course-row:last-child { border-bottom: none; }
.course-row:hover { background: var(--bg-card-hover); }
.course-row input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--blue);
  cursor: pointer;
}

/* ─── EVENT SOURCE BADGE ────────────────────────────────── */
.event-source {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  margin-right: 8px;
  vertical-align: middle;
}
.event-source.hotmart { background: rgba(255,80,0,0.12); }
.event-source.skool   { background: var(--bg-card-hover); font-family: 'Syne', sans-serif; color: var(--text-1); }

/* ─── TIMELINE (member detail) ─────────────────────────── */
.timeline {
  position: relative;
  padding-left: 22px;
  margin-top: 14px;
}
.timeline::before {
  content: '';
  position: absolute; left: 7px; top: 4px; bottom: 4px;
  width: 2px;
  background: linear-gradient(180deg, var(--border) 0%, transparent 100%);
}
.timeline-item {
  position: relative;
  padding: 10px 14px 14px 0;
  margin-bottom: 6px;
}
.timeline-item::before {
  content: '';
  position: absolute; left: -19px; top: 16px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 3px var(--bg);
}
.timeline-item.skool::before   { background: var(--text-2); }
.timeline-item.hotmart::before { background: #ff5000; }
.timeline-time { font-size: 0.7rem; color: var(--text-3); margin-bottom: 4px; }
.timeline-title { font-size: 0.85rem; color: var(--text); margin-bottom: 2px; }
.timeline-detail { font-size: 0.74rem; color: var(--text-2); }

/* ─── WEBHOOK URL BOX ──────────────────────────────────── */
.webhook-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.webhook-box-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.78rem;
  color: var(--text-2);
  margin-bottom: 8px;
  font-weight: 600;
}
.webhook-box-label .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}
.webhook-box-help {
  font-size: 0.72rem;
  color: var(--text-3);
  margin-top: 8px;
  line-height: 1.5;
}

/* ─── EVENTS LIVE FEED ─────────────────────────────────── */
.feed { display: flex; flex-direction: column; gap: 8px; }
.feed-item {
  display: grid;
  grid-template-columns: 100px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.15s;
}
.feed-item:hover { border-color: var(--border-hover); background: var(--bg-card-hover); }
.feed-item.new   { animation: slideIn 0.4s var(--ease); border-left: 3px solid var(--blue); }
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.feed-time { font-size: 0.7rem; color: var(--text-3); font-variant-numeric: tabular-nums; }
.feed-body { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.feed-email { font-size: 0.8rem; color: var(--text); }
.feed-meta  { font-size: 0.7rem; color: var(--text-3); }
.feed-toggle { font-size: 0.7rem; color: var(--text-3); cursor: pointer; }
.feed-payload {
  display: none;
  grid-column: 1 / -1;
  margin-top: 10px;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 320px;
  overflow-y: auto;
}
.feed-item.expanded .feed-payload { display: block; }

/* ─── TAGS / NOTES (CRM) ───────────────────────────────── */
.tag-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  background: var(--blue-dim);
  color: var(--blue-light);
  border: 1px solid var(--border);
}
.tag-chip .x { cursor: pointer; opacity: 0.6; }
.tag-chip .x:hover { opacity: 1; }
.note-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.note-bubble .ts { font-size: 0.68rem; color: var(--text-3); margin-bottom: 4px; }
.note-bubble .body { font-size: 0.82rem; color: var(--text); white-space: pre-wrap; }
