/* ============================================================
   attrio — Panel de atribución · tema oscuro premium
   ============================================================ */

:root {
  --bg: #0b0e14;
  --bg2: #11151d;
  --surface: #141924;
  --surface-2: #1a2030;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #e8ecf4;
  --muted: #8a94a8;
  --muted-2: #5c6577;
  --green: #34d399;
  --cyan: #22d3ee;
  --grad: linear-gradient(100deg, #34d399, #22d3ee);
  --red: #f87171;
  --amber: #fbbf24;
  --violet: #a78bfa;
  /* Escala de radios coherente */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.25);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --ring: 0 0 0 3px rgba(52, 211, 153, 0.28);
  --tr: 160ms cubic-bezier(0.4, 0, 0.2, 1);
  --tr-fast: 120ms ease;
}

/* ---------- Iconos SVG de trazo ---------- */

.icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  color: currentColor;
}

/* Selección de texto con color de marca */
::selection {
  background: rgba(52, 211, 153, 0.28);
  color: #eafff8;
}

/* Focus visible accesible y consistente en toda la app */
:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--radius-sm);
}
a:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.22); }

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(34, 211, 238, 0.06), transparent 60%),
    radial-gradient(900px 500px at -10% 0%, rgba(52, 211, 153, 0.05), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#root {
  min-height: 100vh;
}

h1, h2, h3 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.015em;
}

h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }

a { color: inherit; text-decoration: none; }
.link { color: var(--cyan); }
.link:hover { text-decoration: underline; }

code {
  font-family: 'SF Mono', ui-monospace, Menlo, monospace;
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
}

.mono { font-family: 'SF Mono', ui-monospace, Menlo, monospace; font-size: 12px; }

/* Números tabulares en TODAS las métricas */
.num { font-variant-numeric: tabular-nums; }

.muted { color: var(--muted); }
.pos { color: var(--green); }
.neg { color: var(--red); }
.amber-text { color: var(--amber); }

.grad-text {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* ---------- Wordmark ---------- */

.wordmark {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.03em;
  color: var(--text);
  display: inline-block;
}

.wordmark-lg { font-size: 34px; }

.wordmark-dot {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ---------- Layout shell ---------- */

.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 216px;
  flex-shrink: 0;
  padding: 22px 14px;
  border-right: 1px solid var(--border);
  background: rgba(17, 21, 29, 0.6);
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Marca: punto en degradado + wordmark */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 2px 4px;
}

.brand-mark {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--grad);
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.45);
  transform: rotate(45deg);
  flex-shrink: 0;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 500;
  transition: background var(--tr-fast), color var(--tr-fast);
}

.nav-item:hover { background: rgba(255, 255, 255, 0.045); color: var(--text); }

/* Indicador de barra lateral izquierda de 2px + acento */
.nav-item-active {
  background: rgba(52, 211, 153, 0.08);
  color: var(--text);
}

.nav-item-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 18px;
  border-radius: 2px;
  background: var(--grad);
}

.nav-item-active .nav-icon { color: var(--green); opacity: 1; }

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 21px;
  height: 21px;
  opacity: 0.92;
  transition: color var(--tr-fast), opacity var(--tr-fast);
}

.nav-item:hover .nav-icon { opacity: 1; }

.nav-setup {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px dashed rgba(251, 191, 36, 0.4);
  border-radius: 9px;
  color: var(--amber);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--tr);
}

.nav-setup:hover { background: rgba(251, 191, 36, 0.07); }

.nav-setup-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.shell-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 56px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  background: rgba(11, 14, 20, 0.82);
  backdrop-filter: blur(10px);
  z-index: 40;
}

.topbar-right { display: flex; align-items: center; gap: 14px; }

.tenant-switch {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--tr);
}

.tenant-switch:hover { border-color: var(--border-strong); }

/* Workspace fijo del cliente (sin selector) */
.tenant-fixed {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.tenant-fixed-mark {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--grad);
  color: #06251e;
  font-weight: 800;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.content {
  padding: 26px 30px 60px;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
}

.content-solo { min-height: 100vh; }

/* ---------- Badge de salud CAPI ---------- */

.health {
  display: inline-flex;
  align-items: center;
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color var(--tr);
}

.health:hover { border-color: var(--border-strong); }

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 7px;
}

.health-ok .health-dot { background: var(--green); box-shadow: 0 0 8px rgba(52, 211, 153, 0.7); }
.health-ok { color: var(--green); }
.health-warn .health-dot { background: var(--amber); box-shadow: 0 0 8px rgba(251, 191, 36, 0.6); }
.health-warn { color: var(--amber); }
.health-bad .health-dot { background: var(--red); box-shadow: 0 0 8px rgba(248, 113, 113, 0.6); }
.health-bad { color: var(--red); }

/* ---------- Página ---------- */

.page { display: flex; flex-direction: column; gap: 18px; }
.page-narrow { max-width: 860px; margin: 0 auto; width: 100%; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

/* ---------- Cards ---------- */

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent 40%), var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.form-card { display: flex; flex-direction: column; gap: 14px; }

/* ---------- KPI cards ---------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.kpi { display: flex; flex-direction: column; gap: 6px; padding: 20px 22px; }

/* KPI principal: acento de marca sutil (degradado + hairline superior) */
.kpi-accent {
  position: relative;
  border-color: rgba(52, 211, 153, 0.22);
  background:
    radial-gradient(340px 130px at 15% -10%, rgba(52, 211, 153, 0.1), transparent 70%),
    var(--surface);
  overflow: hidden;
}

.kpi-accent::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--grad);
  opacity: 0.85;
}

