:root {
  --bg: #0f1622;
  --bg-elev: #18212f;
  --bg-card: #1c2738;
  --border: #2a3548;
  --text: #e8edf5;
  --text-dim: #8a98ad;
  --teal: #2dd4bf;
  --teal-soft: rgba(45, 212, 191, 0.15);
  --violet: #8b5cf6;
  --orange: #f59e0b;
  --magenta: #ec4899;
  --green: #10b981;
  --red: #ef4444;
  --blue: #3b82f6;
  --green-soft: rgba(16, 185, 129, 0.18);
  --red-soft: rgba(239, 68, 68, 0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, sans-serif;
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-wrap: wrap;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 12px var(--teal); }
.brand h1 { font-size: 18px; margin: 0; font-weight: 700; }
.brand .subtitle { color: var(--text-dim); font-size: 13px; }

.filtros { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.filtros label { display: flex; flex-direction: column; font-size: 11px; color: var(--text-dim); gap: 4px; }
.filtros input, .filtros select {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}
.filtros input:focus, .filtros select:focus { outline: 1px solid var(--teal); }
.btn-reset {
  align-self: flex-end;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 7px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}
.btn-reset:hover { color: var(--text); border-color: var(--teal); }

main { padding: 24px 32px 64px; max-width: 1600px; margin: 0 auto; }

.seccion { margin-bottom: 40px; }
.seccion-title {
  font-size: 22px;
  font-weight: 700;
  margin: 8px 0 20px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* Cards */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.card-label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.card-value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.card-value.teal { color: var(--teal); }
.card-value.violet { color: var(--violet); }
.card-value.orange { color: var(--orange); }
.card-value.magenta { color: var(--magenta); }

/* Bloques (gráficos / funnel) */
.bloque {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
}
.bloque h3 { margin: 0 0 2px; font-size: 14px; font-weight: 600; }
.bloque .sub, .bloque p { margin: 0 0 10px; color: var(--text-dim); font-size: 11px; }
.bloque { position: relative; }
.bloque canvas { max-width: 100%; height: 220px !important; width: 100% !important; }
.bloque canvas.canvas-med  { height: 320px !important; }
.bloque canvas.canvas-tall { height: 420px !important; }

.bloque-head { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.badges { display: flex; gap: 8px; }
.badge {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.ko { background: var(--red-soft); color: var(--red); }

/* Charts grid */
.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.charts-grid-3 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* Funnel */
.funnel { display: flex; flex-direction: column; gap: 14px; }
.funnel-paso { padding: 6px 0; }
.funnel-paso-head {
  display: grid;
  grid-template-columns: 28px 1fr auto auto auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 13px;
}
.paso-num {
  background: var(--bg-elev);
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 4px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
}
.paso-nombre { font-weight: 500; }
.paso-leads { font-size: 18px; font-weight: 700; }
.paso-avanzo { color: var(--green); font-size: 12px; }
.paso-inicio { color: var(--text-dim); font-size: 12px; }
.funnel-bar {
  height: 14px;
  background: var(--bg-elev);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.funnel-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), #4cf0d4);
  border-radius: 4px;
  transition: width 0.6s ease;
}
.funnel-flecha {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  color: var(--text-dim);
  font-size: 11px;
}
.funnel-flecha .abandono { color: var(--red); }

.creditos {
  text-align: center;
  padding: 24px;
  color: var(--text-dim);
  font-size: 12px;
  border-top: 1px solid var(--border);
}
.creditos a { color: var(--teal); text-decoration: none; }
.creditos a:hover { text-decoration: underline; }

/* Legend custom para donuts */
.legend { margin-top: 12px; font-size: 12px; }
.legend-row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.legend-row:last-child { border-bottom: 0; }
.legend-row .left { display: flex; align-items: center; gap: 8px; }
.legend-row .swatch { width: 10px; height: 10px; border-radius: 50%; }
.legend-row .right { color: var(--text-dim); }
.legend-row .right b { color: var(--text); margin-right: 6px; }