.kpi-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* Los números KPI cantan: grandes, densos, tabulares */
.kpi-value {
  font-size: 31px;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.kpi-sm .kpi-value { font-size: 24px; }

.kpi-delta { font-size: 12px; min-height: 18px; }

.delta { font-weight: 600; }
.delta-good { color: var(--green); }
.delta-bad { color: var(--red); }
.delta-neutral { color: var(--muted); }
.delta-empty { color: var(--muted-2); font-weight: 400; }

.kpi-secondary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 28px;
  color: var(--muted);
  font-size: 13px;
  padding: 2px 4px;
}

.kpi-secondary b { color: var(--text); font-weight: 600; }
.kpi-secondary b.neg { color: var(--red); }

/* ---------- Botones ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  border-radius: 9px;
  padding: 9px 16px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform var(--tr), box-shadow var(--tr), background var(--tr), border-color var(--tr), opacity var(--tr);
  white-space: nowrap;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Iconos dentro de botones: alineados con el texto, no fuerzan color propio */
.btn .icon { margin: 0 -1px; }
.btn-sm .icon { margin: 0 -2px; }

.btn-primary {
  background: var(--grad);
  color: #06251e;
  box-shadow: 0 4px 16px rgba(34, 211, 238, 0.22);
}

.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(34, 211, 238, 0.3); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.05); }

.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 7px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-block { width: 100%; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 6px;
  border-radius: 7px;
  transition: background var(--tr-fast), color var(--tr-fast);
}

.btn-icon:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }

/* ---------- Chips / segmentos / tabs ---------- */

.chip {
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 13px;
  cursor: pointer;
  transition: all var(--tr);
}

.chip:hover { color: var(--text); border-color: var(--border-strong); }

.chip-active {
  color: #06251e;
  background: var(--grad);
  border-color: transparent;
}

.daterange { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.daterange-custom { display: inline-flex; align-items: center; gap: 6px; }
.daterange-sep { color: var(--muted-2); }

input[type='date'] {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 9px;
  font: inherit;
  font-size: 12.5px;
  color-scheme: dark;
}

.toolbar { display: flex; gap: 12px; flex-wrap: wrap; }

.seg {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.seg-btn {
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 7px;
  padding: 6px 13px;
  cursor: pointer;
  transition: all var(--tr);
}

.seg-btn:hover { color: var(--text); }

.seg-active {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border-strong), 0 1px 4px rgba(0, 0, 0, 0.3);
}

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }

.tab {
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  padding: 9px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--tr), border-color var(--tr);
}

.tab:hover { color: var(--text); }
.tab-active { color: var(--text); border-image: var(--grad) 1; border-bottom: 2px solid var(--green); }

.model-chip {
  display: inline-block;
  background: rgba(167, 139, 250, 0.12);
  color: var(--violet);
  border: 1px solid rgba(167, 139, 250, 0.3);
  border-radius: 999px;
  padding: 1px 10px;
  font-size: 12px;
  font-weight: 600;
}

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid;
  white-space: nowrap;
}

.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

.badge-green { color: var(--green); border-color: rgba(52, 211, 153, 0.35); background: rgba(52, 211, 153, 0.08); }
.badge-amber { color: var(--amber); border-color: rgba(251, 191, 36, 0.35); background: rgba(251, 191, 36, 0.07); }
.badge-red { color: var(--red); border-color: rgba(248, 113, 113, 0.35); background: rgba(248, 113, 113, 0.07); }
.badge-gray { color: var(--muted); border-color: var(--border-strong); background: rgba(255, 255, 255, 0.03); }
.badge-cyan { color: var(--cyan); border-color: rgba(34, 211, 238, 0.35); background: rgba(34, 211, 238, 0.07); }
.badge-violet { color: var(--violet); border-color: rgba(167, 139, 250, 0.35); background: rgba(167, 139, 250, 0.08); }

.kind-chip {
  margin-left: 8px;
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
}

.configured-chip {
  margin-left: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--green);
}

/* ---------- Banners ---------- */

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: var(--radius);
  padding: 12px 16px;
  border: 1px solid;
  font-size: 13.5px;
}

.banner-body { flex: 1; }
.banner-icon { font-size: 15px; }
.banner-amber { border-color: rgba(251, 191, 36, 0.35); background: rgba(251, 191, 36, 0.06); color: #fde68a; }
.banner-red { border-color: rgba(248, 113, 113, 0.35); background: rgba(248, 113, 113, 0.06); color: #fecaca; }
.banner-cyan { border-color: rgba(34, 211, 238, 0.3); background: rgba(34, 211, 238, 0.05); color: #a5f3fc; }
.banner b { color: var(--text); }

/* ---------- Formularios ---------- */

.field { display: flex; flex-direction: column; gap: 6px; }

.field > span { font-size: 12.5px; font-weight: 600; color: var(--muted); }

.field input,
.field select,
.field textarea {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
  transition: border-color var(--tr), box-shadow var(--tr);
  width: 100%;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: rgba(52, 211, 153, 0.5);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.12);
}

.field input[aria-invalid='true'] { border-color: rgba(248, 113, 113, 0.6); }
.field input:disabled { opacity: 0.5; }

.field-hint { font-size: 12px; color: var(--muted-2); font-weight: 400; }
.field-hint-error { color: var(--red); }

.field-inline { flex-direction: row; align-items: center; gap: 8px; }
.field-inline > span { white-space: nowrap; }
.field-inline input { width: auto; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.form-error {
  color: var(--red);
  background: rgba(248, 113, 113, 0.07);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 13px;
}

.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.form-actions-split { justify-content: space-between; }
.form-actions-inline { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.field-grow { flex: 1; min-width: 220px; }

/* Título de sección con icono de trazo */
h3 .h3-icon,
.h3-icon {
  display: inline-flex;
  align-items: center;
  vertical-align: -2px;
  margin-right: 7px;
  color: var(--green);
}

/* ---------- Tablas ---------- */

.table-card { padding: 0; overflow: hidden; }

.table-scroll { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}

.th-sort { cursor: pointer; transition: color var(--tr); }
.th-sort:hover { color: var(--text); }
.th-active { color: var(--text); }
.sort-arrow { display: inline-block; width: 12px; margin-left: 3px; color: var(--green); }

.table td {
  padding: 11px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}

.table tbody tr { transition: background var(--tr); }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
.table tbody tr:last-child td { border-bottom: none; }

.td-right { text-align: right; }
.td-name { font-weight: 600; }
.td-name-1 { padding-left: 38px !important; font-weight: 500; }
.td-name-2 { padding-left: 62px !important; font-weight: 400; color: var(--muted); }

.tr-expandable { cursor: pointer; }
.tr-child { background: rgba(255, 255, 255, 0.012); }

.caret {
  display: inline-block;
  margin-right: 8px;
  color: var(--muted);
  transition: transform var(--tr);
}

.caret-open { transform: rotate(90deg); color: var(--green); }

.table-foot {
  display: flex;
  gap: 22px;
  align-items: center;
  padding: 11px 16px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--muted);
  flex-wrap: wrap;
}

.table-foot-split { justify-content: space-between; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.pager { display: inline-flex; gap: 8px; }

.rev-cell { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

.refund-note { font-size: 11.5px; color: var(--red); }

.capi-error {
  font-family: 'SF Mono', ui-monospace, Menlo, monospace;
  font-size: 12px;
  color: #fecaca;
  max-width: 420px;
  overflow-wrap: anywhere;
}

.capi-meta { display: flex; gap: 26px; flex-wrap: wrap; align-items: center; }

/* ---------- Barra apilada frontend/backend ---------- */

.splitbar { width: 120px; }
.splitbar-track {
  display: flex;
  height: 5px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--surface-2);
}
.splitbar-front { background: var(--cyan); }
.splitbar-back { background: var(--violet); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot-rev { background: var(--green); }
.dot-spend { background: var(--red); opacity: 0.8; }
.dot-muted { background: var(--muted); }
.dot-front { background: var(--cyan); }
.dot-back { background: var(--violet); }

/* ---------- Gráfico ---------- */

.chart-card { position: relative; }
.chart-wrap { position: relative; width: 100%; }

.chart-grid { stroke: rgba(255, 255, 255, 0.05); }
.chart-axis { fill: var(--muted-2); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.chart-line-rev { stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart-line-spend { stroke: var(--red); stroke-opacity: 0.65; stroke-width: 1.6; stroke-dasharray: 5 4; }
.chart-crosshair { stroke: rgba(255, 255, 255, 0.18); stroke-width: 1; }
.chart-dot-rev { fill: var(--green); stroke: var(--bg); stroke-width: 2; }
.chart-dot-spend { fill: var(--red); stroke: var(--bg); stroke-width: 2; }

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(17, 21, 29, 0.95);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 12.5px;
  box-shadow: var(--shadow);
  min-width: 180px;
  z-index: 10;
}

.chart-tooltip-date { font-weight: 700; margin-bottom: 6px; }

.chart-tooltip-row {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  padding: 1px 0;
}

.chart-tooltip-row b { margin-left: auto; color: var(--text); font-weight: 600; }

.chart-legend {
  display: flex;
  gap: 20px;
  padding-top: 10px;
  font-size: 12.5px;
  color: var(--muted);
}

.chart-legend > span { display: inline-flex; align-items: center; gap: 7px; }

/* ---------- Tooltips CSS ---------- */

.tt { position: relative; cursor: help; border-bottom: 1px dotted var(--muted-2); }
.tt-block { border-bottom: none; display: block; cursor: default; }

.tt::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(3px);
  background: #1d2433;
  color: var(--text);
  border: 1px solid var(--border-strong);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
  text-transform: none;
  letter-spacing: 0;
  padding: 8px 11px;
  border-radius: 8px;
  width: max-content;
  max-width: 260px;
  white-space: normal;
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--tr), transform var(--tr);
  z-index: 60;
  box-shadow: var(--shadow);
}

.tt:hover::after,
.tt:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Skeletons (sin spinners) ---------- */

.skel {
  border-radius: 9px;
  background: linear-gradient(90deg, var(--surface-2) 25%, #232b3d 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.skel-rows { display: flex; flex-direction: column; gap: 8px; padding: 16px; }

/* ---------- Estados vacíos (ilustración CSS pura) ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 46px 24px;
  gap: 8px;
}

.empty h3 { font-size: 15px; }
.empty p { color: var(--muted); max-width: 400px; margin: 0; font-size: 13px; }
.empty-action { margin-top: 10px; }

.empty-art {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  margin-bottom: 6px;
  border-radius: var(--radius);
  color: var(--green);
  background:
    radial-gradient(circle at 50% 40%, rgba(52, 211, 153, 0.1), transparent 70%),
    var(--surface-2);
  border: 1px solid var(--border);
}

.empty-art .icon { opacity: 0.9; }

/* ---------- Toasts ---------- */

.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  z-index: 100;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #1a2130;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  padding: 11px 16px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: toast-in 200ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
  max-width: 400px;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.toast-icon { font-size: 13px; font-weight: 700; }
.toast-ok .toast-icon { color: var(--green); }
.toast-error { border-color: rgba(248, 113, 113, 0.4); }
.toast-error .toast-icon { color: var(--red); }
.toast-info .toast-icon { color: var(--cyan); }

/* ---------- Modales ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 11, 0.7);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  animation: fade-in 150ms ease;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg2);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  width: min(480px, calc(100vw - 32px));
  box-shadow: var(--shadow);
  animation: modal-in 180ms cubic-bezier(0.2, 0.9, 0.3, 1.1);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 0;
}

.modal-body { padding: 14px 20px 20px; display: flex; flex-direction: column; gap: 12px; }
.modal-body form { display: flex; flex-direction: column; gap: 12px; }
.modal-foot { padding: 0 20px 18px; }

/* ---------- Copyblock ---------- */

.copyblock { display: flex; flex-direction: column; gap: 6px; }

.copyblock-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }

.copyblock-body {
  position: relative;
  background: #0d1119;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 90px 13px 15px;
}

.copyblock-body pre {
  margin: 0;
  font-family: 'SF Mono', ui-monospace, Menlo, monospace;
  font-size: 12px;
  line-height: 1.55;
  color: #a5f3fc;
  white-space: pre-wrap;
  word-break: break-all;
}

.copyblock-btn { position: absolute; top: 9px; right: 9px; }

/* ---------- Login ---------- */

.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 24px;
}

.login-card {
  width: min(380px, 100%);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 36px 32px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 18px;
  text-align: center;
}

.login-card form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.login-sub { margin: -10px 0 0; color: var(--muted); font-size: 13px; }
.login-foot { color: var(--muted-2); font-size: 12px; max-width: 420px; text-align: center; }

/* ---------- Boot ---------- */

.boot {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.boot-bar {
  width: 160px;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-2);
  overflow: hidden;
}

.boot-bar i {
  display: block;
  height: 100%;
  width: 40%;
  border-radius: 2px;
  background: var(--grad);
  animation: boot-slide 1.1s infinite ease-in-out;
}

@keyframes boot-slide {
  from { transform: translateX(-100%); }
  to { transform: translateX(400%); }
}

/* ---------- Tenants ---------- */

.tenant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.tenant-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  cursor: pointer;
  transition: transform var(--tr), border-color var(--tr), box-shadow var(--tr);
}

.tenant-card:hover {
  transform: translateY(-2px);
  border-color: rgba(52, 211, 153, 0.3);
  box-shadow: var(--shadow);
}

.tenant-card-head { display: flex; align-items: center; gap: 12px; }
.tenant-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; flex-wrap: wrap; }

.tenant-avatar {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--grad);
  color: #06251e;
  font-weight: 800;
  font-size: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tenant-slug { color: var(--muted-2); font-size: 12px; font-family: 'SF Mono', ui-monospace, Menlo, monospace; }

/* ---------- Wizard ---------- */

.wizard { gap: 22px; }
.wizard-top { text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; padding-top: 12px; }

.wizard-progress {
  display: flex;
  justify-content: center;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}

.wizard-dot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 10px;
  transition: background var(--tr);
}

.wizard-dot:hover { background: rgba(255, 255, 255, 0.04); }

.wizard-dot-i {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  font-weight: 700;
  transition: all var(--tr);
}

.wizard-dot-label { font-size: 11.5px; font-weight: 600; }

.wizard-dot-current .wizard-dot-i {
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15);
}

.wizard-dot-current { color: var(--text); }

.wizard-dot-done .wizard-dot-i {
  background: var(--grad);
  border-color: transparent;
  color: #06251e;
}

.wizard-card { display: flex; flex-direction: column; gap: 18px; padding: 26px 28px; }

.wizard-step { display: flex; flex-direction: column; gap: 16px; }

.wizard-step-head { display: flex; gap: 14px; align-items: flex-start; }

.wizard-step-num {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--grad);
  color: #06251e;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wizard-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.wizard-nav-right { display: flex; gap: 10px; }

.live-status {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  padding: 11px 14px;
}

.live-status-hint { font-size: 11.5px; }

.test-event { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.backfill { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }

.summary-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.summary-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 15px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.015);
}

.summary-item > div { flex: 1; }
.summary-item .muted { font-size: 12.5px; }

.summary-mark {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--muted);
  flex-shrink: 0;
}

.summary-done { border-color: rgba(52, 211, 153, 0.3); }
.summary-done .summary-mark {
  background: var(--grad);
  border-color: transparent;
  color: #06251e;
  font-weight: 800;
}

/* ---------- Integraciones (settings) ---------- */

.integration { border: 1px solid var(--border); border-radius: 10px; padding: 0 15px; }

.integration summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
}

.integration summary::-webkit-details-marker { display: none; }
.integration summary::before { content: '▸'; color: var(--muted); transition: transform var(--tr); }
.integration[open] summary::before { transform: rotate(90deg); color: var(--green); }

.integration-name { flex: 0 0 170px; }
.integration-updated { margin-left: auto; font-size: 12px; }

.integration-form { display: flex; flex-direction: column; gap: 12px; padding-bottom: 8px; }
.integration-form-compact { padding-bottom: 15px; }

/* ---------- Journey ---------- */

.journey-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  align-items: start;
}

.journey-search { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 76px; }

.person-results { padding: 6px; display: flex; flex-direction: column; gap: 2px; max-height: 420px; overflow-y: auto; }

.person-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  font: inherit;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--tr);
  width: 100%;
}

.person-row:hover { background: rgba(255, 255, 255, 0.04); }
.person-row-active { background: rgba(52, 211, 153, 0.09); box-shadow: inset 2px 0 0 var(--green); }
.person-email { font-weight: 600; overflow-wrap: anywhere; }
.person-meta { font-size: 12px; }

.journey-card { display: flex; flex-direction: column; gap: 20px; }

.journey-person { display: flex; align-items: center; gap: 13px; flex-wrap: wrap; }
.journey-person h3 { overflow-wrap: anywhere; }
.journey-person .muted { font-size: 12.5px; }

.timeline {
  list-style: none;
  margin: 0;
  padding: 4px 0 4px 6px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 21px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: linear-gradient(180deg, rgba(52, 211, 153, 0.35), rgba(34, 211, 238, 0.15));
  border-radius: 1px;
}

.tl-item { display: flex; gap: 14px; align-items: flex-start; position: relative; }

.tl-node {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--muted);
  flex-shrink: 0;
  z-index: 1;
}

.tl-paid .tl-node { color: var(--cyan); border-color: rgba(34, 211, 238, 0.4); }
.tl-email .tl-node { color: var(--violet); border-color: rgba(167, 139, 250, 0.4); }

.tl-node-order {
  background: var(--grad);
  color: #06251e;
  font-weight: 800;
  border: none;
  box-shadow: 0 0 16px rgba(52, 211, 153, 0.4);
}

.tl-card {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.015);
  min-width: 0;
}

.tl-card-order {
  border-color: rgba(52, 211, 153, 0.35);
  background:
    radial-gradient(400px 90px at 10% 0%, rgba(52, 211, 153, 0.08), transparent 70%),
    rgba(255, 255, 255, 0.015);
}

.tl-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.tl-ts { color: var(--muted-2); font-size: 12px; white-space: nowrap; }
.tl-url { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; margin-top: 3px; }
.tl-meta { font-size: 12px; margin-top: 3px; }

/* La venta de 17.000 € tiene que LUCIR */
.tl-amount {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-top: 6px;
  line-height: 1.1;
}

/* ---------- Chip "Solo lectura" (rol viewer) ---------- */

.readonly-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 999px;
  padding: 4px 11px;
  white-space: nowrap;
}

.readonly-chip-icon {
  display: inline-flex;
  align-items: center;
  opacity: 0.75;
}

/* ---------- Subtítulo en llano bajo cada KPI ---------- */

.kpi-sub {
  font-size: 12px;
  color: var(--muted-2);
  line-height: 1.4;
}

/* ---------- Mini-glosario expandible ---------- */

.glossary summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--muted);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 9px;
  user-select: none;
  transition: color var(--tr);
}

.glossary summary:hover { color: var(--text); }
.glossary summary::-webkit-details-marker { display: none; }
.glossary summary::before { content: '▸'; transition: transform var(--tr); }
.glossary[open] summary::before { transform: rotate(90deg); color: var(--green); }

/* ---------- Dominio propio: bloque opcional expandible ---------- */

.optional-domain {
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  padding: 0 15px;
}

.optional-domain summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 0;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--muted);
  list-style: none;
  user-select: none;
  transition: color var(--tr);
}

.optional-domain summary:hover { color: var(--text); }
.optional-domain summary::-webkit-details-marker { display: none; }
.optional-domain summary::before { content: '▸'; transition: transform var(--tr); }
.optional-domain[open] summary::before { transform: rotate(90deg); color: var(--green); }

.optional-domain-tag {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--cyan);
  border: 1px solid rgba(34, 211, 238, 0.3);
  border-radius: var(--radius-pill);
  padding: 1px 8px;
  flex-shrink: 0;
}

.optional-domain-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 2px 0 15px;
}

.optional-domain-body .muted {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
}

.glossary dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px 26px;
  margin: 16px 0 0;
}

.glossary dt { font-weight: 700; font-size: 13px; }
.glossary dd { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.5; }

/* ---------- Vista Funnel ---------- */

.funnel-card { padding: 26px 22px 22px; }

.funnel {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.funnel-step {
  background:
    linear-gradient(180deg, rgba(52, 211, 153, 0.10), rgba(34, 211, 238, 0.04)),
    var(--surface-2);
  border: 1px solid rgba(52, 211, 153, 0.28);
  border-radius: 14px;
  padding: 18px 26px;
  text-align: center;
  min-width: 240px;
  max-width: 100%;
  box-shadow: var(--shadow-sm);
  transition: width var(--tr);
}

.funnel-step-backend {
  border-color: rgba(167, 139, 250, 0.4);
  background:
    linear-gradient(180deg, rgba(167, 139, 250, 0.12), rgba(167, 139, 250, 0.03)),
    var(--surface-2);
}

.funnel-count {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.funnel-label { color: var(--muted); font-weight: 600; font-size: 13px; margin-top: 3px; }
.funnel-rev { margin-top: 7px; font-weight: 700; font-size: 15px; color: var(--green); }
.funnel-step-backend .funnel-rev { color: var(--violet); }

.funnel-conn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}

.funnel-conn-line {
  width: 2px;
  height: 12px;
  background: linear-gradient(180deg, rgba(52, 211, 153, 0.45), rgba(34, 211, 238, 0.2));
  border-radius: 1px;
}

.funnel-conv {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}

.funnel-conv b { font-weight: 800; color: var(--text); font-size: 13.5px; }

/* Tarjetas por campaña */

.camp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 14px;
}

.camp-card { display: flex; flex-direction: column; gap: 11px; }
.camp-card .splitbar { width: 100%; }

.camp-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-wrap: anywhere;
}

.camp-name-unknown { color: var(--muted); }

.camp-kind-chip {
  font-size: 11px;
  font-weight: 600;
  color: var(--violet);
  border: 1px solid rgba(167, 139, 250, 0.35);
  background: rgba(167, 139, 250, 0.08);
  border-radius: 5px;
  padding: 1px 6px;
  vertical-align: middle;
  margin-right: 4px;
}

.camp-invest { font-size: 13.5px; color: var(--muted); }
.camp-invest b { color: var(--text); font-weight: 700; }

.camp-phrase {
  font-size: 14px;
  font-weight: 700;
  border-radius: 9px;
  padding: 9px 13px;
  line-height: 1.4;
}

.camp-phrase-good {
  color: var(--green);
  background: rgba(52, 211, 153, 0.08);
  border: 1px solid rgba(52, 211, 153, 0.28);
}

.camp-phrase-bad {
  color: var(--red);
  background: rgba(248, 113, 113, 0.07);
  border: 1px solid rgba(248, 113, 113, 0.28);
}

.camp-phrase-none {
  color: var(--muted);
  font-weight: 500;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--border-strong);
}

.camp-phrase-note { font-size: 12px; color: var(--muted-2); }

.camp-split-legend {
  display: flex;
  gap: 8px 18px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.camp-split-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.camp-split-legend b { color: var(--text); font-weight: 600; }

.camp-meta {
  display: flex;
  gap: 8px 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted-2);
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: auto;
}

/* ---------- Vista Señales a Meta ---------- */

.card-head-pad { padding: 14px 16px 0; margin-bottom: 4px; }

.event-name-raw {
  display: block;
  font-size: 11px;
  color: var(--muted-2);
  font-weight: 400;
  margin-top: 1px;
}

.event-queue-note { font-size: 11.5px; margin-top: 2px; }

.pctbar { display: flex; align-items: center; gap: 8px; min-width: 130px; }

.pctbar-track {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
}

.pctbar-fill { height: 100%; background: var(--grad); border-radius: 3px; }

.pctbar-num { font-size: 12px; color: var(--muted); width: 42px; text-align: right; flex-shrink: 0; }

.sig-purchases {
  display: flex;
  align-items: center;
  gap: 18px 36px;
  flex-wrap: wrap;
  padding: 6px 0 2px;
}

.sig-flow { display: flex; align-items: center; gap: 16px; }

.sig-flow-item { display: flex; flex-direction: column; gap: 1px; }
.sig-flow-item b { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.sig-flow-item .muted { font-size: 12.5px; }

.sig-flow-arrow { color: var(--muted-2); font-size: 20px; }

.sig-flow-rest { display: flex; gap: 18px; font-size: 13px; }
.sig-flow-rest b { font-weight: 700; }

.sig-note { font-size: 12.5px; margin: 12px 0 0; }

/* ---------- Integraciones solo-lectura (viewer) ---------- */

.integration-readonly {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
}

/* ---------- Vista LTV (v4) ---------- */

.ltv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.ltv-card { display: flex; flex-direction: column; gap: 13px; }

.ltv-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }

.ltv-product { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; overflow-wrap: anywhere; }

/* El multiplicador es el héroe de la tarjeta */
/* Headline adaptativo: el × grande + su ventana ("a 90 días") */
.ltv-headline { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.ltv-headline-window { font-size: 11.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }

.ltv-mult { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.ltv-mult-na { color: var(--muted-2); }

.ltv-flow { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.ltv-flow b { color: var(--text); font-weight: 700; font-size: 15px; }

/* Fila de ventanas 7d / 30d / 90d */
.ltv-windows { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.ltv-window {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  background: rgba(255, 255, 255, 0.015);
}

.ltv-window-headline { border-color: rgba(52, 211, 153, 0.35); background: rgba(52, 211, 153, 0.05); }

.ltv-window-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.ltv-window-total { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.ltv-window-mult { font-size: 12.5px; font-weight: 600; color: var(--cyan); }

.ltv-bar-wrap { display: flex; flex-direction: column; gap: 8px; }

.ltv-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--surface-2); }
.ltv-bar-seg { height: 100%; }
.ltv-bar-first { background: var(--green); }
.ltv-bar-d7 { background: var(--cyan); }
.ltv-bar-d30 { background: var(--violet); }
.ltv-bar-d90 { background: var(--amber); }

.ltv-bar-legend { display: flex; gap: 6px 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.ltv-bar-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.ltv-bar-legend b { color: var(--text); font-weight: 600; }
.dot-ltv-first { background: var(--green); }
.dot-ltv-d7 { background: var(--cyan); }
.dot-ltv-d30 { background: var(--violet); }
.dot-ltv-d90 { background: var(--amber); }

.ltv-month-cell { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

.ltv-na-note { margin: 0; font-size: 12.5px; }

.ltv-pred-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.ltv-pred-item {
  display: flex;
  align-items: baseline;
  gap: 8px 14px;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.015);
}

.ltv-pred-name { font-weight: 700; flex: 1; min-width: 160px; overflow-wrap: anywhere; }
.ltv-pred-item .muted { font-size: 12px; }
.ltv-pred-value { font-size: 17px; font-weight: 800; letter-spacing: -0.01em; }

.ltv-toggle { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }

/* ---------- Comparador de creativos (v5) ---------- */

.cr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 14px;
}

.cr-card { display: flex; flex-direction: column; gap: 13px; }

.cr-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }

.cr-title { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cr-name { font-size: 15.5px; font-weight: 700; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.cr-platform {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cr-stats { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; }
.cr-stats b { color: var(--text); font-weight: 700; }

/* El contraste inmediato → real: el corazón visual de la vista */
.cr-contrast {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.cr-contrast-side { display: flex; flex-direction: column; gap: 2px; }
.cr-contrast-label { font-size: 11px; color: var(--muted); font-weight: 600; }
.cr-contrast-immediate { font-size: 20px; font-weight: 700; color: var(--muted); letter-spacing: -0.02em; }
.cr-contrast-side-strong .cr-contrast-label { color: var(--text); }
.cr-contrast-ltv { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; color: var(--text); }
.cr-contrast-arrow { color: var(--muted-2); font-size: 18px; }

.cr-mult {
  margin-left: auto;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  align-self: center;
}

/* Barras comparativas immediate vs ltv */
.cr-bars { display: flex; flex-direction: column; gap: 8px; }
.cr-bar-row { display: grid; grid-template-columns: 66px 1fr 52px; align-items: center; gap: 10px; }
.cr-bar-tag { font-size: 11px; color: var(--muted); font-weight: 600; }
.cr-bar-track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.cr-bar-fill { height: 100%; border-radius: 4px; }
.cr-bar-immediate { background: var(--muted-2); }
.cr-bar-ltv { background: var(--grad); }
.cr-bar-val { font-size: 12.5px; font-weight: 600; color: var(--muted); text-align: right; }
.cr-bar-val-strong { color: var(--text); font-weight: 700; }

.cr-ltv-line {
  display: flex;
  gap: 6px 18px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 11px;
}
.cr-ltv-line b { color: var(--text); font-weight: 700; }

/* Sección plegable de creativos con datos insuficientes */
.cr-insufficient { padding: 0; overflow: hidden; }
.cr-insufficient-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 18px;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
}
.cr-insufficient-toggle:hover { color: var(--text); }
.cr-insufficient-count {
  margin-left: 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
}
.cr-insufficient-list {
  list-style: none;
  margin: 0;
  padding: 0 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cr-insufficient-item {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  padding: 9px 0;
  border-top: 1px solid var(--border);
}
.cr-insufficient-name { font-weight: 600; min-width: 140px; overflow-wrap: anywhere; }
.cr-insufficient-reason { font-size: 12px; flex: 1; min-width: 180px; }

@media (max-width: 560px) {
  .cr-contrast-ltv { font-size: 24px; }
  .cr-mult { margin-left: 0; }
}

/* ---------- Interruptor (switch) ---------- */

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  color: var(--text);
}

.switch:disabled { opacity: 0.5; cursor: not-allowed; }

.switch-track {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  position: relative;
  flex-shrink: 0;
  transition: background var(--tr), border-color var(--tr);
}

.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform var(--tr), background var(--tr);
}

.switch-on .switch-track { background: var(--grad); border-color: transparent; }
.switch-on .switch-knob { transform: translateX(16px); background: #06251e; }

/* ---------- Vista Audiencias (v4) ---------- */

.aud-row {
  display: flex;
  gap: 12px 18px;
  align-items: flex-start;
  padding: 15px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  flex-wrap: wrap;
}

.aud-row:last-child { border-bottom: none; }
.aud-row-disabled { opacity: 0.55; }

.aud-main { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 3px; }
.aud-name { font-weight: 700; overflow-wrap: anywhere; }
.aud-rule { font-size: 12.5px; color: var(--muted); }
.aud-match { font-size: 12.5px; color: var(--cyan); }

.aud-state { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; max-width: 440px; }
.aud-state-note { font-size: 12px; }

.aud-error {
  font-family: 'SF Mono', ui-monospace, Menlo, monospace;
  font-size: 12px;
  color: #fecaca;
  overflow-wrap: anywhere;
}

.aud-error-help { font-size: 12px; color: var(--amber); }

.aud-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }

.aud-suggestions { display: flex; gap: 8px; flex-wrap: wrap; }

.aud-foot-note { font-size: 12.5px; margin: 0; }

/* ---------- Vista Informes (digest, v4) ---------- */

.digest-card { display: flex; flex-direction: column; gap: 14px; }

.digest-range { font-size: 15px; }

.digest-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.digest-kpi { display: flex; flex-direction: column; gap: 3px; }

.digest-kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.digest-kpi-value { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }

.digest-kpi .delta { font-size: 12px; }

.digest-top {
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 11px;
}

.digest-top b { color: var(--text); }

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
  .journey-layout { grid-template-columns: 1fr; }
  .journey-search { position: static; }
}

@media (max-width: 820px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    overflow-x: auto;
  }
  .sidebar nav { flex-direction: row; }
  .nav-item { padding: 7px 10px; }
  .nav-item-active { box-shadow: inset 0 -2px 0 var(--green); }
  .nav-setup { margin-top: 0; white-space: nowrap; }
  .content { padding: 18px 16px 50px; }
  .kpi-value { font-size: 24px; }
  .tl-amount { font-size: 24px; }
  .funnel-step { min-width: 180px; padding: 13px 16px; }
  .funnel-count { font-size: 24px; }
  .funnel-conv { font-size: 11.5px; padding: 3px 11px; }
  .sig-flow-item b { font-size: 20px; }
  .ltv-mult { font-size: 26px; }
  .digest-kpi-value { font-size: 17px; }
}

/* ============================================================
   MOTION — micro-interacciones premium (solo transform/opacity)
   Extiende el sistema existente. Todo se neutraliza bajo
   prefers-reduced-motion (bloque al final del archivo).
   ============================================================ */

/* Números tabulares para el count-up (mismo ancho por dígito) */
.tabular-nums { font-variant-numeric: tabular-nums; }

/* ---- Entrada escalonada (fade + slide-up) ---- */
@keyframes motion-enter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.stagger-in {
  opacity: 0;
  animation: motion-enter 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  animation-delay: calc(var(--i, 0) * 40ms);
  will-change: transform, opacity;
}

/* Crossfade skeleton → contenido (el contenido entra por opacity) */
@keyframes motion-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.motion-fade { animation: motion-fade-in 0.32s ease forwards; }

/* ---- Transición entre vistas del router ---- */
@keyframes view-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-enter {
  animation: view-enter 0.34s cubic-bezier(0.16, 1, 0.3, 1) both;
  will-change: transform, opacity;
}

/* ---- Indicador de nav deslizante ---- */
.nav-indicator {
  position: absolute;
  left: 0;
  width: 2px;
  height: 18px;
  border-radius: 2px;
  background: var(--grad);
  transform: translateY(var(--nav-ind-y, 0));
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity var(--tr-fast);
  pointer-events: none;
  will-change: transform;
  z-index: 1;
}

.nav-indicator-hidden { opacity: 0; }

/* Cuando el indicador JS está activo, ocultamos la barra ::before por-ítem
   (fallback si JS no midió: la barra ::before original sigue visible) */
.sidebar nav[data-has-indicator='1'] .nav-item-active::before { opacity: 0; }

/* ---- Hover/press feedback ---- */
.card {
  transition: transform var(--tr), box-shadow var(--tr), border-color var(--tr);
}
.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
}

/* Press: feedback de pulsación en botones (encima de las reglas existentes) */
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn-primary:active:not(:disabled) { transform: scale(0.97); }
.chip:active, .seg-btn:active { transform: scale(0.96); }

/* Filas de tabla: transición del highlight */
.table tbody tr { transition: background var(--tr), box-shadow var(--tr); }

/* ---- Charts animados ---- */
/* AreaChart: la línea se traza con stroke-dashoffset */
.chart-line-draw {
  stroke-dasharray: var(--chart-len, 1200);
  stroke-dashoffset: var(--chart-len, 1200);
  animation: chart-draw 1.05s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes chart-draw { to { stroke-dashoffset: 0; } }

/* El área hace fade tras la línea */
.chart-area-fade { opacity: 0; animation: motion-fade-in 0.6s ease 0.35s forwards; }

/* Barras que crecen desde 0 (scaleX, transform-origin izquierda → capa de composición) */
.bar-grow {
  transform: scaleX(var(--bar-scale, 1));
  transform-origin: left center;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

/* Funnel: pasos caen en cascada; píldoras aparecen después */
@keyframes funnel-drop {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.funnel-step-anim {
  opacity: 0;
  animation: funnel-drop 0.44s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  animation-delay: calc(var(--fi, 0) * 90ms);
  will-change: transform, opacity;
}
.funnel-conv-anim {
  opacity: 0;
  animation: motion-fade-in 0.35s ease forwards;
  animation-delay: calc((var(--fi, 0) * 90ms) + 200ms);
}

/* ---- Badge de salud CAPI: pulso sutil cuando está operativo ---- */
@keyframes health-pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(52, 211, 153, 0.7); }
  50% { box-shadow: 0 0 14px 2px rgba(52, 211, 153, 0.45); }
}
.health-ok .health-dot { animation: health-pulse 2.4s ease-in-out infinite; }

/* Atención sutil para warn/bad (parpadeo tenue de opacidad) */
@keyframes health-attention {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
.health-warn .health-dot,
.health-bad .health-dot { animation: health-attention 1.6s ease-in-out infinite; }

/* ---- Sparkline en KPI cards ---- */
.kpi-spark { display: block; margin-top: 2px; width: 100%; height: 26px; overflow: visible; }
.kpi-spark-line {
  fill: none;
  stroke: url(#sparkGrad);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.kpi-spark-area { opacity: 0.9; }

/* ---- Coach-mark (onboarding hint descartable) ---- */
.coach {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid rgba(34, 211, 238, 0.3);
  background:
    radial-gradient(420px 120px at 12% 0%, rgba(34, 211, 238, 0.08), transparent 70%),
    var(--surface);
  border-radius: var(--radius);
  padding: 13px 15px;
  box-shadow: var(--shadow-sm);
  animation: motion-enter 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.coach-icon {
  flex-shrink: 0;
  color: var(--cyan);
  display: inline-flex;
  margin-top: 1px;
}
.coach-body { flex: 1; min-width: 0; }
.coach-title { font-weight: 700; font-size: 13.5px; }
.coach-text { color: var(--muted); font-size: 12.5px; margin-top: 2px; line-height: 1.5; }
.coach-close { margin-left: 4px; }

/* ---- Estado vacío: la ilustración respira ---- */
@keyframes empty-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
.empty-art { animation: empty-float 3.6s ease-in-out infinite; }

/* Skeleton → contenido: contenedor con crossfade */
.content-fade { animation: motion-fade-in 0.3s ease forwards; }

/* ============================================================
   RESPONSIVE (existente) + REDUCED MOTION (innegociable)
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  /* Neutralizamos los estados de partida: todo visible y sin desplazamiento */
  .stagger-in,
  .view-enter,
  .funnel-step-anim,
  .funnel-conv-anim,
  .chart-area-fade,
  .motion-fade,
  .content-fade,
  .coach { opacity: 1 !important; transform: none !important; }
  .chart-line-draw { stroke-dashoffset: 0 !important; }
  .bar-grow { transform: scaleX(1) !important; }
  .empty-art,
  .health-ok .health-dot,
  .health-warn .health-dot,
  .health-bad .health-dot { animation: none !important; }
  .card-hover:hover { transform: none !important; }
  .btn:active:not(:disabled),
  .btn-primary:active:not(:disabled),
  .chip:active,
  .seg-btn:active { transform: none !important; }
}
